<?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 Nadav Barak on Medium]]></title>
        <description><![CDATA[Stories by Nadav Barak on Medium]]></description>
        <link>https://medium.com/@nadavbarak_49565?source=rss-ce2fa5aa341f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NQfI5l6k8RlQzTCJqV4gbw.png</url>
            <title>Stories by Nadav Barak on Medium</title>
            <link>https://medium.com/@nadavbarak_49565?source=rss-ce2fa5aa341f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 00:53:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nadavbarak_49565/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[Scaling LLM Evaluation]]></title>
            <link>https://pub.towardsai.net/scaling-llm-evaluation-1192d70240bd?source=rss-ce2fa5aa341f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1192d70240bd</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[evaluation]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <dc:creator><![CDATA[Nadav Barak]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 17:02:55 GMT</pubDate>
            <atom:updated>2025-04-28T17:02:55.911Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automated Evaluation Playbook for LLM-Based Applications</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qB5BJaVaEPGmbfH-inbiCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@hjwinunsplsh?utm_source=medium&amp;utm_medium=referral">Jungwoo Hong</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>Large Language Models (LLMs) are transforming machine learning, powering applications like chatbots, RAG, and autonomous agents. But building with LLMs comes with a major hurdle: Their output is evaluated either manually, which is costly and slow, or through crude automation that is inconsistent, lacking detail, and inaccurate. Every pipeline tweak demands re-annotation, eating up time and resources. This post breaks down a step-by-step playbook to a better automated evaluation pipeline which is consistent, explainable and trustworthy.</p><p>For a hands-on tutorial, refer to the <a href="https://github.com/Nadav-Barak/RAG_Evaluation_Workshop/tree/main">accompanying workshop</a>, which includes a template notebook and data you can use as a starting point.</p><h3>Define Evaluation Criteria</h3><p>In order to evaluate machine learning models we rely on a representative evaluation set (either validation or test). In classical machine learning, we feed each sample in the evaluation set to our model, and for each possible output, we can automatically evaluate its correctness and thus evaluate the model’s overall performance. This does not apply when dealing with generated text.</p><p>Evaluating the output of an LLM-based application contains many facets and cannot be achieved using a single correctness metric. For example, consider a generated summarization that, while containing all the key points, lacks fluency and is very difficult to read. Alternatively, consider a question-answering pair where the output, although relevant to the provided question, is not factually correct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwJAB7QAYt6e-m6yjOxhIQ.jpeg" /><figcaption>New tools are needed. Photo by <a href="https://unsplash.com/@glenncarstenspeters">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>The first step in evaluating generated text is to determine the relevant key evaluation criteria for our use case. It is recommended to combine criteria that deal with text quality and criteria that address task fulfillment. For instance, in the <a href="https://arxiv.org/abs/2303.16634">following paper</a> on evaluating text summarizations, the authors used Coherence, Consistency, Fluency, and Relevance as their evaluation criteria.</p><p>The second step is to determine the secondary conditions we want the generated text to uphold. For example, consider a question-answering pair in which the answer is correct but uses toxic language, disclose private information, or highly recommend your competition.</p><p>Once we have our evaluation criteria in place, we would want to build an automated pipeline that would be able to evaluate the criteria for a given sample and they ability to draw actionable conclusions from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*upC9nJE3XVgeWZZzj7BTpA.jpeg" /><figcaption>Understand what are the relevant criteria. Photo by <a href="https://unsplash.com/@lunarts">Volodymyr Hryshchenko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><h3>Divide and Conquer</h3><p>To understand why a more complex solution is necessary, let’s start with the downsides of the naive approach — using a single LLM to evaluate all criteria. The core problem is oversimplification. When one judge is tasked with evaluating multiple dimensions, some criteria don’t get the attention they deserve, which weaken overall performance. Another key issue is consistency: in different runs, the LLM may shift its focus across criteria, leading to uneven and unreliable results.</p><p>This is where divide and conquer comes in. Evaluating each criterion separately ensures it gets the attention it deserves, along with a tailored approach to improve both accuracy and consistency. It also enables more meaningful analysis — separate scores for each criterion make root cause analysis easier and comparisons between versions more insightful.</p><h3>Criterion Evaluation</h3><p>Start by picking a small, focused set of examples to test your evaluator. Make sure the negative cases are clearly negative for the specific criterion you’re targeting — like a sample containing hallucinations for factual accuracy.</p><p>Begin with a basic prompt as your baseline and define a clear KPI which is good enough for your use case. This gives you a reference point for how complex the task is — no need to spend a lot of effort building a car for a 5 km walk. From there, experiment with refinements like <a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought</a>, <a href="https://arxiv.org/abs/2005.14165">Few-Shot Learning</a>, a better model or a multi step process. Continuously track changes in performance to see what actually moves the needle.</p><pre>| Approach            | Advantages                          | Disadvantages                              | Ideal Use Cases                        |<br>|---------------------|-------------------------------------|--------------------------------------------|----------------------------------------|<br>| Model Evaluator     | Fast, cost-effective, consistent    | Require a trained models, limited semantic understanding | Toxicity, Fluency, Input Safety        |<br>| LLM Evaluator       | Flexible, strong text understanding | Higher cost, inconsistent                  | Nuanced Classification, Completeness   |<br>| Multi-Step Process  | High accuracy on complex tasks      | More setup, higher cost and latency        | Hallucination, Content Coverage        |</pre><h4>Model Evaluator</h4><p>Criterion evaluation is fundamentally a classification task, which makes BERT-based classification models a strong fit for certain criteria. They’re faster, more cost-effective than LLMs, consistent, and their specialization can give them an edge in performance for specific tasks (see example <a href="https://arxiv.org/abs/2504.15771">here</a>).</p><p>Since training these models can be a significant overhead, I recommend using them only for relatively common criteria that already have high-performing, pre-trained models available on Hugging Face. Some widely used ones I’d suggest are <a href="https://huggingface.co/s-nlp/roberta_toxicity_classifier">Toxicity</a>, <a href="https://huggingface.co/prithivida/parrot_fluency_model">Fluency</a>, and <a href="https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2">Input Safety</a>.</p><h4>LLM Evaluator</h4><p>LLMs are trained to generate natural language, but their strong understanding of text also makes them <a href="https://arxiv.org/abs/1812.01207">effective for classification tasks</a>. To get the best results when using an LLM as a single-criterion evaluator, it’s crucial to give it just enough information — no more, no less. For example, if you want it to judge the factual accuracy of an output, you need to provide both the output’s claims and relevant reference material. Techniques like prompt engineering, <a href="https://arxiv.org/abs/2201.11903">Chain-Of-Thought</a> reasoning, and <a href="https://arxiv.org/abs/2005.14165">Few-Shot Learning</a> can further improve performance.</p><p>Mixture of Experts (MoE) can boost both the performance and consistency of LLM-based evaluators, but they increase latency and cost. As a result, they should be used selectively — only when the a single judge is failing short and the benefits outweigh the trade-offs.</p><h4>Multi Step Process</h4><p>Some tasks are complex, and just like in car manufacturing — where different parts are assembled separately before the final product is put together — it’s often more effective to divide the work into smaller steps. This same approach applies to evaluating complex criteria.</p><p>Take the task of judging whether a summary includes all the key information from an original article. To do this well, you’d first need to read through the article — possibly in chunks if it’s long — and identify the main ideas or essential facts throughout. Once those points are gathered, you’d compile them into a clear list of what truly matters in the original text. Then, you’d go back and compare the summary against that list to determine what’s included and what’s missing. Each of these steps carries its own complexity, and trying to handle them all at once would lead to mistakes or overlooked details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzCIQ_18E2lAFfzby9vkgA.png" /><figcaption>Know your toolbox and select the right tool for the job. <a href="https://pixabay.com/photos/tools-toolbox-construction-builder-3411589/">Source</a>.</figcaption></figure><h3>Criteria Scores Aggregation</h3><p>Choosing the right aggregation method is highly use-case specific yet there are three ‘rule of thumb’ guidelines I recommend following:</p><ul><li><em>Learn from the experts</em>: Ask domain experts to annotate a set of samples for each key evaluation criterion as well as to provide an overall annotation. From this set of samples, you can gain valuable insights to guide you when designing your aggregation method.</li><li><em>Know when you do not know</em>: Some examples may be hard to annotate automatically and best to be manually evaluated. As such, we want our aggregation method to be able to return an ‘NA’ score or confidence bounds for some of the examples, rather than a specific score.</li><li><em>Robustness</em>: The quality of scores from different criteria may vary, so it is important to construct the aggregation method in a way that small changes won’t significantly affect the outcome.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fZif-Xo5BOrN5rknsNsLQ.jpeg" /><figcaption>Build your evaluation dream team. Photo by <a href="https://unsplash.com/@pascalswier">Pascal Swier</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><h3>Conclusion</h3><p>Automatically evaluating your LLM-based application can provide enormous value, but does not come cheap. In this post, we have described how to build an effective multi-step evaluation pipeline and its advendages over crude methods.</p><p>There are numerous elements within the evaluation process that can be optimized. However, before investing valuable time in each of them, I recommend adopting a telescopic approach. Start with a basic implementation that includes what you believe are the essential components, test it, and then concentrate on optimizing the elements that could have a significant impact.</p><p><a href="https://www.linkedin.com/in/nadavbarak/"><em>Nadav Barak</em></a><em> is a Head of AI at </em><a href="https://www.linkedin.com/company/deepchecks"><em>Deepchecks</em></a><em>, a start-up company that arms organizations with tools to evaluate and monitor their Machine-Learning-based systems. Nadav has a rich background in Data Science and is a domain expert in building and improving Generative NLP applications.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1192d70240bd" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/scaling-llm-evaluation-1192d70240bd">Scaling LLM Evaluation</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Information Retrieval For Retrieval Augmented Generation]]></title>
            <link>https://pub.towardsai.net/information-retrieval-for-retrieval-augmented-generation-eaa713e45735?source=rss-ce2fa5aa341f------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaa713e45735</guid>
            <category><![CDATA[information-retrieval]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Nadav Barak]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 20:02:49 GMT</pubDate>
            <atom:updated>2023-07-15T20:02:49.345Z</atom:updated>
            <content:encoded><![CDATA[<h4>Three Battle-Tested Tips to Dramatically Boost Performance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGszgsXOPJGRlIdOalldQQ.jpeg" /><figcaption><a href="https://www.pexels.com/photo/person-holding-book-from-shelf-1370298/">Source and copyrights</a></figcaption></figure><p><a href="https://www.promptingguide.ai/techniques/rag">Retrieval Augmented Generation (RAG)</a> refers to <a href="https://en.wikipedia.org/wiki/Large_language_model">Large Language Model (LLM)</a>-based applications that use an <a href="https://en.wikipedia.org/wiki/Information_retrieval#:~:text=Information%20retrieval%20is%20the%20science,of%20texts%2C%20images%20or%20sounds.">Information Retrieval (IR)</a> component in their <a href="https://medium.com/@simon_attard/giving-large-language-models-context-2d1956a6a017">context</a> generation process. Having a high-performing IR component that provides the LLM with relevant information is key to building a robust RAG application. This post delves into three (and a half) simple tips that can dramatically improve the performance of your information retrieval system. So, without further ado, let’s dive in!</p><h3>Tip 0.5 - Evaluate your IR performance</h3><p>Information retrieval refers to the process of finding information from a vast pool of data that is relevant <strong>to answer</strong> a retrieval query. In RAG applications, the retrieved texts will be attached to the question provided by the user to create the <a href="https://medium.com/google-cloud/generative-ai-best-practices-for-llm-prompt-engineering-2a0131c805cc">prompt</a> that will be sent to the LLM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LNVVvuZPLgdOWakC0hQcig.png" /><figcaption>Retrieval Augmented Generation. Image by author. Icons from <a href="https://www.flaticon.com/">Flaticons</a>.</figcaption></figure><p>Before we can start talking about performance-improving tips, we first need a reliable way to measure our information retrieval performance.</p><p><strong>Building your evaluation set</strong></p><p>The evaluation set should contain a list of <strong>representable</strong> queries Q, a list of documents D, and a binary matrix stating which document is relevant to answer which query. Representable queries are indicative or typical of the different kinds of searches that users will commonly perform in the system.</p><p><em>Tip: Utilize an LLM in order to build the matrix by asking it whether a specific document contains relevant information to answer a specific </em>query<em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lw37mUB0H0jDcVRTJQVJ0g.png" /><figcaption>A binary document relevance matrix. Created by author</figcaption></figure><p><strong>Choosing the right evaluation metrics</strong></p><p>We want to check whether the IR system returns all the relevant documents (high recall) but also that it only returns documents that are indeed relevant (high precision). Depending on your use case, one can be more important than the other.</p><p>Another decision we have to make when building our IR system is what will be the number of returned documents, K. This is somewhat of an art. We want to have K as small as possible to reduce noise (and potentially costs) while making the result contain as much relevant information as possible. Hence the importance of measuring the expected quality for different K values.</p><p>Based on that two considerations, the metrics I would recommend for most use cases are <a href="https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)">Precision at rank k (P@k)</a> and <a href="https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)">Recall at rank k (R@k)</a>, which measure Precision and Recall for a variety of possible K values. It is important to spend time selecting the right evaluation metric for the use case. For additional details, I highly recommend the following <a href="https://archive.pinecone.io/learn/offline-evaluation/">blogpost</a> by Pinecone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DW8F386a8tfnlRQl7ZuUg.png" /><figcaption>Know your toolbox and select the right tool for the job. <a href="https://pixabay.com/photos/tools-toolbox-construction-builder-3411589/">Source</a>.</figcaption></figure><p>Now that we have the tools to establish a baseline and to check whether my tips are any good, let’s get down to business.</p><h3>Tip 1- Integrate TF/IDF for similarity distance</h3><p><strong>Are you telling me there is something more to similarity distance than cosine similarity on the embedding space? Well, yes.</strong></p><p>Before all the fancy embedding-based distance calculations, IR systems were based on <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf">TF/IDF</a>, the intuitive approach of calculating document similarity based on terms that occur frequently in a particular document but are rare in the overall document collection. As it turns out, integrating a variation of TF/IDF (In addition to the embedding-based search) in the similarity calculations can provide a significant <a href="https://arxiv.org/abs/2210.11934">performance boost</a>.</p><p>This can be done by representing each document as a combination of a dense embedding vector and a sparse bag of words vector. This method, otherwise known as hybrid search or hybrid retrieval, has out-of-the-box support in many of the popular vector store providers such as Pinecone, Weaviate, and many more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*gNkWZMKb87YBzBzCAGX10w.jpeg" /><figcaption>The combination is stronger than each of its parts. <a href="https://tfwiki.net/wiki/Gilthor">Gilthor</a>, a combination of Optimus Prime and Megatron.</figcaption></figure><h3>Tip 2 — Don’t embed your text as is</h3><p>Regardless of what embedding method or model we chose, its goal is to create a vector representation such that “similar” texts will be mapped to “similar” embedded vectors.</p><p>The problem arises when our stored information has a completely different format than our retrieval query. For example, in question answering, the stored information is likely to be long informational documents, while the retrieval query is likely to be a short question.</p><p>In order to mitigate the problem, <strong>we need to make sure that the stored information and the retrieval query are formatted to a common structure</strong> as the first step of the embedding process. This can be done either in the embedding procedure for the stored information, the retrieval query, or both. The formatting operations should be use-case and domain-specific.</p><p><em>Tip: In many use cases, the formatting operation can be performed by a LLM.</em></p><p>Examples:</p><ul><li>Question and answer — For each stored document, ask an LLM, ‘What question does this document provide an answer for?’ Use the embeddings of this response as the document’s representation.</li><li>Nontextual formats such as JSON can be converted to textual paragraphs describing the information stored within them.</li></ul><h3>Tip 3 — Embed paragraphs, not documents</h3><p>Focusing on smaller-sized textual objects is likely to improve the quality of the overall retrieved-context due to the following reasons:</p><ol><li><strong>More accurate embeddings:</strong> The embedded vector will have better context preservation as paragraphs typically focus on a single topic, while documents could span multiple topics.</li><li><strong>Less noise:</strong> The returned results will be more focused and contain less off-topic information.</li><li>Specifically for RAG — Ability to fit information from more documents in the context window.</li></ol><p>On the other hand, there are some notable drawbacks:</p><ol><li>Significant increase in the number of embedded vectors we need to store and calculate distance calculations on.</li><li>Some paragraphs may contain information that cannot be understood without the document context.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6rH7WMAHelGvecht_40Ww.jpeg" /><figcaption>Bonsai tree. Sometimes smaller is better. <a href="https://pixabay.com/photos/bonsai-tree-green-plant-small-316573/">Source</a>.</figcaption></figure><h3>Conclusion</h3><p>The efficiency of Retrieval Augmented Generation depends largely on the effectiveness of the Information Retrieval component in place. Thus, it is important to accurately evaluate the information retrieval component and work towards improving it.</p><p>Small modifications in the way we store our information and perform our similarity search can dramatically improve the quality of our information retrieval. The three tips discussed in this post are battle tested and have been proven to increase the performance of the applications they were integrated into.</p><p>Looking forward to hearing if integrating the tips delivered what was promised, as well as hearing additional tips that worked for you.</p><p><a href="https://www.linkedin.com/in/nadavbarak/"><em>Nadav Barak</em></a><em> is a hands-on researcher at </em><a href="https://www.linkedin.com/company/deepchecks"><em>Deepchecks</em></a><em>, a start-up company that arms organizations with tools to validate and monitor their Machine-Learning-based systems. Nadav has a rich background in Data Science and is a domain expert in building and improving Generative NLP applications.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaa713e45735" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/information-retrieval-for-retrieval-augmented-generation-eaa713e45735">Information Retrieval For Retrieval Augmented Generation</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>