Opik - 开源 LLM 评估平台

发布于:2025-03-12 ⋅ 阅读:(133) ⋅ 点赞:(0)


一、关于 Opik

Opik是一个开源平台,用于评估、测试和监控LLM应用程序。由Comet构建。

从RAG聊天机器人到代码助理,再到复杂的代理管道等等,构建LLM系统,通过跟踪、评估和仪表盘运行得更好、更快、更便宜。


功能

您可以使用Opik进行以下操作:

  • 开发:
    • 跟踪 Tracing: 在开发和生产过程中跟踪所有LLM调用和跟踪(快速启动集成
    • 注释 : 通过使用 Python SDK or the UI 记录反馈分数来注释LLM调用
    • Playground : 在 prompt playground 使用不同的提示词和模型
  • 评估 :让你的LLM 应用的评估流程自动化
  • 生产监控
    • 记录所有生产跟踪:Opik设计用于支持大量跟踪,便于监视生产应用程序。即使是小型部署,每天也可以接收超过4000万条跟踪!
    • 监控仪表板:查看 Opik Dashboard 中随时间变化的反馈分数、跟踪计数和标记。
    • 在线评估指标:使用LLM作为评判指标,轻松为所有生产跟踪打分,并通过 Opik’s online evaluation metrics 确定生产LLM应用程序的任何问题。

TIP:如果您正在寻找Opik今天没有的功能,请提出一个新的GitHub讨论主题 🚀


二、🛠️ 安装

Opik可以作为完全开源的本地安装或使用 Comet.com 作为托管解决方案提供。开始使用Opik的最简单方法是创建一个免费的Comet账户,在comet.com

如果您想自己托管Opik,可以通过克隆存储库并使用 Docker Compose 启动平台来实现:

# Clone the Opik repository
git clone https://github.com/comet-ml/opik.git

# Navigate to the opik/deployment/docker-compose directory
cd opik/deployment/docker-compose

# Start the Opik platform
docker compose up --detach

# You can now visit http://localhost:5173 on your browser!

关于不同的部署选项的更多信息,请参阅我们的部署指南:

安装方法 文档链接
本地实例 Local Deployments
Kubernetes Kubernetes

三、🏁 开始使用

要开始使用,您首先需要安装 Python SDK:

pip install opik

一旦 SDK 安装完毕,您可以通过运行 opik configure 命令来配置它:

opik configure

这将允许您通过设置正确的本地服务器地址来本地配置 Opik,或者如果您正在使用云平台,可以通过设置 API 密钥来配置。

TIP:您也可以从您的 Python 代码中调用 opik.configure(use_local=True) 方法来配置 SDK 在本地安装上运行。

现在,您可以使用 Python SDK 开始记录跟踪。


1、📝 记录跟踪

开始的最简单方法是使用我们的其中一个集成。Opik 支持:

Integration Description Documentation Try in Colab
OpenAI Log traces for all OpenAI LLM calls Documentation Open Quickstart In Colab
LiteLLM Call any LLM model using the OpenAI format Documentation Open Quickstart In Colab
LangChain Log traces for all LangChain LLM calls Documentation Open Quickstart In Colab
Haystack Log traces for all Haystack calls Documentation Open Quickstart In Colab
Anthropic Log traces for all Anthropic LLM calls Documentation Open Quickstart In Colab
Bedrock Log traces for all Bedrock LLM calls Documentation Open Quickstart In Colab
CrewAI Log traces for all CrewAI calls Documentation Open Quickstart In Colab
DeepSeek Log traces for all DeepSeek LLM calls Documentation
DSPy Log traces for all DSPy runs Documentation Open Quickstart In Colab
Gemini Log traces for all Gemini LLM calls Documentation Open Quickstart In Colab
Groq Log traces for all Groq LLM calls Documentation Open Quickstart In Colab
Guardrails Log traces for all Guardrails validations Documentation Open Quickstart In Colab
Instructor Log traces for all LLM calls made with Instructor Documentation Open Quickstart In Colab
LangGraph Log traces for all LangGraph executions Documentation Open Quickstart In Colab
LlamaIndex Log traces for all LlamaIndex LLM calls Documentation Open Quickstart In Colab
Ollama Log traces for all Ollama LLM calls Documentation Open Quickstart In Colab
Predibase Fine-tune and serve open-source Large Language Models Documentation Open Quickstart In Colab
Ragas Evaluation framework for your Retrieval Augmented Generation (RAG) pipelines Documentation Open Quickstart In Colab
watsonx Log traces for all watsonx LLM calls Documentation Open Quickstart In Colab

TIP : 如果您正在使用的框架未列在上述内容中,请随时 提交问题 或提交包含集成的 PR。


如果您没有使用上述任何框架,您也可以使用 track 函数装饰器来 记录跟踪:

import opik

opik.configure(use_local=True) # Run locally

@opik.track
def my_llm_function(user_question: str) -> str:
    # Your LLM code here

    return "Hello"

TIP:轨迹装饰器可以与我们的任何集成一起使用,也可以用于跟踪嵌套函数调用。


2、🧑‍⚖️ 作为法官的LLM指标

Python Opik SDK 包含了多个作为法官的LLM指标,以帮助您评估您的LLM应用程序。在指标文档中了解更多信息。

要使用它们,只需导入相关的指标并使用 score 函数:

from opik.evaluation.metrics import Hallucination

metric = Hallucination()
score = metric.score(
    input="What is the capital of France?",
    output="Paris",
    context=["France is a country in Europe."]
)
print(score)

Opik 还包括许多预构建的启发式指标,以及创建您自己的指标的能力。在 指标文档 中了解更多信息。


3、🔍 评估您的 LLM 应用程序

Opik 允许您在开发过程中通过 数据集实验 评估您的 LLM 应用程序。

您还可以使用我们的 PyTest 集成 将评估作为 CI/CD 管道的一部分运行。


2025-03-11(二)


网站公告

今日签到

点亮在社区的每一天
去签到