Git Product home page Git Product logo

about's Introduction

About

让机器人来回答于我的问题

功能

目前只支持单轮 QA,采用文本相似度进行召回,支持自定义问题和答案。
文本相似度模型采用 SimCSE ,预训练模型来自 Hugging Face

部署

由于 Hugging Face 的下载需要用 git lfs,第一次配置起来稍微有些成本,所以我自己缓存了一份模型文件 simcse-chinese-roberta-wwm-ext.tar.gz

需要先将模型放在 resource/model 目录下,然后执行 docker-compose up -d 即可。

ONNX 格式的模型

simcse-chinese-roberta-wwm-ext-onnx.tar.gz

知识库格式

当命中某个标问时,会判定为命中为本条知识,并返回答案,当答案有多个时,会随机返回一个。
目录 resource/knowledge 下的任何 .json 后缀都会被尝试加载进知识库,格式如下。

{
  "知识_1": {
    "question_list": ["标问_1", "标问_2"],
    "answer_list": ["答案_1"]
  },
  "知识_2": {
    "question_list": ["标问_3", "标问_4"],
    "answer_list": ["答案_2", "答案_3"]
  }
}

复杂答案

当答案内容为 func:foo_bar 格式时,会从 about/func_set.py 中寻找并执行名为 foo_bar 的函数,目前不支持参数传入。

运行

python3 main.py

API

chat

curl -X POST \
     -H "Content-Type: application/json" \
     -d '{"text": "你好"}' \
     'http://localhost:3000/api/chat'

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.