libre chat
v0.0.6
轻松配置和部署基于开源大型语言模型 (LLM)(例如 Mixtral 或 Llama 2)的完全自托管聊天机器人 Web 服务,无需具备机器学习知识。
pip
包?或docker
镜像?LangChain
和llama.cpp
提供支持,可在本地进行推理。有关如何使用 Libre Chat 的更多详细信息,请查看vemonet.github.io/libre-chat上的文档
警告
该项目正在开发中,请谨慎使用。
这些检查点是我们计划在未来开发的功能,如果您有任何意见或要求,请随时在问题中告诉我们。
如果您只是想使用预训练的模型Mixtral-8x7B-Instruct
快速部署它,您可以使用 docker:
docker run -it -p 8000:8000 ghcr.io/vemonet/libre-chat:main
您可以使用环境变量配置部署。为此,使用docker compose
和.env
文件更容易,首先创建docker-compose.yml
文件:
version : " 3 "
services :
libre-chat :
image : ghcr.io/vemonet/libre-chat:main
volumes :
# ️ Share folders from the current directory to the /data dir in the container
- ./chat.yml:/data/chat.yml
- ./models:/data/models
- ./documents:/data/documents
- ./embeddings:/data/embeddings
- ./vectorstore:/data/vectorstore
ports :
- 8000:8000
并在与docker-compose.yml
相同的文件夹中使用您的配置创建一个chat.yml
文件:
llm :
model_path : ./models/mixtral-8x7b-instruct-v0.1.Q2_K.gguf
model_download : https://huggingface.co/TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF/resolve/main/mixtral-8x7b-instruct-v0.1.Q2_K.gguf
temperature : 0.01 # Config how creative, but also potentially wrong, the model can be. 0 is safe, 1 is adventurous
max_new_tokens : 1024 # Max number of words the LLM can generate
# Always use input for the human input variable with a generic agent
prompt_variables : [input, history]
prompt_template : |
Your are an assistant, please help me
{history}
User: {input}
AI Assistant:
vector :
vector_path : null # Path to the vectorstore to do QA retrieval, e.g. ./vectorstore/db_faiss
# Set to null to deploy a generic conversational agent
vector_download : null
embeddings_path : ./embeddings/all-MiniLM-L6-v2 # Path to embeddings used to generate the vectors, or use directly from HuggingFace: sentence-transformers/all-MiniLM-L6-v2
embeddings_download : https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/v0.2/all-MiniLM-L6-v2.zip
documents_path : ./documents # Path to documents to vectorize
chunk_size : 500 # Maximum size of chunks, in terms of number of characters
chunk_overlap : 50 # Overlap in characters between chunks
chain_type : stuff # Or: map_reduce, reduce, map_rerank. More details: https://docs.langchain.com/docs/components/chains/index_related_chains
search_type : similarity # Or: similarity_score_threshold, mmr. More details: https://python.langchain.com/docs/modules/data_connection/retrievers/vectorstore
return_sources_count : 2 # Number of sources to return when generating an answer
score_threshold : null # If using the similarity_score_threshold search type. Between 0 and 1
info :
title : " Libre Chat "
version : " 0.1.0 "
description : |
Open source and free chatbot powered by [LangChain](https://python.langchain.com) and [llama.cpp](https://github.com/ggerganov/llama.cpp)
examples :
- What is the capital of the Netherlands?
- Which drugs are approved by the FDA to mitigate Alzheimer symptoms?
- How can I create a logger with timestamp using python logging?
favicon : https://raw.github.com/vemonet/libre-chat/main/docs/docs/assets/logo.png
repository_url : https://github.com/vemonet/libre-chat
public_url : https://chat.semanticscience.org
contact :
name : Vincent Emonet
email : [email protected]
license_info :
name : MIT license
url : https://raw.github.com/vemonet/libre-chat/main/LICENSE.txt
最后启动你的聊天服务:
docker compose up
该软件包需要 Python >=3.8,只需使用pipx
或pip
安装即可:
pip install libre-chat
您可以使用终端轻松启动新的聊天 Web 服务,包括 UI 和 API:
libre-chat start
提供具体的配置文件:
libre-chat start config/chat-vectorstore-qa.yml
重建向量库:
libre-chat build --vector vectorstore/db_faiss --documents documents
通过以下方式获取可用选项的完整列表:
libre-chat --help
或者你可以在 python 脚本中使用这个包:
import logging
import uvicorn
from libre_chat import ChatConf , ChatEndpoint , Llm
logging . basicConfig ( level = logging . getLevelName ( "INFO" ))
conf = ChatConf (
model_path = "./models/mixtral-8x7b-instruct-v0.1.Q2_K.gguf" ,
vector_path = None
)
llm = Llm ( conf = conf )
print ( llm . query ( "What is the capital of the Netherlands?" ))
# Create and deploy a FastAPI app based on your LLM
app = ChatEndpoint ( llm = llm , conf = conf )
uvicorn . run ( app )
灵感来自:
由 Freepik - Flaticon 创建的骆驼图标