Skip to content

Repository files navigation

RagNET (Local Document Q&A / RAG) — .NET 8

Overview

  • 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)

Prerequisites

  • .NET SDK 8.x
  • Docker Desktop (để chạy Qdrant)
  • Ollama (local)

1) Start Qdrant (local)

Tại thư mục root:

docker compose up -d

Qdrant:

  • REST: http://localhost:6333
  • gRPC: http://localhost:6334

2) Setup Ollama (local LLM)

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 gemma2

Chạy Ollama server:

ollama serve

3) Embedding resources

Đặt thư mục .embedding_resources/root workspace, gồm:

  • model.onnx
  • model.onnx_data (nếu có)
  • tokenizer.json, tokenizer.model, tokenizer_config.json

Assumption: BERTTokenizers 1.2.0 không load trực tiếp tokenizer.json/tokenizer.model. Trong code hiện tại, tokenizer dùng BertBaseTokenizer (built-in) để tạo input_ids/attention_mask/type_ids. Nếu embedding ONNX yêu cầu SentencePiece tokenizer đúng theo tokenizer.model, ta sẽ cần thay tokenizer implementation (giữ nguyên IEmbeddingService nên thay thế dễ).

4) Index documents

Tạo thư mục docs/ và đặt PDF/DOCX/TXT vào đó.

Chạy indexer:

dotnet run --project RagApp.Indexer -- docs

5) Run Web App (Blazor Server)

dotnet run --project RagApp.Api

Mở:

  • https://localhost:xxxx/chat (hoặc http://localhost:xxxx/chat)

Configuration

  • RagApp.Indexer/appsettings.json
  • RagApp.Api/appsettings.json

Các key chính:

  • Embedding:ModelDirectory
  • Qdrant:Endpoint, Qdrant:CollectionName
  • Ollama:Endpoint, Ollama:ModelName
  • Chunking:MaxTokensPerChunk, Chunking:OverlapTokens
  • Rag:TopK

"# RagNet-Labs"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages