Demo LLM(RAG Pipeline)使用Docker-Compose在本地運行的Web應用程序。 LLM和嵌入模型被用作OpenAI的服務。
主要目的是使用戶能夠提出與LASIK手術有關的問題,例如“計算機程序員有lasik的禁忌症嗎?”
檢索增強生成(RAG)管道從數據集檢索最新信息,以提供對用戶查詢的準確和相關的響應。
應用程序架構如下:

序列圖:
測序圖
用戶 - >> Langserve API:查詢
注意用戶的權利:是否有禁忌症<br/>供計算機程序員<br/>獲得LASIK?
Langserve API- >> OpenAI嵌入:用戶查詢
OpenAI嵌入 - >> Langserve API:嵌入
Langserve API- >> MILVUSDB:文檔檢索(向量搜索)
MILVUSDB - >> Langserve API:相關文件
注意Langserve API的右:提示<br/>工程...
Langserve API- >> OpenAi LLM:富集提示
Openai LLM- >> Langserve API:生成的答案
ux:

構建應用Docker映像:
make app-build將OpenAI API密鑰設置為環境變量
export OPENAI_API_KEY= < your-api-key >旋轉Milvus DB:
make db-up帶有LASIK眼科手術並發症數據集的DB填充DB:
make db-populate
旋轉API:
make app-run
現在可以通過http:// localhost提供聊天機器人:8000/lasik_complications/playground/
顯示所有可用命令:
make help 
清理
make clean ├── .github
│ ├── workflow
│ │ └── cicd.yml <- CI pipeline definition
├── data
│ └── laser_eye_surgery_complications.csv <- Kaggle dataset
|
├── docs
│ ├── diagrams <- Folder containing diagram definitions
│ └── img <- Folder containing screenshots
│
├── src
│ ├── config.py <- Config file with service host/ports or models to be used
│ ├── populate_vector_db.py <- Scripts that converts texts to embeddings and populates Milvus DB
│ └── server.py <- FastAPI/Langserve/Langchain
│
├── .gitignore
├── .pre-commit-config.yaml <- ruff linter pre-commit hook
├── docker-compose.yml <- container orchestration
├── Dockerfile <- App image definition
├── Makefile <- Makefile with commands like `make app-build`
├── poetry.lock <- Pinned dependencies
├── pyproject.toml <- Dependencies requirements
├── README.md <- The top-level README for developers using this project.
└── ruff.toml <- Linter config
來自LASIK(激光眼科手術)並發症(Kaggle)

Milvus是由Zilliz開發的開源矢量數據庫引擎,旨在存儲和管理大規模矢量數據,例如嵌入,功能和高維數據。它為向量相似性搜索任務提供有效的存儲,索引和檢索功能。

Langchain是LLM編排工具,當您需要構建上下文感知的LLM應用程序時,它非常有用。
為了向LLM提供上下文,我們必須將原始問題包裹在及時的模板中

您可以通過單擊UX中的“中間步驟”來檢查LLM實際收到的提示

Langserve幫助開發人員將Langchain Runnables和鏈條作為REST API部署。該庫與FastApi集成在一起。
聊天機器人無法回答與統計數據有關的問題,例如“ Lasik手術並發症最近是否有任何趨勢?” ,應該有另一種模型來滲透相關的時間窗口,以考慮檢索文檔,然後用這個時間窗口豐富最終提示。
Langsmith的算法反饋。這將允許以自動化方式測試LLM鏈的魯棒性。