19 kỹ thuật, 6 khâu — dùng cho gì, mất gì, đánh đổi ở đâu19 techniques, 6 layers — what each buys you and what it costs

RAG là bài toán search khoác áo AIRAG is a search problem in an AI costume

Không có kỹ thuật nào tốt nhất — chỉ có kỹ thuật đúng cho triệu chứng bạn đang gặp. Sổ này xếp 19 kỹ thuật theo sáu khâu của pipeline, mỗi kỹ thuật nói rõ nó lấy đi cái gì để đổi lấy cái gì.There is no best technique — only the right one for the symptom in front of you. This catalog sorts 19 techniques into the six pipeline layers, and states for each what it takes away in exchange for what it gives.

RAG pipeline: solid lines always run, dashed lines are decided at runtime.CorpusCorpus1Nạp & cắtIngestIndexIndexCâu hỏiQuestion4HỏiQuery2TìmRetrieve3LọcRefine5SinhGenerateTrả lờiAnswerbỏ qua tìm kiếmskip retrieval6 · tìm lại, thử lại6 · re-search, retry
đường luôn chạyalways runs quyết định lúc chạy — có thể bỏ qua hoặc lặp lạidecided at runtime — may skip or repeat Bấm vào một khâu để nhảy tới nhóm kỹ thuật của nó.Tap a layer to jump to its techniques.

Chọn cái nàoWhich one do I need

Bắt đầu từ triệu chứng, không phải từ danh sách kỹ thuật. Tìm dòng mô tả đúng thứ hệ thống của bạn đang mắc.Start from the symptom, not from the technique list. Find the row that describes what your system is doing.

Sổ tra kỹ thuậtThe catalog

Số dạng 2.3 là toạ độ tra cứu: khâu 2, kỹ thuật thứ 3. Cùng số đó xuất hiện trên sơ đồ và trong bảng đánh đổi.A number like 2.3 is a lookup coordinate: layer 2, technique 3. The same number appears on the map and in the trade-off table.

1

Nạp & cắtIngest

Quyết định lúc index. Sai ở đây thì mọi tầng sau không cứu được.Decided at index time. Break it here and nothing downstream helps.

1.1

Cắt theo cấu trúcStructure-aware chunking

Nạp & cắtIngest

Cắt theo heading, section, điều khoản — ranh giới tác giả đã đánh dấu sẵn.Split on headings, sections, clauses — boundaries the author already marked.

Dùng choUse for
Tài liệu có cấu trúc rõ: Markdown, HTML, hợp đồng, mã nguồn.Documents with real structure: Markdown, HTML, contracts, source code.
ĐượcGain
Chunk không đứt giữa ý; ngữ cảnh đến sẵn theo đơn vị ngữ nghĩa.No chunk cut mid-thought; context arrives in semantic units.
MấtLose
Kích thước không đều; section quá dài vẫn phải cắt tiếp.Uneven sizes; over-long sections still need a second pass.

Đổi sự đồng đều về kích thước lấy tính toàn vẹn của ý.Trades uniform size for intact meaning.

Dấu hiệu nhận biếtTell Câu trả lời cụt nửa câu, hoặc một chunk chứa hai chủ đề rời nhau.Answers stop mid-sentence, or one chunk holds two unrelated topics.

1.2

Parent–childParent–child (small-to-big)

Nạp & cắtIngest

Embed chunk nhỏ để khớp, trả về section cha lớn cho LLM đọc.Embed small chunks to match, return the larger parent for the model to read.

Dùng choUse for
Khi khớp cần chính xác nhưng câu trả lời cần ngữ cảnh rộng hơn.When matching needs precision but the answer needs wider context.
ĐượcGain
Precision lúc search và đầy đủ lúc đọc, cùng lúc.Search precision and reading completeness at the same time.
MấtLose
Lưu hai tầng, cần logic map con→cha, prompt dài hơn.Two storage tiers, child→parent mapping, longer prompts.

Đổi độ phức tạp lưu trữ để khỏi phải chọn giữa chunk nhỏ và chunk lớn.Trades storage complexity for not having to choose small or large.

Dấu hiệu nhận biếtTell Retrieval trúng đúng chunk nhưng LLM vẫn thiếu dữ kiện để kết luận.Retrieval hits the right chunk but the model still lacks enough to conclude.

1.3

Contextual retrievalContextual retrieval

Nạp & cắtIngest

Sinh sẵn một dòng ngữ cảnh gắn đầu mỗi chunk trước khi embed.Generate a short context line and prepend it to each chunk before embedding.

Dùng choUse for
Chunk mất tham chiếu: đại từ, “lãi suất này”, số liệu không rõ năm.Chunks that lose their referents: pronouns, “this rate”, undated figures.
ĐượcGain
Giảm rõ rệt tỷ lệ retrieval hụt mà không đổi kiến trúc.Measurably fewer retrieval misses with no architectural change.
MấtLose
Một lời gọi LLM cho mỗi chunk trong lúc index.One LLM call per chunk during indexing.

Trả chi phí một lần lúc index để mọi truy vấn về sau chính xác hơn.Pays once at index time so every later query lands better.

Dấu hiệu nhận biếtTell Đọc riêng một chunk ra thì không biết nó đang nói về cái gì.Read a chunk in isolation and you cannot tell what it refers to.

1.4

Metadata & bộ lọcMetadata & filters

Nạp & cắtIngest

Lưu nguồn, ngày, phòng ban, quyền; lọc cứng ngay trong truy vấn search, không lọc sau.Store source, date, owner, permissions; filter hard inside the search query, not after it.

Dùng choUse for
Câu hỏi có ràng buộc cứng: thời gian, loại tài liệu, tenant, quyền truy cập.Questions with hard constraints: date, doc type, tenant, access rights.
ĐượcGain
Loại thẳng phần lớn corpus; là điều kiện bắt buộc để phân quyền.Eliminates most of the corpus outright; mandatory for access control.
MấtLose
Phải thiết kế schema từ đầu — bổ sung sau nghĩa là index lại toàn bộ.Schema must be designed up front — adding it later means a full re-index.

Công sức bỏ ra ở ngày đầu, không phải ở ngày tối ưu.The work lands on day one, not on optimisation day.

Dấu hiệu nhận biếtTell Kết quả đúng chủ đề nhưng sai năm, sai phòng ban, sai khách hàng.Results are on-topic but the wrong year, wrong team, wrong customer.

2

TìmRetrieve

Lấy ứng viên. Ưu tiên recall — thà thừa còn hơn sót.Fetch candidates. Optimise for recall — better too many than missing one.

2.1

Vector searchVector search

TìmRetrieve

Chuyển text thành vector; văn bản gần nghĩa thì nằm gần nhau.Map text to vectors; similar meaning lands in nearby space.

Dùng choUse for
Câu hỏi diễn đạt bằng từ ngữ khác với tài liệu.Questions phrased differently from the documents.
ĐượcGain
Bắt được “ô tô” khi người dùng hỏi “xe hơi”; chịu được cách nói vòng.Finds “automobile” when the user typed “car”; tolerates indirect phrasing.
MấtLose
Trượt mã lỗi, số phiên bản, danh từ riêng lạ; gần như mù với phủ định.Misses error codes, versions, unusual proper nouns; nearly blind to negation.

Đổi độ chính xác trên mặt chữ lấy khả năng hiểu nghĩa.Trades literal precision for semantic reach.

Dấu hiệu nhận biếtTell Người dùng gõ đúng mã sản phẩm mà tài liệu chứa mã đó vẫn không lên.The user types the exact SKU and the document containing it does not surface.

2.2

BM25BM25

TìmRetrieve

Chấm điểm theo từ trùng, thưởng từ hiếm, phạt tài liệu dài.Scores on matched terms, rewards rare words, penalises long documents.

Dùng choUse for
Mã lỗi, SKU, tên riêng, thuật ngữ hiếm, trích dẫn nguyên văn.Error codes, SKUs, proper nouns, rare jargon, verbatim quotes.
ĐượcGain
Trúng chính xác thứ người dùng gõ; rẻ, không cần GPU.Finds exactly what was typed; cheap, no GPU.
MấtLose
Không hiểu đồng nghĩa. Tiếng Việt cần cấu hình tách từ và xử lý dấu.No synonym awareness. Vietnamese needs word segmentation and diacritics config.

Không hiểu gì cả — và đó chính là lý do nó bù được cho vector.It understands nothing, and that is exactly why it covers for vectors.

Dấu hiệu nhận biếtTell Có những từ khoá hiếm mà vector search bỏ qua hoàn toàn.There are rare keywords vector search drops entirely.

2.3

Hybrid + RRFHybrid + RRF

TìmRetrieve

Chạy cả hai retriever rồi trộn theo thứ hạng, không cộng điểm.Run both retrievers, then fuse by rank — never by adding scores.

Dùng choUse for
Mặc định cho gần như mọi hệ thống chạy thật.The default for almost any system that ships.
ĐượcGain
Che điểm mù của cả hai phía; RRF ít tham số nên ổn định giữa các corpus.Covers both blind spots; RRF is parameter-light so it transfers between corpora.
MấtLose
Hai index phải duy trì, hai lần search cho mỗi truy vấn.Two indexes to maintain, two searches per query.

k=60 là mặc định tốt. Chỉnh trọng số chỉ đáng khi đã có golden set.k=60 is a good default. Tuning weights only pays once you have a golden set.

Dấu hiệu nhận biếtTell Nếu hệ thống chưa bật hybrid, đây là việc tiếp theo cần làm.If your system has no hybrid search yet, this is the next thing to build.

2.4

Index xấp xỉ (ANN)Approximate index (ANN)

TìmRetrieve

HNSW hoặc IVF tìm gần đúng thay vì duyệt toàn bộ vector.HNSW or IVF search approximately instead of scanning every vector.

Dùng choUse for
Khi vượt khoảng 100k vector và độ trễ search bắt đầu tăng; qua ~1M thì chắc chắn cần.Past roughly 100k vectors, when search latency starts climbing; definitely past ~1M.
ĐượcGain
Độ trễ gần như không đổi khi corpus lớn dần.Latency stays nearly flat as the corpus grows.
MấtLose
Recall dưới 1,0 — âm thầm đánh mất một phần kết quả đúng.Recall drops below 1.0 — silently losing some correct results.

Đổi vài phần trăm recall lấy tốc độ. Dưới ngưỡng đó, flat vừa chính xác vừa đơn giản hơn.Trades a few points of recall for speed. Below the threshold, flat is both exact and simpler.

Dấu hiệu nhận biếtTell Search chậm dần theo số tài liệu. Chưa chậm thì chưa cần.Search slows as documents accumulate. Not slow yet means not needed yet.

3

LọcRefine

Cắt ứng viên xuống. Ưu tiên precision — prompt phải sạch.Cut candidates down. Optimise for precision — the prompt must stay clean.

3.1

Cross-encoder rerankCross-encoder rerank

LọcRefine

Đưa cặp (câu hỏi, tài liệu) vào cùng một model để chấm lại độ liên quan.Feed (query, document) into one model together and rescore relevance.

Dùng choUse for
Sau khi hybrid trả về 50 ứng viên, giữ lại 5 để đưa vào prompt.After hybrid returns 50 candidates, keep 5 for the prompt.
ĐượcGain
Cho phép đặt k cao mà prompt vẫn ngắn — recall và precision cùng lúc.Lets you set k high while keeping the prompt short — recall and precision together.
MấtLose
Thêm khoảng 50–300 ms độ trễ cho 20–100 ứng viên, cộng chi phí cho mỗi lời gọi.Adds ~50–300 ms of latency for 20–100 candidates, plus a per-call cost.

Nâng cấp có tỷ lệ lợi trên công cao nhất sau hybrid. Làm trước mọi thứ ở tầng 6.Highest return per unit of effort after hybrid. Do this before anything in layer 6.

Dấu hiệu nhận biếtTell Kết quả đúng nằm ở hạng 20–40 thay vì hạng 1–5.The right result sits at rank 20–40 instead of rank 1–5.

3.2

Late interactionLate interaction (ColBERT)

LọcRefine

Lưu một vector cho mỗi token, tính điểm MaxSim lúc truy vấn.Store one vector per token, compute a MaxSim score at query time.

Dùng choUse for
Cần chất lượng gần cross-encoder nhưng không chịu nổi độ trễ của nó.You need near cross-encoder quality but cannot afford its latency.
ĐượcGain
Tốt hơn bi-encoder, nhanh hơn cross-encoder.Better than a bi-encoder, faster than a cross-encoder.
MấtLose
Dung lượng lưu trữ gấp 10–100 lần.Storage grows 10–100×.

Lựa chọn ngách. Chỉ cân nhắc khi rerank đã là nút thắt độ trễ.A niche pick. Only consider it once reranking is the latency bottleneck.

Dấu hiệu nhận biếtTell Đã tối ưu rerank hết mức mà vẫn không đạt ngân sách độ trễ.Reranking is fully tuned and the latency budget still does not close.

4

HỏiQuery

Sửa câu hỏi trước khi tìm. Rẻ hơn sửa mọi thứ phía sau.Fix the question before searching. Cheaper than fixing everything after.

4.1

Cô đọng hội thoạiConversational condensation

HỏiQuery

Viết lại câu hỏi phụ thuộc ngữ cảnh thành câu hỏi độc lập trước khi tìm.Rewrite a context-dependent question into a standalone one before searching.

Dùng choUse for
Mọi chatbot nhiều lượt. Đây không phải tuỳ chọn.Every multi-turn chatbot. This is not optional.
ĐượcGain
“Còn cái thứ hai?” trở thành một truy vấn tìm được.“And the second one?” becomes a query that can actually be searched.
MấtLose
Một lời gọi LLM đứng trước mỗi lần search.One LLM call in front of every search.

Chi phí nhỏ và cố định, đổi lấy việc hệ thống không sập từ lượt thứ hai.A small fixed cost so the system does not collapse at turn two.

Dấu hiệu nhận biếtTell Lượt đầu trả lời tốt, từ lượt hai retrieval lệch hoàn toàn.The first turn answers well, then retrieval goes off the rails.

4.2

Multi-query & phân rãMulti-query & decomposition

HỏiQuery

Sinh nhiều cách diễn đạt, hoặc tách câu hỏi ghép, tìm từng cái rồi trộn.Generate paraphrases, or split a compound question, search each, then fuse.

Dùng choUse for
Câu hỏi so sánh, câu hỏi mơ hồ, câu hỏi chứa hai ý tách rời.Comparison questions, vague questions, questions holding two separate asks.
ĐượcGain
Tăng recall khi cách diễn đạt của người dùng lệch khỏi tài liệu.Raises recall when the user's phrasing diverges from the documents.
MấtLose
N lần search cộng một lời gọi LLM; độ trễ tăng theo N.N searches plus one LLM call; latency scales with N.

Đổi độ trễ lấy recall. Dùng khi hụt là do diễn đạt, không phải do index.Trades latency for recall. Use it when misses come from phrasing, not from the index.

Dấu hiệu nhận biếtTell “So sánh A và B” chỉ lấy về được tài liệu nói về A.“Compare A and B” only retrieves documents about A.

4.3

HyDEHyDE

HỏiQuery

Cho LLM viết một câu trả lời giả định, rồi dùng chính nó làm truy vấn.Have the model write a hypothetical answer, then search with that.

Dùng choUse for
Câu hỏi ngắn, mơ hồ, ít từ khoá trùng với văn phong tài liệu.Short, vague questions sharing few words with how the documents are written.
ĐượcGain
Vector của một câu trả lời khớp tài liệu tốt hơn vector của một câu hỏi.An answer's vector aligns with documents better than a question's does.
MấtLose
Nếu câu trả lời bịa đi lệch chủ đề, retrieval lệch theo.If the hallucinated answer drifts, retrieval drifts with it.

Đặt cược vào chính thứ bạn đang cố sửa. Đo trước khi bật ở production.Bets on the very thing you are trying to fix. Measure before enabling it live.

Dấu hiệu nhận biếtTell Câu hỏi rất ngắn trong khi tài liệu viết dài và học thuật.Very short questions against long, formal documents.

4.4

RoutingRouting

HỏiQuery

Phân loại câu hỏi trước, rồi mới chọn retrieval, SQL, tool hay trả lời thẳng.Classify the question first, then dispatch to retrieval, SQL, a tool, or a direct answer.

Dùng choUse for
Hệ thống nhận nhiều loại câu hỏi khác bản chất nhau.Systems that receive genuinely different kinds of questions.
ĐượcGain
Không lãng phí retrieval cho “chào bạn”; đưa câu hỏi số liệu sang SQL.No retrieval wasted on “hi”; numeric questions go to SQL where they belong.
MấtLose
Thêm một tầng phân loại, và tầng đó có thể phân sai.Adds a classifier layer, and that layer can be wrong.

Sai lầm của router thì lặng lẽ; hãy log nhánh đã chọn cho mọi truy vấn.Router mistakes are silent; log the chosen branch on every query.

Dấu hiệu nhận biếtTell Hệ thống cố retrieval cho câu hỏi vốn cần tính toán hoặc không cần dữ liệu.The system attempts retrieval for questions needing arithmetic or no data at all.

5

SinhGenerate

Ghép prompt và ràng buộc model vào nguồn.Assemble the prompt and bind the model to its sources.

5.1

Bám nguồn & trích dẫnGrounding & citations

SinhGenerate

Đánh số nguồn, bắt buộc trích dẫn, cho phép model nói “không tìm thấy”.Number the sources, require citations, permit the model to say “not found”.

Dùng choUse for
Mọi hệ thống RAG. Đây là tuyến phòng thủ chính trước hallucination.Every RAG system. This is the primary defence against hallucination.
ĐượcGain
Câu trả lời kiểm chứng được; hậu kiểm bằng code bắt được sai lệch.Answers become checkable; a cheap code post-check catches drift.
MấtLose
Đôi khi từ chối trong khi câu trả lời thực ra có trong nguồn.Sometimes refuses when the answer was in fact present.

Chấp nhận vài lần từ chối sai để đổi lấy việc không bịa. Đây là đánh đổi đúng.Accept a few false refusals in exchange for no fabrication. That is the right trade.

Dấu hiệu nhận biếtTell Câu trả lời tự tin nhưng không nằm trong bất kỳ chunk nào đã lấy về.A confident answer that appears in none of the retrieved chunks.

5.2

Prompt cachingPrompt caching

SinhGenerate

Cache phần tiền tố tĩnh của prompt; giữ mọi nội dung thay đổi ở cuối.Cache the static prefix of the prompt; keep everything variable at the end.

Dùng choUse for
System prompt dài, few-shot, tài liệu tham chiếu lặp lại ở mọi lời gọi.Long system prompts, few-shot examples, reference documents repeated every call.
ĐượcGain
Giảm mạnh chi phí token đầu vào và độ trễ lượt đầu.Sharply lower input-token cost and first-token latency.
MấtLose
Chỉ có hiệu lực khi tiền tố giống hệt nhau từng byte.Only works when the prefix is byte-identical between calls.

Cấu trúc prompt trở thành ràng buộc kiến trúc, không còn là chuyện tuỳ tiện.Prompt ordering becomes an architectural constraint, not a free choice.

Dấu hiệu nhận biếtTell Một timestamp hoặc tên người dùng ở đầu prompt đang phá cache mọi lời gọi.A timestamp or user name at the top is destroying the cache on every call.

6

Vòng lặpLoop

Chạy lại có điều kiện. Chỉ dùng khi bốn tầng trên đã đo xong.Conditional re-runs. Only after the four layers above are measured.

6.1

Agentic RAGAgentic RAG

Vòng lặpLoop

Đưa search cho model dưới dạng tool, để nó tự quyết tìm gì và khi nào dừng.Give the model search as a tool and let it decide what to search and when to stop.

Dùng choUse for
Câu hỏi nghiên cứu mở, không biết trước cần bao nhiêu lần tìm.Open-ended research where the number of searches is not known in advance.
ĐượcGain
Xử lý được câu hỏi mà một lần retrieval không thể đủ.Handles questions a single retrieval could never satisfy.
MấtLose
Độ trễ và chi phí không đoán trước được; cần đặt giới hạn số bước.Unpredictable latency and cost; needs a hard step limit.

Bỏ tính xác định để lấy khả năng thích ứng. Nhiều đội trả giá này quá sớm.Gives up determinism for adaptability. Most teams pay that price too early.

Dấu hiệu nhận biếtTell Chỉ dùng sau khi hybrid, rerank và viết lại truy vấn đã chạy và đã được đo.Only after hybrid, reranking and query rewriting are live and measured.

6.2

Self-RAG / CRAGSelf-RAG / CRAG

Vòng lặpLoop

Chấm điểm chunk lấy về và bản nháp; nếu kém thì viết lại truy vấn và thử lại.Grade the retrieved chunks and the draft; if weak, rewrite the query and retry.

Dùng choUse for
Khi độ tin cậy quan trọng hơn độ trễ.When reliability matters more than latency.
ĐượcGain
Bắt được retrieval hụt trước khi người dùng nhìn thấy kết quả.Catches retrieval misses before the user ever sees them.
MấtLose
Nhân đôi hoặc nhân ba số lời gọi trong trường hợp xấu.Doubles or triples the number of calls in the worst case.

Trả bằng độ trễ cho phần đuôi phân phối. Đo tỷ lệ kích hoạt trước khi bật.Pays latency to fix the tail. Measure how often it fires before turning it on.

Dấu hiệu nhận biếtTell Tỷ lệ hụt vẫn cao nhưng không còn cải thiện được ở tầng retrieval.Miss rate is still high and the retrieval layer has nothing left to give.

6.3

GraphRAGGraphRAG

Vòng lặpLoop

Trích thực thể và quan hệ thành đồ thị; lấy về đồ thị con và tóm tắt cụm.Extract entities and relations into a graph; retrieve subgraphs and community summaries.

Dùng choUse for
Câu hỏi tầm tổng thể mà không chunk đơn lẻ nào trả lời được.Corpus-wide questions no single chunk can answer.
ĐượcGain
Trả lời được “các chủ đề chính xuyên suốt 500 báo cáo là gì”.Answers “what are the main themes across these 500 reports”.
MấtLose
Chi phí dựng và duy trì cao; cập nhật tài liệu kéo theo cập nhật đồ thị.Expensive to build and maintain; document updates cascade into graph updates.

Một hệ thống thứ hai phải nuôi song song. Chỉ đáng khi loại câu hỏi đó là chính.A second system to keep alive. Only worth it when those questions are the main use case.

Dấu hiệu nhận biếtTell Câu hỏi bắt đầu bằng “tổng thể”, “xu hướng”, “so với toàn bộ”.Questions opening with “overall”, “trends across”, “compared to the whole”.

Bảng đánh đổiTrade-offs at a glance

Xếp theo thứ tự nên làm, không theo thứ tự thú vị.Ordered by what to build first, not by what is most interesting.

Kỹ thuậtTechnique Độ trễ thêmAdded latency Chi phíCost Mức cải thiệnGain Khi nàoWhen
2.3 Hybrid + RRFHybrid + RRF +30msthấplowlớnlargelàm ngaydo it now
3.1 Cross-encoder rerankCross-encoder rerank +50–300mstrung bìnhmediumlớnlargelàm ngaydo it now
4.1 Cô đọng hội thoạiConversational condensation +1 lời gọithấplowlớn nếu là chatbotlarge for chatbotslàm ngaydo it now
1.3 Contextual retrievalContextual retrieval 0 lúc chạy0 at query timecao lúc indexhigh at indextrung bình–lớnmedium–largenên làmworth it
1.2 Parent–childParent–child 00thấplowtrung bìnhmediumnên làmworth it
4.2 Multi-queryMulti-query +N×searchtrung bìnhmediumthay đổivarieskhi đã đoonce measured
4.3 HyDEHyDE +1 lời gọitrung bìnhmediumthay đổivarieskhi đã đoonce measured
6.1 Agentic RAGAgentic RAG không đoán đượcunpredictablecaohighchỉ với câu hỏi mởopen-ended onlysau cùnglast
6.3 GraphRAGGraphRAG caohighrất caovery highchỉ với câu hỏi tổng thểglobal questions onlysau cùnglast

Những lỗi lặp lạiAnti-patterns

Tám lỗi này chiếm phần lớn thời gian bị mất trong các dự án RAG.These eight account for most of the time lost on RAG projects.

  • Nhảy thẳng vào agentic hoặc GraphRAG khi chưa có hybrid và rerank.Jumping to agentic or GraphRAG before hybrid search and reranking exist.
  • Sửa prompt trong khi lỗi thật nằm ở khâu parse tài liệu.Tuning the prompt while the real bug is in document parsing.
  • Cộng thẳng điểm vector với điểm BM25 — hai thang đo khác nhau.Adding vector scores to BM25 scores — two incompatible scales.
  • Đổi model embedding mà không embed lại toàn bộ corpus.Swapping the embedding model without re-embedding the whole corpus.
  • Lọc phân quyền sau khi retrieval thay vì bên trong truy vấn.Filtering permissions after retrieval instead of inside the query.
  • Bắt đầu tối ưu khi chưa có bộ 50–100 câu hỏi để đo.Starting to optimise without a 50–100 question set to measure against.
  • Đặt timestamp hoặc tên người dùng ở đầu prompt, phá sạch cache.Putting a timestamp or user name at the top of the prompt, killing the cache.
  • Cắt ngang một chunk khi context tràn, để lại mảnh vỡ gây hiểu sai.Truncating mid-chunk on overflow, leaving a fragment that misleads the model.

Ba câu cần nhớThree things to remember

  1. RAG là bài toán search khoác áo AI. Search tệ thì không kỹ thuật prompt nào cứu được.RAG is a search problem in an AI costume. Bad search cannot be prompted away.

  2. Gỡ lỗi theo thứ tự tầng: có trong index chưa → có lọt top 50 chưa → có lọt top 5 chưa → rồi mới tới prompt.Debug in layer order: in the index → in the top 50 → in the top 5 → only then the prompt.

  3. Hybrid, rerank và viết lại truy vấn mang lại phần lớn mức cải thiện. Phần còn lại là nơi tiêu thời gian.Hybrid, reranking and query rewriting deliver most of the gain. The rest is where time goes.