- Indexer (
RagApp.Indexer): console app đọc tài liệu → chunk → embed (ONNX) → upsert Qdrant - Web App (
RagApp.Api): Blazor Server chat realtime + streaming trả lời từ Ollama (gemma2)
- .NET SDK 8.x
- Docker Desktop (để chạy Qdrant)
- Ollama (local)
Tại thư mục root:
docker compose up -dQdrant:
- REST:
http://localhost:6333 - gRPC:
http://localhost:6334
Cài Ollama theo hướng dẫn chính thức (offline installer nếu cần).
Pull model (chạy 1 lần, cần mạng ở bước này nếu máy chưa có model):
ollama pull gemma2Chạy Ollama server:
ollama serveĐặt thư mục .embedding_resources/ ở root workspace, gồm:
model.onnxmodel.onnx_data(nếu có)tokenizer.json,tokenizer.model,tokenizer_config.json
Assumption:
BERTTokenizers1.2.0 không load trực tiếptokenizer.json/tokenizer.model. Trong code hiện tại, tokenizer dùngBertBaseTokenizer(built-in) để tạoinput_ids/attention_mask/type_ids. Nếu embedding ONNX yêu cầu SentencePiece tokenizer đúng theotokenizer.model, ta sẽ cần thay tokenizer implementation (giữ nguyênIEmbeddingServicenên thay thế dễ).
Tạo thư mục docs/ và đặt PDF/DOCX/TXT vào đó.
Chạy indexer:
dotnet run --project RagApp.Indexer -- docsdotnet run --project RagApp.ApiMở:
https://localhost:xxxx/chat(hoặchttp://localhost:xxxx/chat)
RagApp.Indexer/appsettings.jsonRagApp.Api/appsettings.json
Các key chính:
Embedding:ModelDirectoryQdrant:Endpoint,Qdrant:CollectionNameOllama:Endpoint,Ollama:ModelNameChunking:MaxTokensPerChunk,Chunking:OverlapTokensRag:TopK
"# RagNet-Labs"