You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何提升Azure OpenAI与Cognitive Search的查询准确率?

解决Cognitive Search对话生成无效查询的方案
  • 优化系统提示词
    明确引导模型将自然语言转换为Cognitive Search支持的结构化查询语法,而非直接截取问题片段。比如针对日期查询,提示模型生成带$filter条件的O格式查询:

    你需要将用户的自然语言问题转换为Azure Cognitive Search兼容的查询。当用户询问特定日期的文档时,生成包含$filter的查询,日期字段使用实际索引中的字段名(如document_date),格式遵循OData语法。例如用户问"Tell me everything about the document where the date is 20.09.2023",应输出:search=*&$filter=document_date eq datetime'2023-09-20T00:00:00Z'
    
  • 提取结构化日期字段
    当前索引仅存OCR提取的纯文本merged_content,无结构化日期字段,导致模型无法精准过滤。需修改Cognitive Search技能集,添加实体识别技能提取日期,并映射到单独索引字段:

    {
      "@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill",
      "categories": ["DateTime"],
      "defaultLanguageCode": "en",
      "inputs": [{"name": "text", "source": "/document/merged_content"}],
      "outputs": [{"name": "entities", "targetName": "document_dates"}]
    }
    

    随后在索引中创建document_date(Edm.DateTimeOffset类型)字段,完成字段映射。

  • 升级GPT模型版本
    GPT 3.5 Turbo 0301版本对复杂指令的遵循能力有限,建议升级到GPT-3.5 Turbo 16k或GPT-4版本,这类新版本在自然语言转结构化查询的准确性上表现更优。

  • 添加查询验证逻辑
    在模型生成查询后增加验证步骤,确保查询符合OData语法:检查是否包含有效$filter条件、日期是否转换为ISO 8601格式(如2023-09-20T00:00:00Z),避免无效查询提交到搜索服务。

  • 示例驱动提示词迭代
    针对会计文档常见查询场景(日期、金额、供应商等),给模型提供多组示例,强化正确转换逻辑:

    • 用户问题:"Show all invoices from August 2023"
    • 目标查询:search=*&$filter=document_date ge datetime'2023-08-01T00:00:00Z' and document_date le datetime'2023-08-31T23:59:59Z'

内容的提问来源于stack exchange,提问作者Leob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 10:32:43