0Pricing
NLP Academy · Lektion

Retrieval in den Prompt einbinden

Mit fundiertem und belegtem Kontext antworten

Retrieval in den Prompt einbinden ist eine kostenlose NLP Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des NLP Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der NLP Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Putting the Pieces Together

You can retrieve relevant chunks and call an LLM. Now you connect them: feed the retrieved text into the prompt as context.

The Augmented Prompt

A RAG prompt has three parts: an instruction, the retrieved context, and the user question. The model reads all three together.

Joining the Retrieved Chunks

First stitch your top chunks into one block of text. A blank line between them keeps each passage readable to the model.

context = "\n\n".join(hits)

Building the Prompt String

Wrap the context and question in clear labels. A simple template tells the model exactly what to use and what to answer.

prompt = f"Context:\n{context}\n\nQuestion: {question}\nAnswer:"

Telling the Model to Stay Grounded

Add an instruction to answer only from the context. This curbs hallucination and keeps the response tied to your sources.

Handling Unknown Answers

Tell the model to say it does not know when the context is silent. Allowing I do not know beats a confident wrong guess.

Sending It to the LLM

Pass the assembled prompt to your model call. The LLM now answers using your retrieved context, not just its training.

answer = llm(prompt)

Showing the Sources

Return the chunks you used alongside the answer. These citations let users verify the claim and build trust.

Watch the Context Length

Too many chunks overflow the context window. Keep k small and trim long passages so the prompt fits the model budget.

A Minimal RAG Function

The full flow is tiny: embed, search, build prompt, generate. This one function captures an entire RAG pipeline.

def rag(q):
    hits = retrieve(q)
    return llm(build_prompt(hits, q))

Improving Retrieval Quality

If answers are weak, the fix is usually retrieval, not the LLM. Better chunks and re-ranking raise quality more than a bigger model.

Quick Check

Think about what goes into a RAG prompt.

Recap

You join retrieved chunks into context, build an instruction-plus-question prompt, generate a grounded answer, and show sources. ✅

Häufig gestellte Fragen

Ist die Lektion „Retrieval in den Prompt einbinden“ kostenlos?

Ja — der vollständige Text von „Retrieval in den Prompt einbinden“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des NLP Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der NLP Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Retrieval in den Prompt einbinden“?

Mit fundiertem und belegtem Kontext antworten Du übst NLP Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um NLP Academy zu starten?

Keine Vorkenntnisse erforderlich. NLP Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Retrieval in den Prompt einbinden“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser NLP Academy-Lektion Code schreiben und ausführen?

Ja. Jede NLP Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Warum LLMs Retrieval benötigen
  2. Dokumente aufteilen und Embeddings erstellen
  3. Vektorsuche mit einem Vector Store
  4. Retrieval in den Prompt einbinden
← Zurück zu NLP Academy