<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Peng Liu on Medium]]></title>
        <description><![CDATA[Stories by Peng Liu on Medium]]></description>
        <link>https://medium.com/@liu.peng.uppsala?source=rss-e229153631c3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SJ7phrCqB9dOxMuLFP_kuw@2x.jpeg</url>
            <title>Stories by Peng Liu on Medium</title>
            <link>https://medium.com/@liu.peng.uppsala?source=rss-e229153631c3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:33:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@liu.peng.uppsala/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[<h1 class=”graf graf — h1"> Fine-tuning LLMs on macOS (Apple Silicon Guide)</h1>
<p class=”graf…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/h1-class-graf-graf-h1-fine-tuning-llms-on-macos-apple-silicon-guide-h1-p-class-graf-6cbd9dd7725d?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*7avfqVo_7vr9TAdk" width="6000"></a></p><p class="medium-feed-snippet"># Run the setup script
./setup.sh
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 class=&#x201D;graf graf&#x200A;&#x2014;&#x200A;h3&quot;&gt;2. Configure for Mac (&lt;code class=&#x201D;markup&#x200A;&#x2014;&#x200A;code markup &#x2014;&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/h1-class-graf-graf-h1-fine-tuning-llms-on-macos-apple-silicon-guide-h1-p-class-graf-6cbd9dd7725d?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/h1-class-graf-graf-h1-fine-tuning-llms-on-macos-apple-silicon-guide-h1-p-class-graf-6cbd9dd7725d?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cbd9dd7725d</guid>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[grpo]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 13:15:46 GMT</pubDate>
            <atom:updated>2025-12-23T08:33:18.985Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Fine-Tune an SLM or Prompt an LLM?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/fine-tune-an-slm-or-prompt-an-llm-0d3cdf5c0876?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*dXJ9twFi2FbLB5IG" width="4023"></a></p><p class="medium-feed-snippet">A Deep Dive Into How Researchers Compared Two Paths for Workflow Generation</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/fine-tune-an-slm-or-prompt-an-llm-0d3cdf5c0876?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/fine-tune-an-slm-or-prompt-an-llm-0d3cdf5c0876?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d3cdf5c0876</guid>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 20:50:00 GMT</pubDate>
            <atom:updated>2025-12-23T09:46:39.357Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Key-Value (KV) Cache Size Calculations in Grouped Query Attention (GQA)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/key-value-kv-cache-size-calculations-in-grouped-query-attention-gqa-e090d3037ab3?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*1GC2FaJVeOLB4qxR" width="3024"></a></p><p class="medium-feed-snippet">To calculate the key-value (KV) cache size in grouped query attention (GQA), you need to know the sequence length, batch size, number of&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/key-value-kv-cache-size-calculations-in-grouped-query-attention-gqa-e090d3037ab3?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/key-value-kv-cache-size-calculations-in-grouped-query-attention-gqa-e090d3037ab3?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e090d3037ab3</guid>
            <category><![CDATA[kv-cache]]></category>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[memory-management]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 07:50:28 GMT</pubDate>
            <atom:updated>2025-07-24T07:50:28.822Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Fine-tuning ModernBERT for Text Classification with PyTorch Lightning]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/fine-tuning-modernbert-for-text-classification-with-pytorch-lightning-0ba444ddc9bb?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*cbeQsQX2dQf2FKMa" width="5472"></a></p><p class="medium-feed-snippet">In this blog, we&#x2019;ll explore how to fine-tune ModernBERT for text classification tasks using PyTorch Lightning. We&#x2019;ll cover the&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/fine-tuning-modernbert-for-text-classification-with-pytorch-lightning-0ba444ddc9bb?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/fine-tuning-modernbert-for-text-classification-with-pytorch-lightning-0ba444ddc9bb?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ba444ddc9bb</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[pytorch-lightning]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[bert]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 14:06:20 GMT</pubDate>
            <atom:updated>2025-03-14T09:38:36.517Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build your own search engineer using ModernBERT and Voyoger]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/build-your-own-search-engineer-using-modernbert-and-voyoger-0ca86d99aee9?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*knV3yM4m9yBYqHnx" width="3999"></a></p><p class="medium-feed-snippet">Semantic search has become widely used in different machine learning applications. Unlike the boolean (key words search), semantic search&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/build-your-own-search-engineer-using-modernbert-and-voyoger-0ca86d99aee9?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/build-your-own-search-engineer-using-modernbert-and-voyoger-0ca86d99aee9?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ca86d99aee9</guid>
            <category><![CDATA[semantic-search]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[modern-bert]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 08:18:10 GMT</pubDate>
            <atom:updated>2025-03-14T15:32:51.131Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding ColBERT: What is New Comparing with Normal Semantic Search]]></title>
            <link>https://medium.com/@liu.peng.uppsala/understanding-colbert-what-is-new-comparing-with-normal-semantic-search-6dc285311a18?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dc285311a18</guid>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Wed, 26 Feb 2025 07:56:24 GMT</pubDate>
            <atom:updated>2025-02-26T07:56:24.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sjU9SnS5SkEscRcA" /><figcaption>Photo by <a href="https://unsplash.com/@iamromankraft?utm_source=medium&amp;utm_medium=referral">Roman Kraft</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the rapidly evolving landscape of information retrieval, <strong>ColBERT (Contextualized Late Interaction over BERT)</strong> has emerged as a compelling architecture that rethinks how we approach search and ranking. While many are familiar with transformer-based embedding models like BERT, RoBERTa, or Sentence-BERT, ColBERT distinguishes itself not by replacing these models but by orchestrating their use through a novel <strong>late interaction</strong> mechanism. In this blog, we’ll explore what makes ColBERT unique, how it compares to traditional dense embedding approaches and cross-encoders, and why its design can be both a blessing and a challenge depending on your use case.</p><blockquote><strong>The Traditional Approach: Dense Embeddings &amp; Similarity Scoring</strong></blockquote><p>Before diving into ColBERT, let’s briefly review how many modern retrieval systems operate:</p><ul><li><strong>Embedding Models</strong></li></ul><p>Models such as BERT generate dense, high-dimensional vector representations for text. Traditionally, both documents and queries are passed through these models to obtain a single embedding per document or query.</p><ul><li><strong>Similarity Computation</strong></li></ul><p>Once each document and query is represented as a single vector, similarity is measured (e.g., via cosine similarity or inner product). This method works well in many contexts and is especially popular with managed vector databases like Pinecone or FAISS.</p><ul><li><strong>Indexing and Retrieval</strong></li></ul><p>With the dense embeddings computed, documents are indexed, and during query time, the system computes similarity scores to retrieve the top-k most relevant documents.</p><p>While this dense retrieval approach is efficient and simple to implement, it comes with a trade-off: by compressing an entire document into one vector, you risk losing granular token-level details that can be critical for nuanced search tasks.</p><p>— -</p><blockquote><strong>ColBERT: A Paradigm Shift in Retrieval</strong></blockquote><ul><li><strong>Token-Level Embeddings Without Aggregation</strong></li></ul><p>- <strong><em>Granular Representation: </em></strong><br> Unlike standard methods that aggregate token embeddings (e.g., by averaging or pooling) into a single vector, ColBERT retains **every token’s embedding**. This means that for a document like “How do I reset my password?”, ColBERT stores individual embeddings for “How”, “do”, “I”, “reset”, “my”, “password”, and even “?”.<br> <br>- <strong><em>Contextualized Detail</em></strong><em>: </em><br> By preserving the token-level details, ColBERT allows for a more fine-grained matching process. This is especially beneficial when distinguishing between subtle variations in language, such as synonyms or context-dependent meanings.</p><ul><li><strong>The Late Interaction Mechanism</strong></li></ul><p>- <strong><em>What Is Late Interaction?</em></strong><br> In traditional cross-encoders, the query and document are concatenated and fed into a transformer model, where interactions between query and document tokens happen “early” in the model’s layers. In contrast, ColBERT splits the process into two distinct phases:<br> <br><strong><em>- Encoding Phase: </em></strong><br> The query and each document are independently encoded into token-level embeddings.<br> <br><strong><em>- Interaction Phase: </em></strong><br> Rather than fusing these embeddings within the model, ColBERT performs <strong>late interaction</strong> externally. For each query token, it identifies the most similar token in the document using the <strong>MaxSim operator</strong> (often via Maximum Inner Product Search). These per-token similarity scores are then aggregated (typically by summing) to yield an overall relevance score.</p><p><strong><em>- Benefits of Late Interaction:</em></strong><br>Efficiency and Scalability: Document embeddings can be precomputed and indexed, allowing for rapid lookup even in large corpora.<br> Flexibility: By deferring the interaction step, ColBERT can flexibly match different parts of the query with various parts of a document, accommodating complex or ambiguous queries.</p><ul><li><strong>Comparison with Cross-Encoders</strong></li></ul><p><strong><em>- Cross-Encoders: </em></strong><br> These models process the concatenated query-document pair in one go. All interactions are “early,” and while they tend to capture detailed relationships, the computational cost is high — especially if you need to compare the query against a large number of documents.</p><p><strong><em>- ColBERT’s approach: </em></strong><br> By separating encoding and interaction, ColBERT often provides a faster inference time for ranking, particularly in a reranking scenario where a dense retriever first narrows down candidates. This “two-stage” retrieval strategy — initial retrieval with a simple dense model followed by ColBERT reranking — can combine efficiency with high retrieval precision.</p><blockquote><strong>Architectural Overview: How ColBERT Works</strong></blockquote><p>Let’s break down ColBERT’s pipeline into key phases:</p><p>A. Indexing Phase</p><p>1. Document Encoding: <br> — Each document is tokenized.<br> — A transformer model (e.g., BERT) generates an embedding for every token.<br> — All token embeddings are stored, preserving the fine-grained information.</p><p>2. Building the Index: <br> — An efficient vector search engine (like FAISS) indexes these token embeddings.<br> — A mapping (e.g., `doc_token_map`) keeps track of which token belongs to which document and its position.</p><p>B. Query Phase</p><p>1. Query Encoding: <br> — The query is similarly tokenized and encoded into individual token embeddings.</p><p>2. Late Interaction (MaxSim Operator): <br> — For each query token, the system searches the index to find the document token with the highest similarity score.<br> — These maximum scores are aggregated to compute a final relevance score for each document.</p><p>3. Ranking and Retrieval: <br> — Documents are ranked based on their aggregated scores, and the top-k results are returned.</p><p>When to Use ColBERT vs. Dense Retrieval</p><p>ColBERT is Ideal When:</p><p>- High Retrieval Precision is Required: <br> In scenarios where nuanced token-level differences matter — such as legal document search or technical FAQ retrieval — the detailed matching provided by ColBERT can be invaluable.</p><p>- Reranking is Viable: <br> Due to its computational intensity, ColBERT often works best as a reranker. An initial dense retrieval step can narrow down the candidate set (e.g., 100–500 documents), after which ColBERT fine-tunes the ranking.</p><p>Dense Embeddings Are Preferable When:</p><p>- Simplicity and Speed are Paramount: <br> For many applications, especially those with smaller datasets (like ~500 FAQ documents), a single dense vector per document is sufficient and easier to manage.</p><p>- Resource Constraints Exist: <br> Dense retrieval systems require less storage and computational overhead compared to maintaining multiple embeddings per document.</p><blockquote><strong>Final Thoughts</strong></blockquote><p>ColBERT represents a significant advancement in the realm of document retrieval by leveraging the power of transformer-based token-level embeddings coupled with a clever late interaction mechanism. Its design allows for more granular and context-aware matching compared to traditional dense embedding methods, making it a strong candidate for applications where precision is non-negotiable.</p><p>However, the architectural benefits of ColBERT come with increased complexity and resource demands. For many real-world applications — especially those with moderate datasets — a simple dense retriever, potentially augmented with a ColBERT-based reranker, strikes the right balance between performance and efficiency.</p><p>As research and development continue in the field of information retrieval, architectures like ColBERT will undoubtedly inspire even more hybrid approaches, combining the strengths of early and late interaction paradigms to push the boundaries of what retrieval systems can achieve.</p><p>— -</p><p><em>Interested in learning more about ColBERT and its implementation? Check out the [Qdrant FastEmbed ColBERT documentation](</em><a href="https://qdrant.tech/documentation/fastembed/fastembed-colbert/"><em>https://qdrant.tech/documentation/fastembed/fastembed-colbert/</em></a><em>) for additional insights and practical guidance.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dc285311a18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set up and manage the python environment using pyenv and poetry]]></title>
            <link>https://medium.com/@liu.peng.uppsala/set-up-and-manage-the-python-environment-using-pyenv-and-poetry-ebeaacd347f3?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebeaacd347f3</guid>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Sun, 22 Dec 2024 20:21:30 GMT</pubDate>
            <atom:updated>2024-12-22T20:21:30.136Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4RjckQR0fHRa6uBD" /><figcaption>Photo by <a href="https://unsplash.com/@hiteshchoudhary?utm_source=medium&amp;utm_medium=referral">Hitesh Choudhary</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>1. Python Version Management:</strong></h3><p><strong>Pyenv</strong>:</p><p><strong>1a. Installation</strong>:</p><ul><li>See Github Repo : <a href="https://github.com/pyenv/pyenv">https://github.com/pyenv/pyenv</a></li></ul><p><strong>1b. How to use:</strong></p><ul><li>For example: create a python version 3.12.0</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LE17k5sjPAJVFrp3q5l2gA.png" /></figure><ul><li>List python versions installed</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJPTgVyzzt--7wcd9Al0Ow.png" /></figure><h3><strong>2. Python lib environment management:</strong></h3><h4><strong>Poetry</strong></h4><p><strong>2a. Installation:</strong></p><ul><li>See the github repo: <a href="https://github.com/python-poetry/poetry">https://github.com/python-poetry/poetry</a></li></ul><p><strong>2b. Create a new python environment:</strong></p><ul><li>Create a new environment</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NgB2u2xPlCCPqtb2qgHMDA.png" /></figure><ul><li>poetry env use 3.12.0 # select the right python version for poetry to use</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZRdyhzBaswAYGUtA235EA.png" /></figure><ul><li>Initiate the shell # working in the virtual environment you specified</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qgAAuacUPc-f8hh46pVFA.png" /></figure><p><strong>2c. Add the desired packages:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-02Uc13ejfEssUrkmSf0Og.png" /></figure><p>2d. <strong>pyproject.toml</strong></p><p>pyproject.toml is the configuration file for a Python project managed by Poetry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*am3MVaOc3g_hRz_frO2l3A.png" /></figure><h4>[tool.poetry]</h4><p>This section contains general metadata about the project.</p><ul><li><strong>name</strong>: The name of the project/package.</li><li><strong>version</strong>: The version of the project/package.</li><li><strong>description</strong>: A brief description of the project.</li><li><strong>authors</strong>: A list of authors with their names and contact information.</li><li><strong>readme</strong>: The README file for the project.</li></ul><h4>[tool.poetry.dependencies]</h4><p>This section specifies the dependencies required for the project.</p><ul><li><strong>python = &quot;3.11.10&quot;</strong>: Specifies the Python version the project is compatible with.</li><li><strong>google-cloud = &quot;^0.34.0&quot;</strong>: Adds a dependency on the google-cloud library.</li><li><strong>pandas = &quot;^2.2.3&quot;</strong>: Adds a dependency on the pandas library, a popular library for data manipulation and analysis.</li></ul><h4>[build-system]</h4><p>This section defines the build system for the project, indicating how to build the project into a distributable format (e.g., a wheel or source distribution).</p><ul><li><strong>requires = [&quot;poetry-core&quot;]</strong>: Specifies that the project build process requires the poetry-core package.</li><li><strong>build-backend = &quot;poetry.core.masonry.api&quot;</strong>: Defines the backend responsible for building the project.</li></ul><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebeaacd347f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rethink Your RAG Solutions: A Data-Driven Approach to Unlocking LLM Potential]]></title>
            <link>https://medium.com/hackerai/rethink-your-rag-solutions-a-data-driven-approach-to-unlocking-llm-potential-e7bbc1c9dc07?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7bbc1c9dc07</guid>
            <category><![CDATA[fine-tuning-llm]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 14:36:46 GMT</pubDate>
            <atom:updated>2024-11-04T14:36:46.659Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NLCwWEzl6-9F3y66" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>All contents/views have been talked about in this article mainly come from the paper:</p><blockquote><a href="https://arxiv.org/abs/2409.14924">Retrieval Augmented Generation (RAG) and Beyond: A Comprehensive Survey on How to Make your LLMs use External Data More Wisely</a></blockquote><p>Retrieval augmented generations has been widely adopted in large language model (LLM) based solutions, from smart Chatbot to advanced agent. Here are the main benefits:</p><p><strong>1. Enhanced Professionalism and Timeliness:</strong></p><p>The data used to train LLMs often lags in timeliness and may not cover all domains comprehensively, especially proprietary data owned by users. Data augmented LLM applications address this issue by providing more detailed and accurate answers for complex questions, allowing for data updates and customization.</p><p><strong>2. Alignment with Domain Experts:</strong></p><p>Through the use of and learning from domain-specific data, data augmented LLM applications can exhibit capabilities more like domain experts, such as doctors and lawyers.</p><p><strong>3. Reduction in Model Hallucination:</strong></p><p>Data augmented LLM applications generate responses based on real data, grounding their reactions in facts and significantly minimizing the possibility of hallucinations.</p><p><strong>4. Improved Controllability and Explainability:</strong></p><p>The data used can serve as a reference for the model’s predictions, enhancing both controllability and explainability.</p><h3><strong>Stratification of Queries</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnG2nVZpGeFIhvdNf1PI7g.png" /></figure><h3><strong>Explicit Fact Queries (L1)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dV6kYC2ZDYJxmxzwPStCg.png" /></figure><p><strong>Traditional alignment </strong>involves mapping both document segments and the query into the same encoding space</p><p><strong>Document domain alignment </strong>involves generating synthetic answers first, then using these answers to recall relevant data, effectively addressing the issue of queries and retrieved data not being in the same distribution space.</p><p><strong>Query domain alignment </strong>involves generating a set of synthetic questions for each atomic unit of text, mapping text segments into the query space, and then retrieving the synthetic questions closest to the original query along with their corresponding text segments</p><h3><strong>Implicit Fact Queries (L2)</strong></h3><ol><li><strong>Challenges</strong></li></ol><p>a. Adaptive retrieval volumes</p><p>b. Coordination between reasoning and retrieval</p><p>2.<strong> Solutions</strong>:</p><p>a. Iterative RAG</p><p>Planning-based (ReAct)</p><p>Information GapFillingBased (ITRG, generate first and continue retrieve to fill the gap)</p><p>b.Graph/ Tree Question Answering</p><p>Traditional Knowledge Graph</p><p>Data Chunk Graph/ Tree</p><p>c.Natural Language to SQL Queries</p><h3><strong>Rationale Data</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n9zykcE-iNuaUBw3u802Jw.png" /></figure><h3><strong>Interpretable Rationale Queries (L3)- Interpretable Rationales</strong></h3><h4><strong>1. Challenges</strong></h4><p>a. Prompt Optimization Costs</p><p>b. Limited interpretability</p><h4><strong>2. Solutions:</strong></h4><p>a. Prompt Tuning (Optimizes the integration of external rationales into LLMs to ensure accurate responses based on domain-specific reasoning.)</p><p>a.1. Manual prompt design</p><p>a.2. Reinforcement learning for prompt tuning</p><p>a.3. Edit-based methods</p><p>a.4. LLM-assisted prompt optimization</p><p>b. CoT Prompting (Enhances the LLM’s ability to tackle complex, multi-step problems )</p><p>b.1 Manual CoT Prompting</p><p>b.2 Automated CoT Generation</p><p>b.3 CoT in Agent Systems</p><h3><strong>Hidden Rationale Queries (L4)- Hidden Rationales</strong></h3><p>Challeges</p><p><strong>Logical retrieval</strong></p><p>For questions involving hidden rationales, the helpfulness of external data does not simply depend on entity-level or semantic similarity, but rather on logical congruence or thematic alignment.</p><p><strong>Data insufficiency</strong></p><p>Fundamentally, external data may not explicitly contain the guidance or answers relevant to the current query.</p><p><strong>Solutions</strong></p><p><strong>Offline Learning</strong></p><p>Generate reasoning rationales offline by identifying errors and transforming them into useful guidelines for future tasks (e.g., STaR, LEAP).</p><p><strong>In Context Learning (ICL)</strong></p><p>Selects relevant examples based on task similarity, improving the model’s performance through better contextual examples.</p><p><strong>Fine-tuning</strong></p><p>Instruction Tuning: Uses (instruction, output) pairs to infuse new capabilities into the model through fine-tuning.</p><p><strong>Methods include:</strong></p><p>Datasets derived from existing collections, manually created instructions, or synthetic data generated by powerful LLMs.</p><p><strong>Summary:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bbY27YHpA3qIMPoHVxvGQ.png" /></figure><p><strong>Thanks for the reading :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7bbc1c9dc07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackerai/rethink-your-rag-solutions-a-data-driven-approach-to-unlocking-llm-potential-e7bbc1c9dc07">Rethink Your RAG Solutions: A Data-Driven Approach to Unlocking LLM Potential</a> was originally published in <a href="https://medium.com/hackerai">HackerAI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Train machine learning models with mislabeled data in the era of LLMs]]></title>
            <link>https://medium.com/@liu.peng.uppsala/train-machine-learning-models-with-mislabeled-data-in-the-era-of-llms-709e676dd22e?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/709e676dd22e</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[auto-labeling]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Thu, 23 May 2024 09:17:13 GMT</pubDate>
            <atom:updated>2024-05-23T09:17:13.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VsjbAS4PdkGXNg05" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">Firmbee.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Challenge of Mislabeled Data is often existing in real-world applications. Well-labelled data not only can be used for training models but also be important to create baselines for your model performance. Traditionally, data labeling has been a labor-intensive process, reliant on manual effort or semi-automated methods like <a href="https://en.wikipedia.org/wiki/Active_learning_(machine_learning)">active learning</a> (Human annotator involved).</p><p>Large Language Models (LLMs) are revolutionizing various fields, such as conversational bot, advanced search, content generation etc. However, these models are sometimes considered overkill for simpler tasks like basic classifications due to the high operational costs involved, especially in productionalised solutions.</p><p>Instead of using LLMs for everything, training a small language model by leveraging LLMs excellent abilities is more realistic and cost friendly in enterprise setup.</p><h4>1. Workflows with LLMs to augment data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BB10sCNyiQ4lNItRq1A1gw.png" /></figure><ol><li><strong>Unlabeled Data Input</strong>: The process starts with a set of unlabeled data being fed into a classification model (Trained on limited labelled data).</li><li><strong>Small Classification Model Prediction</strong>: The small classification model processes the unlabeled data and generates predictions.</li><li><strong>Confidence Assessment</strong>: The model assesses its confidence in the predictions. Predictions that the model is confident about are used as they are.</li><li><strong>Handling Uncertain Predictions</strong>: Predictions that the model is not confident about are passed to a large language model (LLM).</li><li><strong>Labeling by LLM</strong>: The LLM processes these uncertain predictions and helps in labeling them, generating labeled samples.</li><li><strong>Collection of Labeled Samples</strong>: The newly labeled samples are collected and added to the existing set of labeled data.</li><li><strong>Retraining the Model</strong>: The small classification model is retrained using the updated labeled data set, improving its accuracy and confidence in future predictions.</li><li><strong>Iteration</strong>: This cycle repeats, with the model continuously being fed new unlabeled data, making predictions, seeking assistance from the LLM for uncertain cases, and being retrained with the enriched labeled data set, thereby progressively enhancing its performance.</li></ol><h4>2. Prompt for classifications:</h4><p>Here is an example prompt for classification tasks:</p><blockquote><em>You will be categorizing a customer comment into one of several predefined categories.</em></blockquote><blockquote><em>Here is the customer comment:<br>&lt;customer_comment&gt;<br>{{CUSTOMER_COMMENT}}<br>&lt;/customer_comment&gt;</em></blockquote><blockquote><em>Here is the list of possible categories:<br>&lt;categories&gt;<br>{{CATEGORIES}}<br>&lt;/categories&gt;</em></blockquote><blockquote><em>Please read the customer comment carefully. Then, determine which single category from the list above the comment best belongs to.</em></blockquote><blockquote><em>Write out your reasoning for why you believe the comment fits best in that category inside &lt;reasoning&gt; tags.</em></blockquote><blockquote><em>Then, output the category you selected inside &lt;category&gt; tags.</em></blockquote><blockquote><em>Remember, choose the single most appropriate category for the comment. Explain your reasoning before providing your categorization.</em></blockquote><p><strong>Reading Materials</strong>:</p><p>As for training a BERT model for classification tasks, I have wrote another article <a href="https://medium.com/@liu.peng.uppsala/train-you-own-bert-model-from-scratch-using-pytorch-lightening-9a3c3eef5207">here</a>.</p><p>Enjoy reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709e676dd22e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to communicate to your cloud run instance in GCP using Python (Deploy in Production/Locally)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@liu.peng.uppsala/how-to-communicate-to-your-cloud-run-instance-in-gcp-using-python-deploy-in-production-locally-b41630bd0c28?source=rss-e229153631c3------2"><img src="https://cdn-images-1.medium.com/max/2600/0*7bL8lAhawyL9pCRf" width="5760"></a></p><p class="medium-feed-snippet">Deploy In Production:</p><p class="medium-feed-link"><a href="https://medium.com/@liu.peng.uppsala/how-to-communicate-to-your-cloud-run-instance-in-gcp-using-python-deploy-in-production-locally-b41630bd0c28?source=rss-e229153631c3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@liu.peng.uppsala/how-to-communicate-to-your-cloud-run-instance-in-gcp-using-python-deploy-in-production-locally-b41630bd0c28?source=rss-e229153631c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b41630bd0c28</guid>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Peng Liu]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 12:33:05 GMT</pubDate>
            <atom:updated>2024-04-19T12:33:05.070Z</atom:updated>
        </item>
    </channel>
</rss>