最新资讯
wechat 这波杀疯了!旗舰级模型不限量、1个月视频额度免费领 dev.to 如何在专用 GPU 服务器上用 OpenAI 兼容 API 部署 LLM dev.to 审计 153 份 Claude Code 与 Codex 会话记录:User-Agent 与 URL 中的邮箱泄露 dev.to 你的 Agent Harness 应具备的 17 项能力 dev.to 离线 AI 记忆中 0.8 余弦阈值为何失效 dev.to Kimi K3.1 Pro 开放权重:自托管 2.8T 模型前的开发者清单 dev.to 如何通过工具调用引导模型以提升 Harness 质量 dev.to AI Agent 审计轨迹不等于对话记录 dev.to 精简 MCP server 工具数量:更少工具、更小影响面,双重收益 dev.to 为什么 git checkout 无法撤销 AI 编码 agent 的改动? wechat AI短剧门槛降降降!实测即梦短剧工作室:剧本分镜预演一条龙,伙伴计划长期护航 dev.to 让模型改写文档前,先量化事实保真度
多元动态
登录 注册
大模型 pub.towardsai.net · @Jessica Parks

用 MLflow 3.0 实现 LLM-as-a-judge

原文 我的收藏

文章介绍如何使用 MLflow 3.0 创建 LLM-as-a-judge 评估。作者在完成 Databricks 生成式 AI 认证考试后,重点关注 LLMOps 部分,希望解决如何监控 AI 系统、如何量化主观输出结果、以及如何用更具领域针对性的评估替代开箱即用评估等问题。文中提到认证课程仅演示了 MLflow 2.0 的用法,而 MLflow 近期已发布重大版本更新。

AI推荐理由 介绍如何用 MLflow 3.0 构建 LLM-as-a-judge 评估流程,涉及 AI 系统监控、主观输出量化与领域特定评估,属 LLMOps 实践内容。作者结合 Databricks 生成式 AI 认证学习经历,但为个人教程,未提供基准或对比结果。

60

正文

Mlflow Mlflow 101 Llm As A Judge Databricks LLM-as-a-judge with MLflow 3.0 We will look at how MLflow 3.0 can be used to create an LLM-as-a-judge. Jessica Parks 6 min read · Just now -- Listen Share I recently finished taking my Databricks Generative AI Certification Exam. In short, it was filled with great content and I learned a good amount. It ranged from reminders of the Gen AI basics, to what tools to use in Databricks for AI, to how a robust AI system should be created. Press enter or click to view image in full size Source: Image by sergeitokmakov on Pixabay In the meantime, one of the most valuable takeaways for me was the section on LLMOps. While many people today can make a notebook that uses an LLM or vibe code their way to it, I was looking to learn how to take my AI projects to the next level. The questions I wanted answered were: How do I monitor my AI system? How do I quantify results of subjective outputs? How do I evaluate my outputs with more domain specific evaluations, not just out of the box ones? While the Databricks certification only showed how to use MLflow 2.0 to answer these questions, MLflow did go through a recent major version update to MLflow 3.0. This newer version allows more flexibility in functions to use with AI related projects, models, evaluations, along with functions specific to handling LLMOps. So while the certification provided examples for how to use MLflow version 2.0, for my project and the examples I will be providing here, I am using version 3.0. As you can imagine, I used the newest version since it is best practice and because of the increase in ease of use for LLMOps. For this series, I will look specifically at how MLflow 3.0 can be used to create an LLM-as-a-judge. This will cover the range of need for judges from out-of-the-box judges that assess things like toxicity, safety, etc. to creating domain specific custom judges. What is an LLM-as-a-Judge? As we all know, LLMs aren’t perfect. I recently had one misspell “commented” as “commmented”. While a human may make that typo when typing, I cannot think of a human that would actually think an English word has three “m”s together. The two “m”s alone get the job done. As a result, it’s important we evaluate our LLM outputs; they should not be taken at face value. It is easy to validate an output if you are only evaluating a few at a time, but what if you have thousands of outputs coming in each day? It is not possible for a human to go through and check each and everyone of of these. An LLM-as-a-judge is a where an LLM is used to evaluate the output of another LLM. These evaluation can look at if the output is safe, if it is grammatically correct, or even check domain specific materials, such as if it included accurate domain information. What Tools in MLFlow 3.0 can Create an LLM-as-a-Judge? As mentioned earlier, MLflow 3.0 has created more flexibility for integrating it with AI, including creating different types of judges. Below, we will highlight three different judges and what they should be used for. Here is a brief explanation of what each label means: Flexibility: how much it allows you to define what is being assessed and how to grade it. Amount of Time: time required to build out the judge Requirements: what the judge requires to be executed When to use: best scenarios for when the judge should be used Please note, there are best practices around LLM-as-a-judge that aren’t not covered in this post. make_judge Flexibility: High Amount of Time: High Requirements: Sample labeled dataset, prompt, judge name Returns: User provided scoring metric When to Use: When extensive prompt, few-shot examples, many rules, etc. are needed to produce accurate results Notes: To improve performance of this judge, it is helpful to include examples of inputs and outputs that would receive certain scores and rationales; this is shown in the example below. Get Jessica Parks’s stories in your inbox Join Medium for free to get updates from this writer. Subscribe Subscribe Remember me for faster sign in Please see the hyperlink for additional parameters. Here is the definition of main ones used: name description: this should be short, a definition instructions: include few shot text here; MLFlow specifically looks for {{input}} and {{output}} in this section. See the example below on an easy way to incorporate this into the instructions. If you do not include these two, your code will fail. model: LLM model to judge outputs, provide score and rationale feedback_value_type: int, float, string, literal, list, dict, etc.; see hyperlink for formatting notes rationale is automatically provided and will be shown in UI, do not need to indicate rationale in this parameter import mlflow from mlflow.genai.judges import make_judge from typing import Literal # Create a judge that evaluates response quality using template variables quality_judge = make_judge( name="response_quality", description="Evaluate how well the response answers the question", instructions=(""" ###Instructions### Evaluate if the response in {{ outputs }} correctly answers the question in {{ inputs }}. The response should be accurate, complete, and professional. ###Rubric### 0: Does not answer question at all 0.5: Partially answers question 1: Completely answers question ###Examples### Input: What is the capitol of France? Output: Paris Score: 1 Rationale: The input only required one word answer and is correct Input: How many schools are in the Big Ten and which ones are in Michigan? Output: There are 18 schools in the Big Ten. Score: 0.5 Rationale: The response correctly answered the number of schools in the Big Ten but did not answer the other question asking how many are in Michigan. """), model="openai:/gpt-4", feedback_value_type=int ) Guidelines Flexibility: Medium Amount of Time: Medium Returns: Pass/Fail When to Use: When a prompt with a few examples or rules are needed; stick a few paragraphs max import mlflow from mlflow.genai.scorers import Guidelines english = Guidelines( name="english", guidelines=["The response must be in English"] ) Built in LLM-As-Judge (scorers) Available out-of-the-box judges listed in hyperlinked title above. Flexibility: Least Time: Low Returns: Pass/Fail Requirements: None When to Use: When standard judge topics cover data evaluation needs Notes: You do not need to make a special evaluator for these as seen in the previous two judges above. Just import the judge(s) you need and call them in your run. from mlflow.genai.scorers import Safety, Correctness results = mlflow.genai.evaluate( data=sample_data, scorers=[ Safety(), Correctness(), ], ) Implementation Lastly, in order to actually implement these judges, you will need to have a table with inputs and outputs as their own columns. MLFlow will then iterate through each row and evaluate the data using the judge(s). In order to set up your evaluation data correctly, it must follow the convention below: Column names must be inputs and outputs. Structure of the table: One list, each row is it’s own dictionary (see in code below). This is to help accommodate for the different formats that could come with AI values instead of traditional ML. # create evaluationd data # from dummy data frame df # with columns data, response sample_data = pd.DataFrame( { "inputs": [{"data":x}] for x in df.data, "outputs": [{"response":y} for y in df.response] } ) # generate results for all judges results = mlflow.genai.evaluate( data=sample_data, scorers=[ Safety(), Correctness(), english, quality_judge ], ) Wrap Up LLMs-as-a-judge are not only great tools to evaluate qualitative responses, but can also be reviewing large amounts of data for specific errors that would require many manual hours to carefully review and try to catch. With the various ways to set up these judges with MLFlow, you can speed up this part of your pipeline. By having pre-defined structures, you can quickly fill in the judge with your data, all while having the flexibility to evaluate the entire response down to aspects as small as punctuation and specific word use. This is part of my Databricks Generative AI Certification Exam Series. Here are some other articles from it: Databricks Generative AI Certification: Study Databricks Generative AI Certification: Exam

来源报道 · 1 篇 · 以下链接均前往原始媒体

Jessica Parks 用 MLflow 3.0 实现 LLM-as-a-judge 09-16 · 原文发布
← 返回精选动态 原文

更多内容