打造智能私有知識(shí)庫(kù):開源工具AnythingLLM全解析及實(shí)操指南,RAG企業(yè)級(jí)解決方案 原創(chuàng)
在數(shù)據(jù)安全和隱私保護(hù)日益受到重視的背景下,私有化部署大模型的需求日益增長(zhǎng)。Mintplex Labs Inc. 推出的開源項(xiàng)目 AnythingLLM,為個(gè)人和企業(yè)提供了一種安全、高效且可定制的解決方案。該工具基于RAG(Retrieval-Augmented Generation)模型,允許用戶將本地文檔轉(zhuǎn)換為可由大型語(yǔ)言模型(LLM)引用的格式,實(shí)現(xiàn)對(duì)話式問答和知識(shí)管理。
一、AnythingLLM的主要功能
- 多用戶支持與權(quán)限管理:支持多用戶同時(shí)訪問,并可設(shè)置不同權(quán)限。
- 文檔管理:支持PDF、TXT、DOCX等多種文檔類型,并通過簡(jiǎn)易界面管理。
- 聊天模式:提供對(duì)話和查詢兩種模式,保留歷史記錄,支持引用標(biāo)注。
- 技術(shù)棧簡(jiǎn)單:便于快速迭代和云部署。
- 成本效益:對(duì)大型文檔一次性嵌入,顯著節(jié)約成本。
- 開發(fā)者API:提供完整API支持自定義集成。
- LLM:包括任何開源的 llama.cpp 兼容模型、OpenAI、Azure OpenAI、Anthropic ClaudeV2、LM Studio 和 LocalAi。
- 嵌入模型:AnythingLLM 原生嵌入器、OpenAI、Azure OpenAI、LM Studio 和 LocalAi。
- 向量數(shù)據(jù)庫(kù):LanceDB(默認(rèn))、Pinecone、Chroma、Weaviate 和 QDrant。
二、AnythingLLM 部署實(shí)戰(zhàn)
1. 安裝Chroma Vectorstore:通過Docker容器部署,創(chuàng)建集合并驗(yàn)證設(shè)置。
訪問向量存儲(chǔ)API文檔: http://localhost:8000/docs
2. LocalAI部署:使用CLI應(yīng)用程序啟動(dòng)API服務(wù)器,與開源模型交互。
git clone https://github.com/go-skynet/LocalAI
cd chroma
docker compose up -d --build
容器運(yùn)行后,我們需要下載、安裝模型以供測(cè)試使用
Bert 的轉(zhuǎn)換器嵌入模型:MiniLM L6
curl http://localhost:8080/models/apply
-H "Content-Type: application/json"
-d '{ "id": "model-gallery@bert-embeddings" }'
curl http://localhost:8080/v1/embeddings
-H "Content-Type: application/json"
-d '{ "input": "The food was delicious and the waiter...",
"model": "bert-embeddings" }'
{
"created": 1702050873,
"object": "list",
"id": "b11eba4b-d65f-46e1-8b50-38d3251e3b52",
"model": "bert-embeddings",
"data": [
{
"embedding": [
-0.043848168,
0.067443006,
...
0.03223838,
0.013112408,
0.06982294,
-0.017132297,
-0.05828256
],
"index": 0,
"object": "embedding"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
大模型LLM:Zephyr-7B-β
curl http://localhost:8080/models/apply
-H "Content-Type: application/json"
-d '{ "id": "huggingface@thebloke__zephyr-7b-beta-gguf__zephyr-7b-beta.q4_k_s.gguf",
"name": "zephyr-7b-beta" }'
curl http://localhost:8080/v1/chat/completions
-H "Content-Type: application/json"
-d '{ "model": "zephyr-7b-beta",
"messages": [{
"role": "user",
"content": "Why is the Earth round?"}],
"temperature": 0.9 }'
{
"created": 1702050808,
"object": "chat.completion",
"id": "67620f7e-0bc0-4402-9a21-878e4c4035ce",
"model": "thebloke__zephyr-7b-beta-gguf__zephyr-7b-beta.q4_k_s.gguf",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "\nThe Earth appears round because it is
actually a spherical body. This shape is a result of the
gravitational forces acting upon it from all directions. The force
of gravity pulls matter towards the center of the Earth, causing
it to become more compact and round in shape. Additionally, the
Earth's rotation causes it to bulge slightly at the equator,
further contributing to its roundness. While the Earth may appear
flat from a distance, up close it is clear that our planet is
indeed round."
}
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
3. 部署AnythingLLM:利用官方Docker鏡像安裝,然后配置LocalAI后端和嵌入模型。
docker pull mintplexlabs/anythingllm:master
export STORAGE_LOCATION="/var/lib/anythingllm" && \
mkdir -p $STORAGE_LOCATION && \
touch "$STORAGE_LOCATION/.env" && \
docker run -d -p 3001:3001 \
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
mintplexlabs/anythingllm:master
訪問:???http://localhost:3001??,我們可以在其中使用直觀的 GUI 開始配置。
LocalAI 后端配置:通過 http://172.17.0.1:8080/v1 URL 訪問
嵌入模型配置與相同的 LocalAI 后端保持一致。
接下來,配置 Chroma 向量數(shù)據(jù)庫(kù),使用URL http://172.17.0.1:8000
創(chuàng)建一個(gè)工作區(qū),命名為“Playground”。
在“Playground”工作區(qū),我們可以上傳文檔,進(jìn)一步擴(kuò)展本地知識(shí)庫(kù)。
至此我們能夠與文檔開始進(jìn)行交互式對(duì)話。
總結(jié):
AnythingLLM和Vector Admin是Mintplex Labs提供的創(chuàng)新開源工具,它們極大地簡(jiǎn)化了私有知識(shí)庫(kù)的構(gòu)建和管理。通過高效的RAG模型實(shí)現(xiàn)和直觀的用戶界面,這些工具不僅保障了數(shù)據(jù)的安全性,同時(shí)也提供了強(qiáng)大的交互式文檔處理能力。隨著技術(shù)的不斷進(jìn)步,這些工具將為企業(yè)和個(gè)人用戶提供更多的可能性和價(jià)值。
了解更多詳情:
AnythingLLM GitHub: https://github.com/Mintplex-Labs/anything-llm
LocalAI Docs: https://localai.io/
AnythingLLM: https://useanything.com/
本文轉(zhuǎn)載自公眾號(hào)頂層架構(gòu)領(lǐng)域
原文鏈接:????https://mp.weixin.qq.com/s/KHeWJUIRFqygPs6fVOES7A??