graphrag icon indicating copy to clipboard operation
graphrag copied to clipboard

[Feature Request]: 在运行前新增一个提问优化器

Open shaoqing404 opened this issue 6 months ago • 11 comments

Do you need to file an issue?

  • [X] I have searched the existing issues and this feature is not already filed.
  • [ ] My model is hosted on OpenAI or Azure. If not, please look at the "model providers" issue and don't file a new one here.
  • [X] I believe this is a legitimate feature request, not just a question. If this is a question, please use the Discussions area.

Is your feature request related to a problem? Please describe.

** 前言 :感谢Graphrag项目组的开源付出,这让我的工作得到了飞跃性质的效率提升! 包括开发过程文档和规章文档,借助于Graphrag的能力,不仅对于个人,更是对于团队,让我们实质上得到了普惠。

** 功能建议原因:在生产运行了一段时间后,我们发现graphrag对提问中的很多显式的关系没有能够被正确提取 如下例:

4499始发航班A330机型,航班搭载要客联合国秘书长,预计起飞时间14:00,航班机组情况{机长:张三,岗位:责任机长,等级:教员,乘务长:李四,等级:科长,空保组长:王五,等级:科长}

在该例子中,我 通过 prompt_tune 成功从文档里提取了 4499作为航班号 始发航班作为航班类型,A330机型作为飞机类型,要客作为乘客类型,联合国秘书长作为要客级别等实体。但在提问中local和global均忽视了 始发航班、联合国秘书长、空保组长 三个实体。 这在运行中很意外。

Describe the solution you'd like

通过进一步实验发现,当提问的实体种类超过5个时(或提问长度达到100字以上时),graphrag极易发生实体丢失的情况,普遍为2~4个实体。 因此,我基于构建实体的entity_extraction的思路,验证了一个新思路: 通过优化用户提问来实现更好更准取得查询效果,经过优化的内容大概是这样的:

-Examples- ######################

Example 1:

user question: 4499始发航班,属于A330机型,预计起飞时间14:00,目前机组到位时间:13:10,是否符合航班保障标准要求?

output: 请根据以下信息判断是否符合航班保障标准要求:航班为始发航班,航班号为4499,机型为A330,预计起飞时间为14:00,机组到位时间为13:10。请提供详细的评估和结论。 ######################

我在工作中已经实装了这些优化。这在长查询中至少提高了31%的命中率,并且极大的改善了回复的期望质量。

我将这个实践作为功能请求分享给你们,希望能够普惠到更多人。

Additional context

No response

shaoqing404 avatar Aug 19 '24 07:08 shaoqing404