0Pricing
LangChain / RAG / Vector DBs · Ders

Üst Belge ve Cümle Penceresiyle Alma

Aradığınız parçaları döndürdüğünüz parçalardan ayırarak LLM'nin zengin bağlamla kesin eşleşmeler almasını sağlayın.

Üst Belge ve Cümle Penceresiyle Alma, CoddyKit'te ücretsiz bir LangChain / RAG / Vector DBs dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, LangChain / RAG / Vector DBs öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. LangChain / RAG / Vector DBs kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

The Chunk-Size Dilemma

Small chunks search precisely but lack context; large chunks give context but dilute relevance. Parent document retrieval resolves this tension by searching small and returning large.

Two Chunk Sizes

Index small child chunks for accurate similarity matching, but keep a link to the larger parent chunk that surrounds each one.

  • Search on child embeddings
  • Return parent text to the LLM

ParentDocumentRetriever

LangChain provides a ready-made retriever. You give it a child splitter, an optional parent splitter, a vector store, and a doc store for the parents.

from langchain.retrievers import ParentDocumentRetriever

retriever = ParentDocumentRetriever(
    vectorstore=vectorstore,
    docstore=store,
    child_splitter=child_splitter,
    parent_splitter=parent_splitter,
)

Adding Documents

The retriever splits each document into parents and children, embeds the children, and stores parents keyed by id so they can be fetched on a hit.

retriever.add_documents(docs)
results = retriever.invoke("What is the refund window?")
print(len(results[0].page_content))  # large parent text

Sentence-Window Retrieval

A variant indexes single sentences but, on retrieval, expands each hit to include the surrounding sentences. The model sees the exact match plus neighbors.

Storing the Window

During indexing you save the neighboring text in metadata so it can be stitched back at query time.

doc.metadata["window"] = " ".join(
    sentences[max(0, i-2): i+3]
)
doc.page_content = sentences[i]

Swapping Content After Search

After similarity search returns the matched sentence, replace its content with the stored window before passing it to the LLM.

for r in results:
    r.page_content = r.metadata["window"]

When to Use Each

Parent document suits structured docs with natural sections. Sentence-window suits dense prose where precise sentences matter most.

Avoiding Duplicate Parents

Multiple child hits can map to the same parent. Deduplicate by parent id so the LLM is not handed the same passage twice.

seen = set()
unique = []
for d in results:
    pid = d.metadata["parent_id"]
    if pid not in seen:
        seen.add(pid)
        unique.append(d)

Cost and Context Limits

Returning larger parents consumes more of the LLM context window. Balance the parent size against your token budget and the number of results k.

Putting It Together

Index fine-grained children, retrieve precisely, then expand to parents or windows. Your generation step receives focused yet contextual passages.

docs = retriever.invoke("cancellation terms")
context = "\n\n".join(d.page_content for d in docs)
answer = llm.invoke(f"Context:\n{context}\n\nQuestion: ...")

Quick Check

Test your understanding of decoupled retrieval.

Recap

You learned to decouple search and return units:

  • Parent document: search children, return parents
  • Sentence-window: match sentences, expand to neighbors
  • Deduplicate parents and watch context limits

Sıkça Sorulan Sorular

“Üst Belge ve Cümle Penceresiyle Alma” dersi ücretsiz mi?

Evet — “Üst Belge ve Cümle Penceresiyle Alma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve LangChain / RAG / Vector DBs kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. LangChain / RAG / Vector DBs kursu toplamda 4 dersten oluşur.

“Üst Belge ve Cümle Penceresiyle Alma” dersinde ne öğreneceğim?

Aradığınız parçaları döndürdüğünüz parçalardan ayırarak LLM'nin zengin bağlamla kesin eşleşmeler almasını sağlayın. LangChain / RAG / Vector DBs ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

LangChain / RAG / Vector DBs öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te LangChain / RAG / Vector DBs, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Üst Belge ve Cümle Penceresiyle Alma” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu LangChain / RAG / Vector DBs dersinde kod yazıp çalıştırabilir miyim?

Evet. Her LangChain / RAG / Vector DBs dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Çoklu Sorgu Alma Stratejileri
  2. LLM'lerle Bağlamsal Sıkıştırma
  3. Birleşik Arama ve Yeniden Sıralama
  4. Üst Belge ve Cümle Penceresiyle Alma
← LangChain / RAG / Vector DBs Sayfasına Dön