当前位置: 首页 > news >正文

【RAG】优化query查询效果的几种处理


查询增强

query_rewrite_template = """You are an AI assistant tasked with reformulating user queries to improve retrieval in a RAG system. 
Given the original query, rewrite it to be more specific, detailed, and likely to retrieve relevant information.
Original query: {original_query}Rewritten query:"""

使query更加具体。

下面一种方法与这个增强相似,本质上也是丰富query

假设文档嵌入技术

传统的检索方法往往难以解决短查询与更长、更详细文档之间的语义差异问题。假设文档嵌入通过将查询扩展为完整的假设性文档来解决这一问题,这有可能通过使查询的表示与向量空间中的文档表示更加相似来提高检索的相关性。这种技术在那些理解查询意图和上下文至关重要的领域中可能具有极大的价值,例如法律研究、学术文献综述或高级信息检索系统。

HyDE是一种创新的方法,它将查询问题转化为包含答案的假设性文档,旨在缩小查询与文档在向量空间中的分布差距。


回溯式提问
相对于让query更加detailed,也可以使他更加笼统

```bash
step_back_template = """You are an AI assistant tasked with generating broader, more general queries to improve context retrieval in a RAG system.
Given the original query, generate a step-back query that is more general and can help retrieve relevant background information.

Original query: {original_query}

Step-back query:"""
```
## 拆解为子问题

```bash
subquery_decomposition_template = """You are an AI assistant tasked with breaking down complex queries into simpler sub-queries for a RAG system.
Given the original query, decompose it into 2-4 simpler sub-queries that, when answered together, would provide a comprehensive response to the original query.

Original query: {original_query}

example: What are the impacts of climate change on the environment?

Sub-queries:
1. What are the impacts of climate change on biodiversity?
2. How does climate change affect the oceans?
3. What are the effects of climate change on agriculture?
4. What are the impacts of climate change on human health?"""

```

提示词的处理只有两种方式,要么就是增强,添加更多细节和上下文,要么就是压缩,只抽取关键字。个人觉得查询效果需要看数据源来进行调整。因为有时数据多了,只用关键字可能查出来的内容也很笼统。而有时数据少了,增强后的query反而语义变复杂了检索不到。

## 自适应检索策略
不同类型的提问采用不同的策略

![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/16c7e786437747058ef44ff2b5f8e742.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/5ab709b3d6134ad1a2720e8dd49cfe4f.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/ca48f27858a3412cbbd5a63961116738.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/c475631f3a7b41a5be035be5e2cc1759.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/0ff51fd9ac6043fc84fd66f408016b12.png)

http://www.dtcms.com/a/456682.html

相关文章:

  • transformer详解(位置编码+attention+残差连接+全连接网络)
  • 已注册域名怎么做网站呢免费网站免费网站平台
  • 如何解决 pip install -r requirements.txt 约束文件 constraints.txt 仅允许固定版本(未锁定报错)问题
  • 【Camera】准备的一些Camera面试题——相机预览、拍照流程(经验尚欠,待补充)
  • CICD工具选型指南,GitLab cicd vs Arbess哪一款更好用?
  • 尉Lucene.Net 分词器选择指南:盘古分词 vs 结巴分词h
  • gitlab runner 安装
  • MySQL的OR条件查询不走索引及解决方案
  • 1688 店铺商品全量采集与智能分析:从接口调用到供应链数据挖掘
  • 淘宝商品详情采集方式,json数据返回
  • 【论文精度-1】 组合优化中的机器学习:方法论之旅(Yoshua Bengio, 2021)
  • 南京维露斯网站建设微信营销软件app
  • 从帧边界识别到数据编码:嵌入式通信协议与数据序列化方案深度对比
  • Quick SwiftObjective-C测试框架入门教程
  • GRM tools三大插件使用教程
  • C62-结构体的指针
  • 腾讯云 建网站企业网站seo公司
  • Java-143 深入浅出 MongoDB NoSQL:MongoDB、Redis、HBase、Neo4j应用场景与对比
  • 线程1——javaEE 附面题
  • 吴恩达机器学习课程(PyTorch适配)学习笔记:1.4 模型评估与问题解决
  • 后端_基于注解实现的请求限流
  • 从 0 到 1 搭建 Python 语言 Web UI自动化测试学习系列 10--基础知识 6--元素等待方式和内联框架
  • 织梦网站如何做seo重庆市城市建设档案馆官方网站
  • 一文详解Go语言字符串
  • 通用:MySQL-LBCC并发锁机制
  • Elasticsearch:使用推理端点及语义搜索演示
  • 基于websocket的多用户网页五子棋(九)
  • Async++ 源码分析13--parallel_reduce.h
  • 分布式api调用时间优化和问题排查
  • LeetCode每日一题,20251008