GithubHelp home page GithubHelp logo

linecode / document.ai Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ganymedenil/document.ai

0.0 1.0 0.0 69 KB

基于向量数据库与GPT3.5的通用本地知识库方案(A universal local knowledge base solution based on vector database and GPT3.5)

License: GNU Affero General Public License v3.0

Python 72.43% HTML 27.57%

document.ai's Introduction

document.ai

基于向量数据库与GPT3.5的通用本地知识库方案(A universal local knowledge base solution based on vector database and GPT3.5)

目录

code 目录中有本次MSD示例的相关示例代码

流程

整个流程非常简单,也没有复杂的地方,相信关注GPT领域的都会看到过如上的流程。

主要就以下几个点:

  • 将本地答案数据集,转为向量存储到向量数据
  • 当用户输入查询的问题时,把问题转为向量然后从向量数据库中查询相近的答案topK 这个时候其实就是我们最普遍的问答查询方案,在没有GPT的时候就直接返回相关的答案整个流程就结束了
  • 现在有GPT了可以优化回答内容的整体结构,在单纯的搜索场景下其实这个优化没什么意义。但如果在客服等的聊天场景下,引用相关领域内容回复时,这样就会显得不那么的突兀。

难点

查询数据不准确

基于数据的优化

问答拆分查询

在上面的例子中,我们直接将问题和答案做匹配,有些时候因为问题的模糊性会导致匹配不相关的答案。

如果在已经有大量的问答映射数据的情况下,问题直接搜索问题集,然后基于已有映射返回当前问题匹配的问题集的答案,这样可以提升一定的问题准确性。

抽取主题词生成向量数据

因为答案中有大量非答案的内容,可以通过抽取答案主题然后组合生成向量数据,也可以在一定程度上提升相似度,主题算法有LDA、LSA等。

基于自训练的Embedding模型

openAI 的Embedding模型数据更多是基于普遍性数据训练,如果你要做问答的领域太过于专业有可能就会出现查询数据不准确的情况。

解决方案是自训练 Embedding 模型,在这里我推荐一个项目 text2vec ,shibing624 已经给出了一个模型基于 CoSENT + MacBERT +STS-Bshibing624/text2vec-base-chinese

我也在前些日子训练了基于 CoSENT + LERT + STS-B的两个模型一个隐层大小是1024的text2vec-large-chinese,另一个是768的text2vec-base-chinese。也欢迎比对。

为了做这个Demo我还训练了两个医疗问答相关的模型基于cMedQQ数据集,其他与上面的一致分别是text2vec-cmedqq-lert-largetext2vec-cmedqq-lert-base

基于 Fine-tune

目前我自身测试下来,使用问答数据集对GPT模型进行Fine-tune后,问答准确性会大幅提高。你可以理解为GPT通过大量的专业领域数据的学习后成为了该领域专家,然后配合调小接口中temperature参数,可以得到更准确的结果。

但 现在 Fine-tune 训练和使用成本还是太高,每天都会有新的数据,不可能高频的进行 Fine-tune。我的一个想法是每隔一个长周期对数据进行 Fine-tune ,然后配合外置的向量数据库的相似查询来补足 Fine-tune 模型本身的数据落后问题。

Buy me a coffee

document.ai's People

Contributors

ganymedenil avatar coderabbit214 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.