<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article MLOps Gym -  Evaluating Large Language Models with MLflow in Technical Blog</title>
    <link>https://community.databricks.com/t5/technical-blog/mlops-gym-evaluating-large-language-models-with-mlflow/ba-p/72815</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image (9).png" style="width: 510px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8307i32D6FA4291F9F184/image-dimensions/510x291?v=v2" width="510" height="291" role="button" title="image (9).png" alt="image (9).png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;EM&gt;This is the second part of a three-part guide on MLflow in the MLOps Gym series. In Part 1, “&lt;A href="https://community.databricks.com/t5/technical-blog/mlops-gym-beginners-guide-to-mlflow/ba-p/62593" target="_blank" rel="noopener"&gt;Beginners’ Guide to MLflow&lt;/A&gt;”, we covered Tracking and Model Registry components. In this article, we will focus on the &lt;STRONG&gt;Evaluate&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt; component, which is one of the MLflow tools designed to aid in Large Language Model Operations. The remaining components, AI Gateway and Prompt Engineering UI, will be covered in Part 3.&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-TOC indent="15" liststyle="disc" maxheadinglevel="2"&gt;&lt;/LI-TOC&gt;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;&lt;BR /&gt;What is LLMOps and why is it important?&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;LLMOps, or Large Language Model Operations, is an emerging area in the field of artificial intelligence that focuses on the deployment, monitoring, management, and scaling of large language models (LLMs) like DBRX, Llama3, GPT-4, BERT, and more. LLMs have shown remarkable capabilities in understanding and generating human-like text, which makes them incredibly valuable across various applications such as chatbots, content creation, and language translation. However, the complexity of these models, coupled with their substantial computational requirements, necessitates specialized operational strategies to utilize them effectively.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Databricks is built with LLMOps in mind by integrating open-source tooling, such as &lt;/SPAN&gt;&lt;A href="https://mlflow.org/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;MLflow&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;, to streamline the operational aspects of large language models. Databricks alleviates common problems arising from intensive resource consumption, the need for ongoing training, difficulties with evaluating outputs, and the management of ethical considerations such as bias and fairness. The platform's native support for popular ML frameworks used in LLM development, alongside MLflow's capabilities for experiment tracking, model versioning, and lifecycle management, equips teams to effectively train, deploy, and monitor LLMs at scale. Additionally, Unity Catalog allows for tight governance across all data assets, lineage tracking, feature tables, and much more.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;How is LLMOps different than MLOps&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;LLMOps represents a specialized subset within the broader domain of MLOps, which is concerned with the end-to-end lifecycle management of Machine Learning systems. LLMOps focuses specifically on the unique challenges posed by large language models. Here are the top challenges when operationalizing LLMs:&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Size of models and data&lt;/STRONG&gt;&lt;SPAN&gt;: LLMs are characterized by their vast number of parameters, enormous data requirements, and significant computational resources for training and inference. It is also difficult to properly track model outputs and evaluate overall performance. &lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Working with unstructured data&lt;/STRONG&gt;&lt;SPAN&gt;: In contrast to general MLOps, LLMOps deals with intricacies like managing the extensive preprocessing pipelines for text data.&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Different training techniques&lt;/STRONG&gt;&lt;SPAN&gt;: Modeling for LLMs differ from traditional machine learning in scale, architecture, generalization, context handling, and reliance on transfer learning. Ensuring data privacy in language models, handling the complexities of transfer learning and fine-tuning on domain-specific information, and dealing with the nuances of natural language understanding and generation are challenges that are specific to LLMOps. &lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;STRONG&gt;Responsible AI:&lt;/STRONG&gt;&lt;SPAN&gt; Additionally, LLMOps must consider the ethical implications and potential biases within language models, emphasizing the importance of responsible AI practices.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;H3&gt;&lt;SPAN&gt;Databricks, MLflow, and GenAI&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;MLflow has grown to include many tools for working with LLMs including native flavors for some of the most popular packages. These &lt;/SPAN&gt;&lt;A href="https://mlflow.org/docs/latest/llms/index.html#explore-the-native-llm-flavors" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;flavors&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; include Transformers (HuggingFace), OpenAI, Sentence Transformers, and Langchain!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Langchain Flavor:&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="height: 83px; border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="83px"&gt;&lt;LI-CODE lang="python"&gt;with mlflow.start_run():
    model_info = mlflow.langchain.log_model(chain, "langchain_model")&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Transformers Flavor (HuggingFace):&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;LI-CODE lang="python"&gt;with mlflow.start_run():

    model_info = mlflow.transformers.log_model(
        transformers_model=generation_pipeline,
        artifact_path="text_generator",
        input_example=input_example,
        signature=signature,
    )
&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;Complementing the advancements of MLflow, Databricks has released a breadth of documentation and blogs including the &lt;/SPAN&gt;&lt;A href="https://www.databricks.com/resources/ebook/the-big-book-of-mlops" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Big Book of MLOps&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; which includes information on generative AI, RAG, and more.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Now, let’s start going deeper into the concepts mentioned already, starting with LLM Evaluation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Evaluation&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Large Language Models have changed the technologic landscape immensely, but how do we decide which models to use? Which prompts are determined to be &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;good&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;? How do we make sure that we are using models correctly and efficiently? &lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Evaluating LLMs is a continuously evolving field, but MLflow makes it easy to aggregate metrics and even use additional LLMs to judge the outputs of your existing models. Using &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;mlflow.evaluate()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; we can use specific configurations for our evaluator to gather key information about our models’ performance.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Let’s take a deeper look.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Calculating and Collecting Metrics&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;MLflow has a number of default evaluators for specific model types including question-answering, text-summarization, text-generation, and retrievers. You can invoke these evaluators by calling &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;mlflow.evaluate()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; and setting the &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;model_type&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; parameter, as seen in the following code snippet.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="101px"&gt;&lt;LI-CODE lang="python"&gt;mlflow.evaluate(
    model=logged_model.model_uri, model_type="question-answering", data=questions
)
&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;Function-based metrics measure the effectiveness of LLMs in NLP tasks by taking into consideration toxicity, quality of text, readability, relevance, etc. These metrics assess the models' ability to predict correct outcomes, handle errors, and provide meaningful results in tasks like sentiment analysis, named entity recognition, part-of-speech tagging, machine translation, and language modeling.&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;By default, MLflow will collect function-based &lt;/SPAN&gt;&lt;A href="https://mlflow.org/docs/latest/llms/llm-evaluate/index.html#use-default-metrics-for-pre-defined-model-types" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;metrics&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; associated with the &lt;FONT face="courier new,courier"&gt;model_type&lt;/FONT&gt; and surface them within your experiment along with the rest of the run information:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Will_Smith_8-1718206724894.png" style="width: 656px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8310i73AD4B3D8410982F/image-dimensions/656x667?v=v2" width="656" height="667" role="button" title="Will_Smith_8-1718206724894.png" alt="Will_Smith_8-1718206724894.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Some of the common metrics include:&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Exact-match - This metric measures the percentage of predictions that exactly match the ground truth, often used in question-answering tasks.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Toxicity - This metric measures the level of toxicity in a text, often used in content moderation to ensure language models do not generate harmful content.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;A href="https://huggingface.co/spaces/evaluate-metric/rouge" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;ROUGE&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; - This metric stands for Recall-Oriented Understudy for Gisting Evaluation and is used to automatically determine the quality of summaries by comparing them to reference summaries.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;ARI Grade Level - This is a readability metric that estimates the U.S. grade level (1-12) needed to understand a text. It's used to evaluate the readability of generated text, ensuring it's appropriate for the intended audience.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;H3&gt;&lt;SPAN&gt;Function-Based Custom Metrics&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;Additionally, you can create custom function-based metrics that you can define to log specific metrics within your runs. For example, latency is defined as the time it takes to generate a prediction for a given input. This is important when determining if the model is fast enough for a given application or if we need to rethink our model selection, and we can include latency in our evaluation by passing &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;mlflow.metrics.latency()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; to &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;extra_metrics&lt;/FONT&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;LI-CODE lang="python"&gt;results = mlflow.evaluate(
    model,
    eval_data,
    targets="ground_truth",
    model_type="question-answering",
    extra_metrics=[mlflow.metrics.latency()],
)
&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;You can remove the &lt;/SPAN&gt;&lt;SPAN&gt;model_type&lt;/SPAN&gt;&lt;SPAN&gt; if you want to log &lt;/SPAN&gt;&lt;STRONG&gt;only&lt;/STRONG&gt;&lt;SPAN&gt; your custom metrics. The &lt;/SPAN&gt;&lt;A href="https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.evaluate" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;MLflow documentation&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; provides more information about the supported evaluation metrics.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;LLM-as-a-Judge&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;An alternative approach to evaluating LLMs is to utilize an LLM-as-a-judge. This method involves using the output from your model and generating scores based on the defined metric for the LLM judge. Evaluating LLMs using other LLM judges has become a prominent research topic. Our insights on this topic are presented in the blog post &lt;/SPAN&gt;&lt;A href="https://www.databricks.com/blog/LLM-auto-eval-best-practices-RAG" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Best Practices for LLM Evaluation of RAG Applications&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MLflow has the capability to capture metrics generated by other LLMs. Currently, you can measure:&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;answer_similarity - measures how &lt;/SPAN&gt;&lt;STRONG&gt;similar&lt;/STRONG&gt;&lt;SPAN&gt; output is to provided &lt;/SPAN&gt;&lt;STRONG&gt;ground_truth&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;answer_correctness - measures how &lt;/SPAN&gt;&lt;STRONG&gt;factually&lt;/STRONG&gt; &lt;STRONG&gt;correct&lt;/STRONG&gt;&lt;SPAN&gt; the output is based on &lt;/SPAN&gt;&lt;STRONG&gt;ground_truth&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;answer_relevance - measures how relevant the output is to the &lt;/SPAN&gt;&lt;STRONG&gt;input&lt;/STRONG&gt;&lt;SPAN&gt; prompt &lt;/SPAN&gt;&lt;STRONG&gt;only&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;relevance - measures how relevant the output is to both the &lt;/SPAN&gt;&lt;STRONG&gt;input&lt;/STRONG&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;STRONG&gt;context&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;faithfulness - measures how faithful the model is to the &lt;/SPAN&gt;&lt;STRONG&gt;context&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;You can configure these metrics by first using &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;mflow.metrics.genai&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; to import the appropriate metrics, associate an LLM (we are using Databricks Foundation Models API), and pass the information to&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt; mlflow.evaluate()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;LI-CODE lang="python"&gt;from mlflow.metrics.genai import relevance, EvaluationExample

relevance_metric = relevance(model="endpoints:/databricks-llama-2-70b-chat")

results = mlflow.evaluate(
    model,
    eval_df,
    targets="ground_truth",
    model_type="question-answering",
    evaluators="default",
    predictions="result",
    extra_metrics=[faithfulness_metric, relevance_metric, mlflow.metrics.latency()],
    evaluator_config={
        "col_mapping": {
            "inputs": "questions",
            "context": "source_documents",
        }
    },
)

results.tables["eval_results_table"]&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;Output table split into two images for readability:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Will_Smith_9-1718206944993.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8311iC93BA883536EF36D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Will_Smith_9-1718206944993.png" alt="Will_Smith_9-1718206944993.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Custom GenAI Metrics&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;You can also create custom LLM-as-a-judge metrics within MLflow using &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;A href="http://mlflow.metrics.genai.make_genai_metric" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;mlflow.metrics.genai.make_genai_metric()&lt;/SPAN&gt;&lt;/A&gt;&lt;/FONT&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt; You can do this by first creating an &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;EvaluationExample&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Note: You can access the full notebook examples &lt;/SPAN&gt;&lt;A href="https://mlflow.org/docs/latest/llms/llm-evaluate/notebooks/question-answering-evaluation.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;here&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="height: 336px; border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="336px"&gt;&lt;LI-CODE lang="python"&gt;example = EvaluationExample(
    input="What is MLflow?",
    output=("MLflow is an open-source platform for managing machine "),
    score=4,
    justification=(
        "The definition effectively explains what MLflow is "
        "its purpose, and its developer. It could be more concise for a 5-score.",
    ),
    grading_context={
        "targets": (
            "MLflow is an open-source platform for managing "
            "the end-to-end machine learning (ML) lifecycle. It was developed by Databricks"
        )
    },
)&lt;/LI-CODE&gt;
&lt;P&gt;You then use this example within &lt;FONT face="courier new,courier"&gt;make_genai_metric()&lt;/FONT&gt; which can be used like other metrics within &lt;FONT face="courier new,courier"&gt;mlflow.evaluate():&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" height="842px"&gt;&lt;LI-CODE lang="python"&gt;metric = make_genai_metric(
    name="answer_correctness",
    definition=(
        "Answer correctness is evaluated on the accuracy of the provided output based on "
        "the provided targets, which is the ground truth..."
    ),
    grading_prompt=(
        "Answer correctness: Below are the details for different scores:"
        "- Score 1: The output is completely incorrect. It is completely different from "
        "or contradicts the provided targets."
        "- Score 5: The output is correct. It demonstrates a high degree of accuracy and "
        "semantic similarity to the targets."
    ),
    examples=[example],
    version="v1",
    model="openai:/gpt-4",
    grading_context_columns=["targets"],
    parameters={"temperature": 0.0},
    aggregations=["mean", "variance", "p90"],
    greater_is_better=True,
)
&lt;/LI-CODE&gt;
&lt;H1&gt;&lt;STRONG&gt;&lt;BR /&gt;Summary&lt;/STRONG&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Throughout this article, we've delved into how LLMOps focuses on the unique challenges of deploying, monitoring, and managing LLMs such as DBRX and Llama3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Our exploration covered the native support within MLflow for LLM evaluation and associated metrics so that we can better assess our LLMs’ performance. We discussed the use of default and custom function-based metrics, as well as advanced techniques like the LLM-as-a-judge approach for comprehensive model assessment. Databricks includes all of the tools needed for developing, deploying, and managing your large language models.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;H1&gt;&lt;SPAN&gt;Coming up next!&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Next blog in this series: MLOps Gym - IDE vs Notebooks for ML Workloads&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2024 09:57:47 GMT</pubDate>
    <dc:creator>Will_Smith</dc:creator>
    <dc:date>2024-06-13T09:57:47Z</dc:date>
    <item>
      <title>MLOps Gym -  Evaluating Large Language Models with MLflow</title>
      <link>https://community.databricks.com/t5/technical-blog/mlops-gym-evaluating-large-language-models-with-mlflow/ba-p/72815</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image (9).png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8306iB557BF2D6CE4108B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image (9).png" alt="image (9).png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 09:57:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/mlops-gym-evaluating-large-language-models-with-mlflow/ba-p/72815</guid>
      <dc:creator>Will_Smith</dc:creator>
      <dc:date>2024-06-13T09:57:47Z</dc:date>
    </item>
  </channel>
</rss>

