Giter Club home page Giter Club logo

chatllm's Introduction

image image image

🔥ChatLLM 基于知识库🔥

image

Click to Star⭐️免费领取tokens https://api.chatllm.vip/

Install

pip install -U chatllm

Usages

计划推出国内 oneapi,支持各种主流大模型,兼容openai客户端生态。

from chatllm.applications import ChatBase

qa = ChatBase()
qa.load_llm(model_name_or_path="THUDM/chatglm-6b")
for i in qa(query='周杰伦是谁', knowledge_base='周杰伦是傻子'):
    print(i, end='')
# 根据已知信息无法回答该问题,因为周杰伦是**内地流行歌手、演员、音乐制作人、导演,
# 是具有一定的知名度和专业能力的人物,没有提供足够的信息无法判断他是傻子。

OpenaiEcosystem

Click to 无缝对接openai生态
# 服务端
pip install "chatllm[openai]" && chatllm-run openai <本地模型地址>
  • SDK:pip install openai
import openai

openai.api_base = 'http://0.0.0.0:8000/v1'
openai.api_key = 'chatllm'
prompt = "你好"
completion = openai.Completion.create(prompt=prompt, stream=True, model="text-davinci-003")
for c in completion:
    print(c.choices[0].text, end='')
# 你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。

openai_keys: 不定期更新免费keys

ChatOCR

Click to ChatOCR
from meutils.pipe import *
from chatllm.llmchain.applications import ChatOCR

llm = ChatOCR()
file_path = "data/invoice.jpg"
llm.display(file_path, 700)
llm.chat('识别编号,公司名称,开票日期,开票人,收款人,复核人,金额', file_path=file_path) | xprint

ocr

ChatMind

Click to ChatMind
pip install "chatllm" && chatllm-run webui --name chatmind

客户端

ChatPDF

Click to ChatPDF
pip install "chatllm[pdf]" && chatllm-run webui --name chatpdf
  • python交互
from chatllm.applications.chatpdf import ChatPDF

qa = ChatPDF(encode_model='nghuyong/ernie-3.0-nano-zh')
qa.load_llm(model_name_or_path="THUDM/chatglm-6b")
qa.create_index('财报.pdf')  # 构建知识库

for i in qa(query='东北证券主营业务'):
    print(i, end='')
# 根据已知信息,东北证券的主营业务为证券业务。公司作为证券公司,主要从事证券经纪、证券投资咨询、与证券交易、
# 证券投资活动有关的财务顾问、证券承销与保荐、证券自营、融资融券、证券投资基金代销和代销金融产品待业务。
  • 支持召回结果查看 向量召回结果

Deploy

Click to Deploy
  • ChatGLM-6B 模型硬件需求
量化等级 最低 GPU 显存(推理) 最低 GPU 显存(高效参数微调)
FP16(无量化) 13 GB 14 GB
INT8 8 GB 9 GB
INT4 6 GB 7 GB

TODO

Click to TODO
  • ChatLLM 应用

    • 接入非结构化文档(已支持 md、pdf、docx、txt 文件格式)
    • 搜索引擎与本地网页接入
    • 结构化数据接入(如 csv、Excel、SQL 等)
    • 知识图谱/图数据库接入
    • 增加 ANN 后端,ES/RedisSearch【确保生产高可用】
    • 增加多级缓存缓存
  • 多路召回

      • 标量匹配
      • 多种向量化,向量匹配
      • 增加相似问,换几个问法
      • 高置信度直接返回答案【匹配标准问】
      • 高置信度篇章
      • 增加上下文信息
      • 增加夸篇章信息
      • 增加召回信息的相似信息
      • 提前生成标准问,匹配问
      • 拒绝推断
  • 增加更多 LLM 模型支持

  • 增加更多 Embedding 模型支持

  • 增加一键启动 webui

    • 利用 streamlit 实现 ChatPDF,一键启动 chatllm-run webui --name chatpdf
    • 利用 gradio 实现 Web UI DEMO
    • 添加输出内容及错误提示
    • 引用标注
    • 增加知识库管理
      • 选择知识库开始问答
      • 上传文件/文件夹至知识库
      • 删除知识库中文件
  • 增加 API 支持

    • 利用 Fastapi/Flask/Grpc 实现流式接口 chatllm-run openai <本地模型地址> --host 127.0.0.1 --port 8000
    • 前后端分离,实现调用 API 的 Web UI Demo
群

若二维码失效加微信拉群 313303303

chatllm's People

Contributors

yuanjie-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatllm's Issues

生产级api

项目中是怎么提供生产级api,实现前后端分离的呢

Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0!

执行ChatPDF部分代码时,报错,

from chatllm.applications.chatpdf import ChatPDF

qa = ChatPDF(encode_model='nghuyong/ernie-3.0-nano-zh')
qa.load_llm4chat(model_name_or_path="THUDM/chatglm-6b")
qa.create_index('财报.pdf')  # 构建知识库

list(qa(query='东北证券主营业务'))

Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat2 in method wrapper_CUDA_mm)

如何正确使用各个功能?

我成功使用run.sh运行了chatbot.py,但是看起来它并不能执行实际的功能?我是否需要将它部署到streamlit?我尝试了部署,但是被告知没有您的permission,您能指导我将整个程序正确运行吗?

ImportError: cannot import name 'clear_cuda_cache' from 'meutils.decorators'

Traceback (most recent call last):
File "/root/autodl-tmp/chatglm/ChatLLM-master/zystest.py", line 2, in
from chatllm.applications import ChatBase
File "/root/autodl-tmp/chatglm/ChatLLM-master/chatllm/applications/init.py", line 11, in
from chatllm.applications.chatbase import ChatBase
File "/root/autodl-tmp/chatglm/ChatLLM-master/chatllm/applications/chatbase.py", line 12, in
from meutils.decorators import clear_cuda_cache
ImportError: cannot import name 'clear_cuda_cache' from 'meutils.decorators' (/root/miniconda3/envs/chatglm20230401/lib/python3.9/site-packages/meutils/decorators/init.py)

demo文件有点问题,没跑通

首先是方法名引用错了
image
模型文件,我使用的是本地的路径
文本文件,我用的是./data, 我不确定这么加载对不对
image
读取query的时候报错了
image

你好,有关于文档内容抽取的实现?

从你的介绍中可以看到你通过句法模版抽取引擎、开放域抽取系统等对文档进行处理,很想借鉴你的实现,可是没有在你的代码中没有找到相关的实现。
截屏2023-09-04 09 49 33

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.