Tất cả bài viết
LLM
LLM
RAG
NLP
Enterprise AI

Xây dựng RAG system cho Knowledge Base doanh nghiệp

Infratek AI Team·NLP Engineering10 tháng 12, 202411 phút đọc

Xây dựng RAG system cho Knowledge Base doanh nghiệp

LLM mạnh nhưng không biết gì về data nội bộ của bạn. RAG (Retrieval-Augmented Generation) là pattern phổ biến nhất để đưa enterprise knowledge vào AI.

Architecture Overview

Documents → Chunking → Embedding → Vector DB
                                        ↓
User Query → Embedding → Retrieval → Context + Query → LLM → Answer

Chunking Strategies

Chunking là bước quan trọng nhất mà nhiều team underestimate:

  • Fixed-size (512 tokens) — simple nhưng mất context
  • Semantic chunking — split theo paragraph/section boundaries
  • Document-aware — preserve headers, tables, lists structure
  • Parent-child — retrieve small chunks, return parent context

Cho technical docs tiếng Việt, chúng tôi recommend semantic + parent-child.

Embedding Model Selection

ModelDimensionsVietnamese SupportSpeed
text-embedding-3-large3072GoodMedium
multilingual-e5-large1024ExcellentFast
bge-m31024ExcellentFast

Evaluation

Đừng deploy mà không evaluate. Metrics quan trọng:

  1. Retrieval Recall@k — relevant docs có trong top-k không?
  2. Answer Faithfulness — answer có grounded trong context không?
  3. Answer Relevance — answer có đúng câu hỏi không?
  4. Latency — end-to-end response time

Production Tips

  • Hybrid search (vector + keyword) outperform pure vector cho technical terms
  • Reranking với cross-encoder cải thiện precision đáng kể
  • Cache frequent queries
  • Always cite sources trong response