• Stars
    star
    422
  • Rank 102,132 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created over 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

轻松玩转LLM兼容openai&langchain,支持文心一言、讯飞星火、腾讯混元、智谱ChatGLM等

image image image

🔥ChatLLM 基于知识库🔥

ChatLLM API 分发系统上线

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

Install

pip install -U chatllm

Docs

Usages

目前适配的LLMs

计划推出国内 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

More Repositories

1

ChineseSensitiveVocabulary

暴恐违禁 文本色情 政治敏感 恶意推广 低俗辱骂
Python
74
star
2

tql-Python

思维误区: 用理想模型来思考复杂现实问题
Jupyter Notebook
39
star
3

FeatureSelector

Feature selector is a tool for dimensionality reduction of machine learning datasets.
Jupyter Notebook
19
star
4

iNLP

https://pypi.org/project/iNLP/
Python
11
star
5

DaGuan-NLP-Classifier

达观杯“文本智能处理挑战赛”
Python
10
star
6

NlpCorpusWithLabel

中文语料:大量人工标注样本,非常有价值 !!!
9
star
7

gcForest

gcForest个人整理,欢迎star or fork
Python
8
star
8

PpdaiQuestionPairsMatching

第三届魔镜杯大赛 相似问匹配
Python
8
star
9

iFeature

特征工程工具包
Python
8
star
10

DNN

Learning ...
Jupyter Notebook
7
star
11

AIZoo

ai 工具类
Jupyter Notebook
7
star
12

BigDataTools

Jupyter Notebook
6
star
13

AppZoo

AppZoo: The Faster App Service
Python
5
star
14

inn

integrated neural network library
Python
5
star
15

HiddenPoem

藏头诗 开箱即用 一键部署 春节拉新活动藏头诗
Python
4
star
16

ReposLinking

Python
3
star
17

iTransferLearning

Python
3
star
18

PythonLearning

🏇
3
star
19

ML-DL-Interview

机器学习 深度学习 面试
3
star
20

stopwords-zh

中文停用词汇总,持续完善中,欢迎push共建
Python
2
star
21

CTRZOO

CTR ZOO
Python
2
star
22

x2embedding

万物皆可embedding
Python
2
star
23

MyTools

Python
2
star
24

tf-serving-client

TensorFlow Serving client hosted by Flask/Sanic Web Framework
1
star
25

tuning

tuning
Python
1
star
26

Competitons-Baseline

Competiton-Baseline
Python
1
star
27

Santander_Customer_Transaction_Prediction

kaggle
Python
1
star
28

ChatGo

微信微服务
Python
1
star
29

nlp-

Jupyter Notebook
1
star
30

xgboost-tuner

A library for automatically tuning XGBoost parameters
Python
1
star
31

Demo

1
star
32

minidata

文本匹配 情感分配 数据治理词根
Python
1
star
33

AuthorScore

1
star
34

simbert

基于UniLM思想、融检索与生成于一体的BERT模型。simbert向量化开箱即用
Python
1
star
35

bert4torch

BertZoo
1
star
36

MyWeb

WebApp
Python
1
star
37

competition-baseline

算法比赛:数据科学竞赛知识、代码、思路
Jupyter Notebook
1
star
38

QuantZoo

量化投资,让财富的飞轮旋转起来吧!
Python
1
star
39

AI-Torch

Pytorch Make Me Happy !
Python
1
star
40

ChineseNewWordsFinder

中文新词发现
Python
1
star
41

tql-ANN

ANN: Faiss
Python
1
star
42

MeUtils

MeUtils
Python
1
star
43

nlp-zoo

中文语料集合:停顿词、情感词、金融词库、敏感词(暴恐违禁/文本色情 /政治敏感 /恶意推广/低俗辱骂)等
1
star