phoenix

Arize Phoenix LLM 追踪与评估

补充说明

Phoenix 是 Arize 开源的 LLM 可观测性和评估工具,基于 OpenTelemetry 采集 trace,支持 RAG 检索质量、幻觉和回答相关性评估。适合本地开发和自建。

核心概念:project、trace、span、evaluator、dataset 和 experiment。

常用示例

安装并启动:

pip install arize-phoenix
python -m phoenix.server.main serve
# http://localhost:6006

自动追踪 OpenAI/LangChain:

import phoenix as px
px.launch_app()

from openinference.instrumentation.langchain import LangChainInstrumentor
LangChainInstrumentor().instrument()

手动创建 span:

from opentelemetry import trace
tracer = trace.get_tracer("rag")
with tracer.start_as_current_span("retrieval") as span:
    span.set_attribute("retriever.top_k", 4)

导出数据:

px.Client().export_dataframe()

易错点与排错