@响马 分享了他基于Embedding做的文档问答的经验,和传统的直接将问题做向量查询不一样,他让GPT先对问题做一个关键字分析,然后根据分析的关键词结果再做向量搜索,这样匹配度更高,聪明的做法👍🏻
文档地址就不发了,用的人太多,一晚上就烧了他十来刀😄,有心你总能找到
———
多轮问答跑了一天,目前效果很稳定,可以来解释一下是如何实现的了。
问答通常的实现,embedding -> search -> llm,连续语义在第一步就丢失了。
我的方案是在前面,先让 ChatGPT 解释问题,返回关键词,流程变为:explain -> embedding -> search -> llm。
具体 prompt 如下:
`You are a fibjs development assistant, please give detail keywords for the my question, based on the previous discussion.
There is no need to specifically include fibjs in the keywords.
my question: ${ask_message}
keywords: `
———
他的所有代码都是开源的:
轻量向量数据库:
github.com/fibjs/fibjs/blob/dev/fibjs/src/db/sql/Sqlite_vec.cpp
开发文档索引:
github.com/fibjs/fibjs/blob/dev/tools/gen_index.js
问答测试:
github.com/fibjs/fibjs/blob/dev/tools/ask.js
文本提取模块:
github.com/xicilion/fib-spliter
自动嵌入文档的代理:
github.com/xicilion/gptproxy
