Skip to content

语义整理(Catalog)

按相似度而不只是按规则来决定该评审哪些智能体轨迹。条目上的嵌入索引支持相似度检索(“找出和这次失败类似的轨迹”)以及动态切片:保存下来的语义与元数据过滤器,会自动纳入新匹配的轨迹并把它们整理进数据集。

语义整理帮你按相似度找出该评审什么,而不只是靠规则或不确定性。 条目上的嵌入索引支持相似度检索(“找出和这次失败类似的轨迹”),也支持动态切片:保存下来的语义与元数据过滤器,会自动纳入新匹配的轨迹,并把它们整理进数据集。它是基于规则的分诊和基于模型不确定性的主动学习的补充。

启用

yaml
curation:
  enabled: true
  model_name: all-MiniLM-L6-v2   # any sentence-transformers model
  embed_on_ingest: false          # index runtime-ingested traces on arrival
  text_key: task_description      # which field to embed

嵌入是惰性的:sentence-transformers 只在你构建索引时才导入,启动时不会加载,因此启动依然很快。用 pip install sentence-transformers 安装它,或者接入自定义的嵌入器。启用后,管理面板会出现 Catalog 链接。

构建、检索、切片

bash
# Build the index over current items
curl -X POST localhost:8000/admin/catalog/api/build -H "X-API-Key: <key>"
 
# Search by text query (or by an anchor instance to find neighbours)
curl -X POST localhost:8000/admin/catalog/api/search -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" -d '{"query": "tool call failed", "top_k": 10, "threshold": 0.3}'

一个切片是保存下来的过滤器,按需针对当前索引求值,因此保存之后摄入的轨迹只要匹配就会自动被纳入。它把一个可选的语义邻域和一个元数据过滤器组合在一起:

bash
curl -X POST localhost:8000/admin/catalog/api/slices -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{"name": "tool-errors", "query": "tool call failed", "threshold": 0.3,
       "metadata_filter": [{"field": "metadata.outcome", "equals": "error"}]}'
 
# Curate the resolved instances straight into a dataset
curl -X POST localhost:8000/admin/catalog/api/slices/tool-errors/to_dataset \
  -H "X-API-Key: <key>" -H "Content-Type: application/json" \
  -d '{"dataset": "tool-errors-to-fix"}'

相关内容