Giter Site home page Giter Site logo

openai-qdrant's Introduction

向量化数据库与openAI的关联逻辑

开始说明:

开始前 需要先了解 qdrant 数据库,以及 openai embedding

相关文档:

openai embedding文档

qdrant API 文档 所有后端均可使用

qdrant API Quick-start

所用工具:

openai embedding

所用数据库:

qdrant

插入逻辑

  1. 使用 openAI 的嵌入方法 (https://api.openai.com/v1/embeddings) 将数据转化为向量

  2. 获取到嵌入方法返回的 embedding 的值,插入 points 到 某个 collection 中

  3. 外部准备部分数据 准备写入到 payload 中,可以如下面的例子

    [
        {
            "title": "问题1",
        	"text": "回答1"
        },
        {
            "title": "问题2",
        	"text": "回答2"
        }
    ]

    以上例子的 titletext 可以随意更改,但后面的数据必须规范 这里我把 title 作为 问题,text作为回答

    后面的point里的内容应该是以下的状态

    {
        "id": 1,
        "vector":[
            // 返回的embedding 
        ],
        payload: {
            "title": "问题1",
        	"text": "回答1"
        }
    }

查询逻辑

  1. 还是使用 openAI 的嵌入方法 (https://api.openai.com/v1/embeddings) 将数据转化为向量

  2. 获取到嵌入方法返回的 embedding 的值,查询同个collection里的内容(将 embedding 代入 vector 中),配置好 limit,建议为3,配置 params ,可以将 hnsw_ef 配置为128(准确值),exact 默认为 false(无近似搜索/精确搜索/无模糊搜索)

  3. 循环遍历搜索出来的内容,如果内容与提问相符则让gpt回答,前面可以使用 system,assistant,user 来对gpt的下一步回答进行一个微调

    1. 关键提示词:

      使用以下段落来回答问题,如果段落内容不相关就返回未查到相关信息:"1.问题1:回答1\n2.问题2:回答2"
      

参考仓库

document.ai

openai-qdrant's People

Contributors

aejays avatar

Stargazers

 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.