RAG nedir, neden kritik?
Retrieval-Augmented Generation (RAG), LLM'in cevabını external knowledge ile zenginleştiren pattern. Vanilla LLM yalnız eğitildiği bilgiyle çalışır; RAG ile güncel, domain-specific, müşteri-özel data dahil edilir. AIOR projelerinde LLM uygulamalarının %70'i RAG kullanıyor — hallucination'ı azaltır, knowledge'ı güncel tutar.RAG mimari
Tipik RAG akışı:- 1. Document ingestion — kaynak belgeleri DB'ye yükle.
- 2. Chunking — belgeleri küçük parçalara böl.
- 3. Embedding — her chunk'ı vector'e çevir.
- 4. Storage — vector'leri DB'de tut.
- 5. Query — kullanıcı sorgusunu vector'e çevir.
- 6. Search — DB'de en benzer chunk'ları bul.
- 7. Augmented prompt — chunk'ları context olarak prompt'a ekle.
- 8. Generation — LLM cevap üretir.
Vector store seçimi
AIOR projelerinde tercih ettiğimiz vector store'lar:- pgvector — PostgreSQL extension. AIOR'ın varsayılan tercihi — mevcut PostgreSQL infrastructure'ı yeterli.
- Pinecone — managed service, scale gerektiren projeler.
- Qdrant — open-source, self-hosted güçlü.
- Weaviate — hybrid search desteği iyi.
- Milvus — büyük scale, complex setup.
Çoğu AIOR projesi için pgvector yeterli; ayrı altyapı operational overhead'i değer.
Chunking strategy — en kritik karar
Belgeleri nasıl bölersiniz? RAG kalitesinin %50'si burada.- Fixed size — 500 token gibi sabit boyut. Basit ama anlamsal sınırları kırar.
- Sentence-based — cümle sınırlarında böl. Daha temiz ama context dağılır.
- Paragraph-based — paragraf sınırı. Genelde iyi denge.
- Semantic chunking — anlamsal değişim noktalarında böl (LLM ile). En akıllı ama maliyetli.
- Hierarchical — büyük chunk + küçük chunk'ler birlikte. Layered search.
AIOR'da paragraph-based + overlap (%10-20) standart başlangıç; complex domain'lerde semantic chunking.
Embedding model seçimi
Modern embedding model'leri:- OpenAI text-embedding-3-large — yüksek kalite, $$.
- Cohere embed v3 — multilingual güçlü.
- Voyage AI — domain-specific (legal, code).
- Local models — Sentence-Transformers, BGE — self-hosted, free.
AIOR projelerinde varsayılan: production'da OpenAI veya Cohere; sensitive data ve self-hosted gereksinim ise BGE-M3 (multilingual).
Hybrid search — semantic + keyword
Pure semantic search bazı sorguları kaçırır (rare terms, ürün kodları). Hybrid search semantic + BM25 (keyword) kombinasyonu. AIOR projelerinde hybrid search standart — her ikisinin sonuçları reciprocal rank fusion ile birleştirilir.Reranking — retrieval kalitesini artırma
Initial retrieval top 20-50 chunk getirebilir. Reranking model bu sonuçları daha doğru sıralar:- Cohere Rerank — managed, kolay.
- Cross-encoder modeller — self-hosted, BGE-Reranker.
- LLM-based reranking — model her chunk'ın relevance'ını puanlar (maliyetli).
AIOR'da production'da BGE-Reranker tercih ediyoruz — maliyet/kalite oranı iyi.
Citation ve attribution
RAG cevabının hangi belgeden geldiğini göstermek kritik. AIOR'da output formatı:
Code:
Cevap: [LLM yanıtı]
Kaynaklar:
- Doküman A, sayfa 3
- Doküman B, paragraf 12
Bu yapı kullanıcı doğruluğu doğrulayabilsin diye. Hallucination'ı da azaltıyor — model uydurma yapamaz, kaynak göstermek zorunda.
Eval — RAG kalitesi nasıl ölçülür?
RAG eval iki boyutlu:- Retrieval quality — doğru chunk getirildi mi? (precision, recall, MRR).
- Generation quality — chunk'lar verildiğinde LLM doğru cevap üretti mi?
RAGAS, TruLens gibi framework'ler bu metric'leri otomatikleştiriyor. AIOR projelerinde RAGAS standart eval framework.
Document ingestion pipeline
RAG sürekli güncellenen knowledge'a ihtiyaç duyar:- Scheduled crawl (web pages, docs).
- File watch (S3 bucket, dropbox).
- Manual upload (admin UI).
- Webhook (kaynak sistemden push).
AIOR projelerinde her ingestion event'inde delta processing — sadece değişen belgeler re-embed edilir.
Sonuç
RAG 2026'da LLM uygulamalarının knowledge backbone'u. Doğru vector store, akıllı chunking, hybrid search + reranking, ve disiplinli eval ile high-quality retrieval kurulabilir. AIOR olarak müşteri RAG projelerinde bu pattern'leri standart paket halinde teslim ediyoruz. Sizin RAG sisteminizde en zorlandığınız nokta ne — chunking strategy, retrieval relevance, yoksa fresh data ingestion mı?What is RAG and why is it critical?
Retrieval-Augmented Generation (RAG) is the pattern of enriching an LLM's answer with external knowledge. Vanilla LLMs work only with their training data; RAG injects current, domain-specific, customer-specific data. 70% of LLM applications on AIOR projects use RAG — it reduces hallucination and keeps knowledge current.RAG architecture
Typical RAG flow:- 1. Document ingestion — load source documents into DB.
- 2. Chunking — split documents into small pieces.
- 3. Embedding — convert each chunk to a vector.
- 4. Storage — keep vectors in DB.
- 5. Query — convert user query to vector.
- 6. Search — find the most similar chunks in DB.
- 7. Augmented prompt — add chunks as context to the prompt.
- 8. Generation — LLM produces an answer.
Vector store selection
Vector stores we prefer on AIOR projects:- pgvector — PostgreSQL extension. AIOR's default — existing PostgreSQL infrastructure suffices.
- Pinecone — managed service, projects requiring scale.
- Qdrant — open-source, strong self-hosted.
- Weaviate — strong hybrid search support.
- Milvus — large scale, complex setup.
For most AIOR projects, pgvector suffices; a separate infrastructure isn't worth the operational overhead.
Chunking strategy — the most critical decision
How you split documents accounts for 50% of RAG quality.- Fixed size — fixed size like 500 tokens. Simple but breaks semantic boundaries.
- Sentence-based — split on sentence boundaries. Cleaner but context fragments.
- Paragraph-based — paragraph boundaries. Usually good balance.
- Semantic chunking — split at semantic change points (LLM-driven). Smartest but costly.
- Hierarchical — large chunks + small chunks together. Layered search.
Paragraph-based + 10-20% overlap is AIOR's standard starting point; semantic chunking for complex domains.
Embedding model selection
Modern embedding models:- OpenAI text-embedding-3-large — high quality, $$.
- Cohere embed v3 — strong multilingual.
- Voyage AI — domain-specific (legal, code).
- Local models — Sentence-Transformers, BGE — self-hosted, free.
Default on AIOR projects: OpenAI or Cohere in production; BGE-M3 (multilingual) when sensitive data needs self-hosting.
Hybrid search — semantic + keyword
Pure semantic search misses some queries (rare terms, product codes). Hybrid search combines semantic + BM25 (keyword). Hybrid search is standard on AIOR projects — results are merged via reciprocal rank fusion.Reranking — improving retrieval quality
Initial retrieval can bring 20-50 chunks. A reranking model orders them more accurately:- Cohere Rerank — managed, easy.
- Cross-encoder models — self-hosted, BGE-Reranker.
- LLM-based reranking — model scores each chunk's relevance (costly).
In production we prefer BGE-Reranker at AIOR — good cost/quality ratio.
Citation and attribution
Showing which document a RAG answer came from is critical. Output format at AIOR:
Code:
Answer: [LLM response]
Sources:
- Document A, page 3
- Document B, paragraph 12
This lets the user verify accuracy. It also reduces hallucination — the model can't fabricate; it must cite sources.
Eval — how is RAG quality measured?
RAG eval is two-dimensional:- Retrieval quality — was the right chunk fetched? (precision, recall, MRR).
- Generation quality — given the chunks, did the LLM produce the right answer?
Frameworks like RAGAS and TruLens automate these metrics. RAGAS is our standard eval framework on AIOR projects.
Document ingestion pipeline
RAG needs continuously updated knowledge:- Scheduled crawl (web pages, docs).
- File watch (S3 bucket, Dropbox).
- Manual upload (admin UI).
- Webhook (push from source system).
On AIOR projects, delta processing runs on every ingestion event — only changed documents re-embed.