<?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 SallyAnn DeLucia on Medium]]></title>
        <description><![CDATA[Stories by SallyAnn DeLucia on Medium]]></description>
        <link>https://medium.com/@sallyanndelucia?source=rss-7eec43086b57------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OXjnFyxI5fojBXqagTCv2A.jpeg</url>
            <title>Stories by SallyAnn DeLucia on Medium</title>
            <link>https://medium.com/@sallyanndelucia?source=rss-7eec43086b57------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:14:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sallyanndelucia/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[LLM Deployment: Best Practices and Tips]]></title>
            <link>https://medium.com/arize-ai/best-practices-for-llm-deployment-81937af82a57?source=rss-7eec43086b57------2</link>
            <guid isPermaLink="false">https://medium.com/p/81937af82a57</guid>
            <category><![CDATA[context-retrieval]]></category>
            <category><![CDATA[llm-deployment]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[SallyAnn DeLucia]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 22:17:54 GMT</pubDate>
            <atom:updated>2024-01-16T19:36:18.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*aaaAzd27FOBdtKmrwnLfzQ.jpeg" /><figcaption>Image created by author using Stable Diffusion</figcaption></figure><h4>Tips for navigating the galaxy of large language models, including how to optimize and what to do after launch</h4><p>Large language models (LLMs) are revolutionizing the AI landscape. Despite being relatively new, many teams are <a href="https://arize.com/blog/survey-massive-retooling-around-large-language-models-underway/">jumping at the opportunity</a> to deploy these powerful models in their organizations. While excitement is high, knowing where to start can be a daunting task.</p><p>This blog covers the ins-and-outs of <a href="https://arize.com/blog-course/large-language-model-llm-deployment/">deploying LLMs</a>, including: tradeoffs between models, optimization — prompt engineering, fine tuning, and context retrieval — deployment strategies, and what to do after launch.</p><h3>Tradeoffs Between Custom and Commercial Models</h3><h4>Benefits of Building</h4><p>One of the first decisions to make when deciding to deploy a LLM is whether to build a LLM from scratch or use a commercial model. Both options have their advantages, and the answer might actually be both. Let’s get into it.</p><p>One benefit of building an LLM from scratch is that you have complete data ownership and privacy. Not only will your proprietary data be kept private but you can also make the most out of it. By leveraging your own data, you have the ability to control where the data powering your LLM comes from. This allows you to make sure the LLM is trained on reliable sources that won’t contribute to bias. You also don’t have to worry about your proprietary data being inadvertently used by a third party for training or <a href="https://www.bloomberg.com/news/articles/2023-05-02/samsung-bans-chatgpt-and-other-generative-ai-use-by-staff-after-leak">leaked</a>.</p><p>Using your own data could also lead to superior performance, potentially giving you a competitive advantage. You can also decide exactly what content filters to use based on your specific business use case. For example, you might need a longer sequence length than what a commercial model offers or the ability to add specific content filters to your training data. When you opt to use a commercial LLM, you have to work around the sequence limits and have no visibility of the data used for training.</p><p>Commercial models, like GPT-4, are <a href="https://community.openai.com/t/chat-gpt-4-painfully-slow/117996/41?page=3">known</a> to have a delay ranging from 5 to 30 seconds depending on the query. This latency issue is not ideal for applications that require real-time responses. When you build your LLM from scratch, you can opt for a smaller model with fewer layers and less parameters which tend to have faster inference speeds than their larger peers.</p><p>There’s growing evidence that smaller models can be just as powerful as larger models for domain specific tasks. <a href="https://www.mosaicml.com/blog/introducing-pubmed-gpt">BioMedLM</a>, a biomedical specific LLM using a mere 2.7 billion parameters, performed just as well if not better than a 120 billion parameter competitor. Another benefit: your model is smaller this will save you a bunch in training and serving costs.</p><p>Since you have complete model ownership when you opt to build from scratch, you also have better introspection and explainability. A commercial model is a black box; since you have little to no access to the inner workings of the model, understanding why the model is behaving the way it does is extremely difficult.</p><h4>Benefits of Commercial Models</h4><p>One of the biggest challenges when building an LLM from scratch is the cost. Building a LLM can be extremely expensive. GPT-4, for example, <a href="https://www.wired.com/story/openai-ceo-sam-altman-the-age-of-giant-ai-models-is-already-over/">reportedly cost</a> $100M to train. There’s also a lot of risk. With little room for error, you could end up wasting thousands or even millions of dollars — leaving you with only a suboptimal model. You also need a large volume of high quality and diverse data in order for the model to gain the required generalization capabilities to power your system.</p><p>Using a commercial model, on the other hand, means far less training costs. Since you do not have to worry about hosting or pre-training a commercial LLM, the only cost occurs at inference. Training costs would only be acquired from doing tests and experiments during development. Another benefit of commercial LLMs is they require less technical expertise. Finally, commercial models can also are a great tool for prototyping and exploring.</p><h4>So…Which?</h4><p>Overall, the choice of whether or not to build or buy an LLM comes down to your specific application, resources, traffic, and data ownership concerns. Teams with domain-specific applications might opt to build a model from scratch whereas teams looking to leverage the latest and greatest to build downstream applications might use a commercial model. Prior to heavily investing in either option, you may want to experiment with the technology to understand what’s possible and carefully consider your specific requirements.</p><h4>The Dark Horse of LLMs: Open Source Options</h4><p>While build-versus-commercial is the mainstream debate, let’s not forget about the open source options. There have been some impressive open source models that are available for commercial use. Dolly, MPT-7B, and RedPajama are just a few examples of open source models with commercial licenses that are rivaling popular commercial models like GPT-4 and LLaMA.</p><p>Open source LLMs allow you to leverage powerful models that have already learned a vast amount of data without having to be dependent on a service. Since you are not starting completely from scratch, there can be huge savings on training time and budget. This allows you to get your model in production sooner.</p><p>Just like building and using commercial LLMs, open source LLMs have downsides as well. While you save on costs at inference time by not having to pay a service provider, if you have a low usage then using a commercial model might actually lead to a cost savings. The cost benefits of open source models is seen when the requested volume is more than one million (see: Skanda Vivek’s great piece on <a href="https://towardsdatascience.com/llm-economics-chatgpt-vs-open-source-dfc29f69fec1">LLM economics</a>). The main cost associated with using open source is hosting and deploying these large models. When you have thousands of requests a day, paying a service provider often works out cheaper than paying at inference.</p><p>In addition to cost, open source models, while less demanding than building from scratch, still require substantial lift. Similar domain expertise is needed to train, fine-tune, and host an open source LLM. There is also evidence to support that reproducibility is still an issue for open source LLMs. Without the proper expertise you risk wasting time and resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*h4nA35bVtFZ2FwHKkMcapg.png" /><figcaption>Chart by author</figcaption></figure><h3>A Practical Guide to Optimization</h3><p>The steps to deployment will differ depending on your use case and model choice. Commercial models, for example, do not allow for fine tuning. Instead, you opt for prompt engineering and context retrieval to optimize your LLM. When using an open source or your own LLM, you’ll likely use a combination of these techniques to refine the model’s performance.</p><h4>Prompt Engineering — Shaping Performance with the Right Instructions</h4><p>Prompt engineering is a new field in AI where engineers focus on crafting prompts to feed the model, with prompts defined as the set of instructions the LLM will use to perform the task. Prompts play a huge role in optimizing and controlling the performance of LLMs. Prompt engineering allows developers to provide the LLM with context to perform a specific task. A good prompt will assist the model in providing high quality responses that are relevant and accurate. This allows you to harness the power of LLMs without needing extensive fine-tuning.</p><p>Since prompts are at the center of guiding model output towards the desired direction, prompt engineering is a crucial step in deploying an LLM. An effective prompt will allow your LLM to correctly and reliably respond to your query. You want your prompt to be clear and include specific instructions. Some best practices for prompts include:</p><ul><li>Write clear and specific instructions</li><li>Use delimiters to indicate specific pieces of the prompt</li><li>Outline the structure of the desired output</li><li>Use guidelines to check if certain conditions are met</li><li>Leverage few-shot prompting to give successful examples of completing the task</li></ul><p>Prompt engineering is an iterative process, it is unlikely that you will get the desired outcome from your first shot. You’ll want to create a process to iterate and improve on your prompt. The first step is to create a clear and specific prompt. Run a test with this prompt and observe the outcome, did it meet your expectations? If not, analyze why the prompt might not be generating the desired output. Use this information to refine the prompt. This might include adjusting the language, clarifying, or giving the model more time to think. Repeat this process until you feel confident in your prompt.</p><p>It’s worth mentioning that your prompt can also save you money. For example, adding “be concise” to your prompt can limit the response given. When you are using an API, like OpenAI’s API, you are charged based on the tokens given in the response so you’ll want to be sure you’re giving concise responses to ensure you are not racking up costs.</p><p>The main takeaway from this is <strong>we want to guide the model to pay attention to the latent space that is most relevant to the task at hand</strong>. To do this, you want to provide the correct context, instructions, and examples in your prompt. You can even stylize your LLM through prompting and save a huge percentage by simply adding “be concise.” There’s no doubt that prompt engineering is just as important as the foundation models that are being developed. The process is iterative and can be time-consuming but it is essential for having a well-performing and reliable model.</p><h4>Fine Tuning — Transforming Generalized Models into Specialized Tools</h4><p>You may be asking yourself how prompt engineering is different from fine tuning a LLM. The answer is simple: the task is the same — getting the model to perform a specific task — but it is done through a different mechanism. In prompt engineering, we are feeding instructions, context and examples to the model to perform a specific task; with fine tuning, we are updating the model’s parameters and training with a task specific dataset. You can think of prompt engineering as “in context learning” whereas fine tuning is “feature learning.” It is important to note that these two tasks are not mutually exclusive, meaning you might employ both methods.</p><p>Fine tuning is not a new task that appeared with the rise of LLMs. Fine tuning has been used as a part of transfer learning before transformers, attention mechanisms, and foundation models ever came to exist. The general concept of fine tuning is to take a model trained on a broad data distribution and specialize it by adjusting the parameters. In the context of LLMs, this is no different.</p><p>Once pre-training is complete by your internal engineers, it can be fine-tuned for a specific task by training on a smaller task specific set of data . A key component to successful fine tuning is being sure to use data that is representative of the target domain. Remember, the structure of your data is what determines what capabilities your model has so you’ll want to keep this in mind when choosing your dataset.</p><p>You can also opt to fine-tune the model’s parameters. Traditionally speaking, there are two different approaches you can take: freezing all the LLM’s layers and only fine tuning the output layer or fine tuning all layers. Generally speaking, fine tuning all layers yields better performance but it does have a higher cost associated with it due to the memory and compute requirements.</p><p>In recent years, researchers have found ways to avoid this tradeoff through methods like parameter efficient fine tuning (PEFT) and <a href="https://arize.com/blog/lora-low-rank-adaptation-of-large-language-models-paper-reading-and-discussion/">Low Rank Adaption (LoRA)</a> (<a href="https://arxiv.org/abs/2106.09685">paper</a>). These methods allow you to efficiently and cost effectively fine tune your models without having to compromise on the performance.</p><h4>Enhancing LLMs with Context Retrieval</h4><p>Another common task in developing an LLM system is to add <strong>context retrieval</strong> to your process. This popular technique allows you to arm your LLM with context not included in the training data without having to undertake total retraining. In this method, you would process your data to be split into chunks and then stored in a vector database. When a user asks a question, the vector database is queried for semantically similar chunks and the most relevant pieces of information are pulled as context for the LLM to generate a response.</p><p>Context retrieval can drastically improve the responses given by your LLM. You’ll want to experiment with similarity metrics and chunking methods to ensure the most relevant information is being passed in the prompt. It is also important to pinpoint user queries that are not answered by your knowledge base so that you know which topics to iterate and improve upon. While evaluating the model’s responses and context, it is possible to identify areas where the LLM lacks the knowledge it needs to answer. Using this information, you can add the context your LLM is missing to improve the model’s performance.</p><h4>Critical Non-Technical Considerations of LLMs</h4><p>Prior to deploying an LLM, it’s important to do a comprehensive evaluation to be aware of the model’s limitations and sources of bias. It is also recommended that you develop techniques, such as human feedback loops, to minimize any unsafe behavior. We have seen <a href="https://gizmodo.com/chatgpt-ai-openai-study-frees-chat-gpt-inner-racist-1850333646">real life examples</a> of how users were able to easily manipulate the input of the models and cause the model to respond in nefarious ways. It’s best to ensure you have the proper tools and procedures to mitigate the risk of inappropriate or unsafe behavior.</p><p>Once you have identified weaknesses and vulnerabilities, they should be documented along with use case specific best practices for safety. The public should also be made aware of any lessons learned around LLM safety and misuse of the applications. It is likely impossible to eliminate all unintended bias or harm, but by documenting it creates transparency and accountability — all key to developing responsible AI.</p><p>To that end, an important component that is too often overlooked when developing an LLM application is thoughtfully collaborating with stakeholders. By including people from diverse backgrounds in your team and soliciting broader perspectives, you can combat biases or failure of the model. Our models are expected to work on the diverse population that exist; the teams who build them should reflect this.</p><h3>Deployment Strategies for LLMs</h3><p>Deploying LLMs can bring a host of new problems. When it comes to the optimal deployment strategy, each use case will be different. You’ll want to consider the problem you are trying to solve to determine the best strategy.</p><h4>Latency</h4><p>Different applications have different latency requirements. You’ll want to assess the desired inference speed prior to deployment, making the appropriate hardware choices to meet requirements. GPUS and TPUs, for example, are key when optimizing inference speed. Both are more expensive than CPUs, which are generally slower.</p><h4>Cost</h4><p>If you’re building your own model or leveraging open source, you’re going to have to host your model. Because of their significant size, these models require a lot of computational power and memory and end up driving up infrastructure costs. Additionally, to reduce latency you might need to leverage GPUs or TPUs. Optimizing resources is paramount.</p><h4>Resource Management</h4><p>As mentioned previously, when you are hosting a model — whether it’s your own in house model or an open source model — it requires a lot of resources. Storing the model in a single storage device is impractical, thus requiring far more storage than conventional models.</p><p>Accommodating for memory requirements is also crucial. You can opt for multiple servers, model parallelism, or distributed inference to address these storage capacity issues. Additional requirements might include GPUs, RAM and high-speed storage to improve inference speed. It’s key to have the proper infrastructure to support your LLM, but these resources are costly and challenging to manage. Therefore, careful and thorough planning of your infrastructure is of the utmost importance. Here are some things to consider:</p><ul><li><strong>Deployment options</strong>: Cloud-based or on-premise deployment. Cloud deployments are flexible and easy to scale while on-prem deployments might be preferred for applications when data security is important.</li><li><strong>Hardware selection</strong>: Choose the hardware that aligns with your needs including processing power, memory, and storage capacity.</li><li><strong>Scaling options</strong>: Choose the right inference option.</li><li><strong>Resource optimization</strong>: Leverage model compression, quantization or pruning to reduce your memory requirements, enhance computational efficiency, and reduce latency</li><li><strong>Resource utilization</strong>: Be sure to only utilize relevant resources or else you might end up eating a lot of unnecessary cost</li></ul><h4>Security</h4><p>One of the main considerations enterprises should take when deploying is security and privacy requirements. You’ll want to be sure to have the proper techniques to preserve data privacy. In addition, you might consider encrypting data at rest and in transit to protect it from unauthorized access. It’s also critical to consider legal obligations like General Data Protection Regulation (GDPR) and implement the proper management, privacy, and security practices to ensure compliance.</p><h3>After the Launch</h3><p>Once you put the model into production, you will need to monitor and evaluate the model’s performance. You’ll want to do continuous evaluation of the model’s behavior and investigate any degradations. LLMs are sensitive to changes in input and can be negatively influenced leading to inappropriate responses. <a href="https://arize.com/blog-course/llmops-operationalizing-llms-at-scale/">LLMs are also known to hallucinate</a> so you’ll want to closely <a href="https://towardsdatascience.com/how-to-best-leverage-openais-evals-framework-c38bcef0ec47">monitor</a> responses (i.e. using <a href="http://openai eval">OpenAI Eval</a> or <a href="https://docs.arize.com/phoenix/llm-evals/llm-evals">open-source LLM Evals</a>). Often, you may have to return to prompt engineering and update your knowledge base to maintain your model’s performance. As always, it’s important to ensure you have the proper feedback loops and workflows in place to efficiently troubleshoot your model’s performance and quickly take action.</p><p>You’ll also want to monitor your resources. This will allow you to identify any underutilized resources and scale back when necessary. It will also help you to identify resource-intensive operations which require the architecture to be optimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*W6w6VR3W_i3W_TTeVci_lQ.png" /><figcaption>Diagram by author</figcaption></figure><h3>Summary</h3><p>Let’s recap. Once you’ve identified your specific use case, you’ll want to decide on whether you will build, buy, or use an open source model. After your chosen model is pre-trained, you will need to utilize an array of strategies to improve response quality and customize the model to your unique task. While performance optimization is key for a successful LLM application, it’s equally important to minimize unsafe behavior. This can be achieved through transparency, establishing feedback loops, and including diverse stakeholders in the development process. The deployment strategy should be tailored to the specific use case, with a clear focus on managing latency and optimizing resources to reduce costs. Post-deployment, the model’s performance and resource utilization should be continuously monitored and evaluated to maintain performance and optimize operations.</p><p>In essence, the success of any deployment requires technical expertise, careful planning, and constant oversight to ensure the model functions optimally.</p><p>Given that LLMs are in the early stages of development, the best practices for their deployment are likely to continue evolving. We can anticipate the development of superior tools designed to streamline the deployment of these models. Further advancements are likely to yield better techniques for optimizing model performance.</p><p>It’s an exciting time in the sense that we are in relatively unchartered territories with LLMs. As we learn and grow, we will see continuous evolution in methodologies, tools, and optimization strategies.</p><p><strong><em>Learn more about </em></strong><a href="https://arize.com/"><strong><em>AI observability</em></strong></a><strong><em>, or ask any question in our community!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81937af82a57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arize-ai/best-practices-for-llm-deployment-81937af82a57">LLM Deployment: Best Practices and Tips</a> was originally published in <a href="https://medium.com/arize-ai">Arize AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using LLMs To Evaluate LLMs]]></title>
            <link>https://medium.com/arize-ai/using-llms-to-evaluate-llms-c69da454048c?source=rss-7eec43086b57------2</link>
            <guid isPermaLink="false">https://medium.com/p/c69da454048c</guid>
            <category><![CDATA[model-evaluation]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llmops]]></category>
            <dc:creator><![CDATA[SallyAnn DeLucia]]></dc:creator>
            <pubDate>Thu, 25 May 2023 20:08:11 GMT</pubDate>
            <atom:updated>2024-01-16T19:36:35.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*zaIAa3Y395hBiAcZTNvbRw.jpeg" /><figcaption>Image created by author using Stable Diffusion</figcaption></figure><p>In the rapidly evolving world of artificial intelligence, large language models (LLMs) have proven their potential in various applications, including translation, summarization, sentiment analysis, and more.</p><p>With the increasing complexity and capabilities of these models, there is a growing need for effective evaluation techniques to assess their strengths and weaknesses.</p><p>This piece covers the emerging practice of <a href="https://arize.com/blog-course/assessing-large-language-models/">using LLMs to evaluate LLMs</a>.</p><h3>How to Evaluate LLMs Using Other LLMs</h3><p>The process of evaluating LLMs using LLMs primarily involves generating test cases and evaluating the model’s performance on these cases. Typically, this includes:</p><ol><li><strong>Automatic Test Generation</strong>: An LLM is used to create a diverse range of test cases, including different input types, contexts, and difficulty levels.</li><li><strong>Evaluation Metrics</strong>: The LLM being evaluated is tasked with solving the generated test cases. An LLM-based evaluation system then measures the model’s performance using predefined metrics, such as accuracy, fluency, and coherence.</li><li><strong>Comparison and Ranking</strong>: The results are compared to a baseline or other LLMs, offering insights into the relative strengths and weaknesses of the models.</li></ol><h3>What Are the Benefits of LLM-Based Evaluation?</h3><p>Utilizing Large Language Models for evaluation offers several noteworthy benefits. One such advantage is scalability, as LLMs can automatically generate a vast number of test cases, enabling comprehensive evaluation without significant human intervention. This efficiency allows researchers to assess a model’s performance across various tasks and domains quickly.<br>Additionally, the flexibility of LLM-based evaluations makes it possible to tailor the evaluation process to different domains, applications, and specific use cases, ensuring relevance and applicability. The consistency of using a single LLM for generating test cases and evaluating the results also reduces the chances of human bias affecting the assessment. Lastly, continuous improvement is fostered through regular LLM-based evaluations, as developers can identify performance trends and track improvements over time, ensuring the ongoing advancement of AI technology.</p><h3>How Does LLM-Based Evaluation Compare with Other Model Evaluation Techniques?</h3><p>While LLM-based evaluation offers numerous benefits, it is important to view these benefits in context of broader techniques.</p><h3>Human Evaluation</h3><p>Human evaluation involves experts or crowdsourced workers assessing the output or performance of an LLM in a given context. This method provides qualitative feedback and can identify subtle nuances that LLM-based evaluation might miss.</p><p><strong>Advantages:</strong></p><ul><li>Ability to capture context-specific nuances and understandability.</li><li>Direct feedback on model performance from the target user group.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>Time-consuming and expensive, especially for large-scale evaluations.</li><li>Inconsistencies due to subjective human opinions and biases.</li></ul><h3>Task-Specific Benchmarks</h3><p>Task-specific benchmarks, such as GLUE or SuperGLUE, evaluate LLMs using a predefined set of tasks, with well-established metrics for each task. These benchmarks provide standardized, quantitative comparisons between different models.</p><p><strong>Advantages:</strong></p><ul><li>Consistent, reproducible evaluation using standardized tasks and metrics.</li><li>Allows for direct comparison of different LLMs on the same tasks.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>Limited to the tasks and domains included in the benchmark, potentially missing other relevant use cases.</li><li>May not provide a comprehensive view of a model’s overall capabilities.</li></ul><h3>Intrinsic Metrics</h3><p>Intrinsic metrics — such as ROUGE, BERT, and <a href="https://arize.com/blog-course/generative-ai-metrics-bleu-score/">BLEU score</a> — focus on measuring the similarity of a response to a provided reference answer. These metrics rely primarily on word or sentence-level similarity which capture syntax not semantic similarities.</p><p><strong>Advantages:</strong></p><ul><li>Can provide insights into the model’s behavior and “truthfulness.”</li><li>Useful for identifying specific areas of improvement.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>Intrinsic metrics may not always correlate with real-world performance.</li><li>Focusing on a single metric may lead to over-optimization for that metric, neglecting other important aspects of performance.</li></ul><p>In comparison to these methods, <a href="https://arize.com/blog-course/llm-evaluation-the-definitive-guide/">LLM-based evaluation</a> offers scalability, flexibility, and consistency while reducing the impact of human bias. However, it is important to consider the limitations of LLM-based evaluation, such as ensuring diversity in test cases and addressing ethical concerns. In practice, combining different evaluation methods, including LLM-based evaluation, can provide a more comprehensive and holistic understanding of a model’s performance and capabilities.</p><h3>What Are the Challenges and Ethical Considerations in LLM-Based Evaluation?</h3><p>Despite the advantages of using LLMs for evaluation, it’s early days and there are challenges and considerations that must be addressed. Ensuring diversity in the evaluation process is critical, as it involves generating diverse and unbiased test cases that cover a wide range of possible scenarios. This diversity helps in identifying potential blind spots, biases, and limitations in the model being evaluated. Selecting appropriate evaluation metrics is another crucial aspect, as it directly impacts the accuracy and relevance of the assessment of an LLM’s performance. Researchers must carefully consider the metrics that best represent the desired outcomes and the model’s performance in specific tasks.</p><p>Ethical considerations also play a significant role when using LLMs for evaluation. The potential biases and limitations of LLMs should be acknowledged and addressed in the evaluation process to ensure fair and ethical use. As AI continues to permeate various aspects of society, it is essential to develop strategies to minimize the risks associated with biased or unfair AI systems. By incorporating ethical considerations into the LLM evaluation process, researchers can contribute to the development of more transparent, accountable, and responsible AI technology.</p><p>In addition to the above challenges, a comparison done by Microsoft Research <a href="https://arxiv.org/abs/2303.12712">showed</a> that the justification process used by LLMs when evaluating generated responses does not necessarily mirror that of a human. There are some assumptions that were made by the LLM, for example, downweighting shorter answers, that human evaluators did not use when evaluating responses. To overcome these shortcomings, we must ensure that models are calibrated like humans for evaluation by creating nuanced and information instructions to the model through thoughtful <a href="https://arize.com/blog-course/prompt-engineering/">prompt engineering</a>.</p><h3>How Do OpenAI Evals Help With Model Evaluation?</h3><p>OpenAI has launched an open-source software framework, known as <a href="https://github.com/openai/evals">Evals</a>, to evaluate the performance of its AI models in tandem with GPT-4. <a href="https://arize.com/blog-course/evals-openai-simplifying-llm-evaluation/">OpenAI Evals</a> provides developers with tools to generate prompts using datasets, measure the quality of completions by the LLMs, and compare performance across different datasets and models. <a href="https://towardsdatascience.com/how-to-best-leverage-openais-evals-framework-c38bcef0ec47">The framework</a> also includes templates that have proven useful in evaluating OpenAI’s own models, which users can leverage to evaluate their own systems built on OpenAI models. With Evals, developers can evaluate their LLM applications without writing any code at all. However, for those who wish to tailor the evaluation process to their specific needs, custom Evals can also be written and added.</p><p><a href="https://openai.com/research/gpt-4">Evals</a> is designed not only to enable individuals to assess their own applications, but also to provide a vehicle for sharing and crowdsourcing benchmarks for OpenAI’s LLMs; Evals will help identify deficiencies and provide feedback to direct future enhancements. OpenAI actively reviews Evals when considering improvements for models under development, allowing users to contribute to the improvement of OpenAI’s products while improving their own applications.</p><h3>Summary</h3><p>Evaluating LLMs with LLMs is a promising approach to assess the performance and capabilities of these powerful AI models. This self-reflective technique provides scalability, flexibility, and consistency, enabling developers to identify areas of improvement and ensure the continued advancement of AI technology. However, it is essential to consider the challenges and ethical implications associated with this method to ensure a comprehensive and fair evaluation process.</p><p><strong><em>Learn more about </em></strong><a href="https://arize.com/"><strong><em>AI observability</em></strong></a><strong><em>, or ask any question in our community!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c69da454048c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arize-ai/using-llms-to-evaluate-llms-c69da454048c">Using LLMs To Evaluate LLMs</a> was originally published in <a href="https://medium.com/arize-ai">Arize AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluating Model Fairness: a Primer]]></title>
            <link>https://medium.com/arize-ai/evaluating-model-fairness-a-primer-c85a7b0dd0d2?source=rss-7eec43086b57------2</link>
            <guid isPermaLink="false">https://medium.com/p/c85a7b0dd0d2</guid>
            <category><![CDATA[model-fairness]]></category>
            <category><![CDATA[ai-ethics]]></category>
            <category><![CDATA[ai-fairness]]></category>
            <category><![CDATA[algorithmic-bias]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <dc:creator><![CDATA[SallyAnn DeLucia]]></dc:creator>
            <pubDate>Thu, 25 May 2023 19:21:56 GMT</pubDate>
            <atom:updated>2024-01-16T19:38:16.217Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkS9PzWxHaroxDxYlxwakw.jpeg" /><figcaption>Image created by author using Dall-E 2</figcaption></figure><p>In many ways, bias and fairness in AI are two sides of the same coin; bias is a result, fairness is an action. Bias is inherently present in the world around us and is where prejudice is put into practice (consciously or unconsciously). Fairness is the absence of prejudice or preference for an individual or group based on their characteristics. For decades, bias in machine learning has been recognized as a potential concern, but it remains a complex and challenging issue for machine learning researchers and engineers when deploying models into production.</p><h3>Bias in ML</h3><p>Bias in machine learning refers to systematic errors that arise during the development and application of ML algorithms, often due to the presence of discriminatory or unfair patterns in data. In these cases, the model perpetuates or amplifies biases or discrimination due to the patterns in the underlying data. When talking about bias, there are two types you should pay attention to: bias in relating to sensitive groups and bias relating to non-sensitive groups.</p><p>Let’s dissect each.</p><h4>Sensitive Group Bias</h4><p>Sensitive groups in machine learning are groups of individuals who are identified by a specific characteristic that is protected by law or ethics, and may be subject to discrimination or unfair treatment. These characteristics include race, ethnicity, gender, age, religion, disability, sexual orientation, and other personal attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILFM3sFwYa6uWeA_yyFMfA.jpeg" /><figcaption>Image by author</figcaption></figure><p>Sensitive groups are often the focus of fairness and equity concerns in machine learning because they have historically been subjected to bias and discrimination. When building machine learning models, it is important to ensure that these groups are treated fairly and equitably, and that the models do not perpetuate or amplify biases or discrimination.</p><p>It is important to note that while sensitive groups are often the focus of fairness concerns, bias and discrimination can also occur against non-sensitive groups or individuals, and it is important to be aware of and address these concerns as well.</p><h4>Non-Sensitive Group Bias</h4><p>Non-sensitive groups are the features that are not protected attributes. Bias for non-sensitive groups occurs when a model consistently makes errors due to its inability to represent certain aspects of the data accurately. This can happen for various reasons, such as overfitting or underfitting, inappropriate assumptions and lack of diversity in the training data.</p><h3>Addressing Bias</h3><p>To address bias in machine learning models, it’s important to identify the sources of bias and take steps to mitigate them. This can involve collecting more diverse and representative training data, selecting appropriate model architectures and algorithms, and using techniques such as regularization to prevent overfitting. It’s also important to critically examine the assumptions and decisions made during the model-building process, and to involve diverse stakeholders in the development and evaluation of the model.</p><p>It’s important to note that data is not the only source of bias; even if we have perfect data, our modeling methods can introduce bias. For example, having a single model for all populations is bound to exhibit bias known as aggregation bias. Another example is evaluation bias, where benchmarks used for evaluation do not represent the general population.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YpA4R1dplli83BUWY8CDUw.png" /><figcaption>Image by author</figcaption></figure><p>Overall, addressing bias in machine learning is crucial for ensuring that the models we create are fair, accurate, and aligned with our values and goals. As machine learning becomes increasingly integrated into our daily lives, it’s important to remain vigilant and proactive in addressing bias and promoting ethical and responsible AI development.</p><h3>Fairness Metrics</h3><p>Here are several prevailing model fairness metrics.</p><h4>Recall Parity</h4><p><a href="https://arize.com/blog/evaluating-model-fairness/#recall-parity">Recall Parity</a> measures whether the model has equal recall rates across different subgroups. You can interpret this as how “sensitive” the model is for one group compared to another, or the model’s ability to predict true positives correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IoKu1HQgUq7_fgIql-Bn0w.png" /></figure><p>If the recall parity value is greater than 1, it indicates that one subgroup has a higher recall rate than the other subgroups. This may indicate that the model is biased towards that subgroup, or that the model performs better on that subgroup due to differences in the data distribution or feature importance.</p><p>This metric is particularly relevant when the cost of a false negative (i.e., failing to identify a positive instance) is high, such as in medical diagnoses or loan approvals. Use this metric when you want to ensure that the model is not biased in favor of or against certain subgroups.</p><h4>False Positive Rate Parity</h4><p>False positive rate parity measures whether a model incorrectly predicts the positive class for the sensitive group as compared to the base group. Ideal false positive rate parity is achieved if the false positive rates (the ratio between the number of false positives and the total number of negatives) in the subgroups are close to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44uLXyryiaqz9TjZ94UA0Q.png" /></figure><p>If the FPR Parity value is greater than 1, it would mean that the false positive rate is higher for the sensitive group compared to the base group. If the FPR Parity value is less than 1, it would mean that the false positive rate is lower for one subgroup compared to other subgroups.</p><p>This metric is particularly relevant when the cost of a false positive (i.e., incorrectly identifying a negative instance as positive) is high, such as in criminal justice or hiring decisions. Use this metric when you want to ensure that the model is not biased in favor of or against certain subgroups.</p><h4>Disparate Impact Formula</h4><p>Disparate impact compares the proportion of individuals that receive a positive output for two subgroups. You can interpret disparate impact as a quantitative measure of the adverse treatment of protected classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVKhkUtjkNaCIbe4JYh4fw.png" /></figure><p>A disparate impact of 1 indicates perfect parity between different subgroups, where each subgroup is represented in the same proportion as the overall population. A value greater than 1 indicates that one subgroup is overrepresented relative to another subgroup or the overall population, while a value less than 1 indicates that one subgroup is underrepresented.</p><p>This metric is particularly relevant when the goal is to ensure that the model does not perpetuate historical discrimination or disparities. Use this metric when you want to ensure that the model does not result in unequal outcomes across different subgroups.</p><h3>Choosing a Fairness Metric</h3><p>The choice of fairness metric to use between recall parity, false positive rate parity, and disparate impact depends on the specific context and goals of the machine learning model being developed. When deciding on which fairness metric or metrics to use, you must think about what insights you need to ensure your model is not acting discriminately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGjZ00HnxUeu_WEkTGAGSQ.png" /><figcaption>Image by Arize AI</figcaption></figure><p>The first question at hand is to determine if your business problem requires you to address disparate representation or errors. Disparate representation refers to an uneven distribution of different groups or subpopulations in the training data used to build the ML model. If certain groups are underrepresented or overrepresented, the model’s performance may be biased, leading to unfair outcomes for these groups. For example, say you have a model used for hiring and candidate selection. The model is trained on historical data to identify and shortlist the most suitable candidates for a specific job role based on various factors, such as experience, skills, and education. Disparate representation could arise if the historical data used to train the model contains an uneven distribution of candidates from different demographic groups, such as gender, race, or age.</p><p>Disparate errors occur when an ML model’s performance — such as accuracy, precision, recall — vary significantly across different groups or sub-populations. This can lead to biased outcomes with the model performing better for some groups and worse for others. For example, disparate errors could occur with a financial institution using a machine learning model for credit risk assessment. The model is trained to predict the likelihood of a borrower defaulting on their loan based on various factors, such as credit score, income, race, and employment history.</p><p>Once you determine if you want to focus on representation or error, you can continue on considering the questions in the context of your business problem to determine which metric to use. This is just one example of how to choose a metric, but overall, you want to consider the specific context and goals of the machine learning model being developed.</p><h3>Assessing Bias for Non-Sensitive Groups</h3><p>Bias can exist in machine learning models for features that are not legally or traditionally considered sensitive groups but nonetheless might be underrepresented or worth paying attention to.</p><p>In these cases, fairness metrics are not the only tool used to assess bias:</p><ol><li>Data analysis: Examine the distribution of the data for the feature in question. Are there any trends or patterns that suggest bias, such as certain groups being overrepresented or underrepresented? If so, you may need to take steps to correct for this in your model.</li><li>Model evaluation: Evaluate your model’s performance on different subgroups based on the feature in question. For example, if you are using the age of a car as a feature, you could evaluate the model’s performance on cars of different ages. If you see significant differences in performance between subgroups, this may indicate bias.</li><li>Human review: Finally, consider having human experts review your model and its output to identify any potential sources of bias. This can be especially useful for features that may not be immediately apparent as sensitive groups but could still introduce bias into your model.</li></ol><h3>Evaluation Thresholds</h3><h3>Sensitive Groups</h3><p>The industry standard for evaluating fairness metric values is the four-fifths rule. The four-fifths rule is a threshold that is used by regulatory agencies like the United States Equal Employment Opportunity Commission to help in identifying adverse treatment of protected classes. Since an ideal parity score is 1, when leveraging the four-fifths rule you typically measure whether your fairness metric score falls outside of the 0.8–1.25 threshold.</p><h3>Non-Sensitive Groups</h3><p>The threshold you should use for a fairness metric depends on a few factors, including the specific metric you are using and the context of your application. In general, there is no one-size-fits-all answer to this question, and you will need to determine the appropriate threshold based on your specific needs and goals.</p><p>Here are some general guidelines to consider:</p><ol><li>Determine the unacceptable level of disparity: Depending on the context of your application, you may have a specific threshold for acceptable levels of disparity between different subgroups. For example, you may decide that a disparity ratio of less than 0.8 (80%) is acceptable for a particular metric. This threshold should be based on careful consideration of the potential impact of bias on different subgroups and any legal or ethical requirements that apply to your application.</li><li>Consider trade-offs: Keep in mind that there may be trade-offs between fairness and other performance metrics, such as accuracy or precision. A lower threshold for fairness may result in reduced performance on other metrics. Consider the trade-offs carefully and choose a threshold that balances fairness with other important considerations.</li><li>Evaluate multiple thresholds: You may need to evaluate multiple thresholds to determine the appropriate level of fairness for your application. This can involve testing your model with different thresholds and comparing the results to determine which threshold provides the best balance of fairness and performance.</li></ol><p>Overall, the threshold you choose should be based on a careful evaluation of the potential impact of bias on different subgroups and a thorough understanding of the trade-offs involved in achieving fairness in your model.</p><h3>Take Action</h3><p>For a deep dive into fairness metrics, check out the <a href="https://arize.com/blog-course/algorithmic-bias-examples-tools/">relevant section of the Arize advanced course</a>. To see how Arize can help you<a href="https://arize.com/blog/machine-learning-bias-tracing/"> monitor fairness metrics</a> for your models in production, sign up for a free Arize account.</p><p><strong><em>Learn more about </em></strong><a href="https://arize.com/"><strong><em>AI observability</em></strong></a><strong><em>, or ask any question in our community!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c85a7b0dd0d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/arize-ai/evaluating-model-fairness-a-primer-c85a7b0dd0d2">Evaluating Model Fairness: a Primer</a> was originally published in <a href="https://medium.com/arize-ai">Arize AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>