概述
构造良好的 schema 可以确保抽取结果更符合预期,且便于下游使用,本文分享的最佳实践包括:- 如何定义清晰的字段
- 使用枚举与描述
- 避免不必要的嵌套
- 聚焦于原文档中的关键信息,引导抽取引擎准确理解抽取意图和解读文档
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
关于如何创建高质量 JSON schema 的建议
"properties": {
"币种": {
"type": ["enum", "null"],
"enum": [
"USD",
"EUR",
"JPY",
"CAD",
"AUD",
"Other"
],
"description": "国际货币种类代码"
}
}
# 通过 schema 抽取原文档中的月消费值
"properties": {
"monthly_cost": {
"type": ["number", "null"],
"description": "服务月度消费总计"
},
}
.
.
.
# 下游计算年消费值
total_annual_price =
extract_result.json()["result"][0]["monthly_cost"] * 12
此页面对您有帮助吗?
