Prompt Engineering & LLM Optimization for Developers · Aula

Fundamentos da Geração Aumentada por Recuperação (RAG)

Aprenda como o RAG fundamenta respostas de LLM em seus próprios documentos, recuperando contexto relevante no momento da consulta e inserindo-o no prompt.

Aula 4 de 413 etapas

Fundamentos da Geração Aumentada por Recuperação (RAG) é uma aula grátis de Prompt Engineering & LLM Optimization for Developers no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Prompt Engineering & LLM Optimization for Developers, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Prompt Engineering & LLM Optimization for Developers inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

The Knowledge Gap

An LLM only knows what it was trained on. It cannot answer questions about your private docs or recent events. RAG (Retrieval-Augmented Generation) closes this gap by fetching relevant text and putting it in the prompt.

The Core Idea

Instead of fine-tuning the model on your data, you retrieve the most relevant snippets at query time and let the model answer using them as context. Cheaper, faster to update, and easy to cite.

Step 1: Chunking

Documents are split into small chunks (a few hundred tokens each). Chunks small enough to be precise, large enough to keep meaning.

chunks = split(document, size=500, overlap=50)

Step 2: Embeddings

Each chunk is converted to a vector with an embedding model. Similar meanings produce nearby vectors, enabling semantic search.

vector = embed("Refunds are processed in 5 days.")
// -> [0.012, -0.43, 0.88, ...]

Step 3: The Vector Store

Vectors are saved in a vector database like Pinecone, Weaviate, or pgvector. It supports fast nearest-neighbor search over millions of chunks.

Step 4: Retrieve at Query Time

When a user asks a question, you embed the question and find the top-k most similar chunks.

q = embed(userQuestion);
results = store.search(q, topK=4);

Step 5: Augment the Prompt

The retrieved chunks are inserted into the prompt as context, and the model is told to answer using only that context.

Use only the context below to answer.
Context:
{retrieved_chunks}
Question: {user_question}

Grounding and Citations

Because the answer is built from real chunks, you can show citations back to the source documents, and you can instruct the model to say I do not know when the context lacks the answer.

Why Not Just Fine-Tune?

  • RAG updates instantly: change a doc, re-index, done.
  • Fine-tuning is slow and bakes knowledge in.
  • RAG gives traceable sources; fine-tuning does not.

Common RAG Problems

Poor chunking, weak embeddings, or retrieving too few chunks all hurt quality. If answers are wrong, inspect what was retrieved first; the issue is usually retrieval, not the model.

Improving Retrieval

  • Add overlap between chunks.
  • Use hybrid keyword + vector search.
  • Re-rank results with a cross-encoder.
  • Tune top-k for your context window.

Quick Check

Test your understanding of RAG.

Recap

RAG chunks documents, embeds them into a vector store, retrieves the most relevant chunks for each query, and augments the prompt. It grounds answers, enables citations, and stays current without retraining.

Grátis para começar

Aprenda Prompt Engineering & LLM Optimization for Developers com um tutor de IA — grátis

Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.

Cursos
12
Aulas
48

Perguntas Frequentes

A aula “Fundamentos da Geração Aumentada por Recuperação (RAG)” é grátis?

Sim — o texto completo de “Fundamentos da Geração Aumentada por Recuperação (RAG)” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Prompt Engineering & LLM Optimization for Developers, atualize para CoddyKit PRO. O curso de Prompt Engineering & LLM Optimization for Developers inclui 4 aulas no total.

O que vou aprender em “Fundamentos da Geração Aumentada por Recuperação (RAG)”?

Aprenda como o RAG fundamenta respostas de LLM em seus próprios documentos, recuperando contexto relevante no momento da consulta e inserindo-o no prompt. Você pratica Prompt Engineering & LLM Optimization for Developers com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Prompt Engineering & LLM Optimization for Developers?

Nenhuma experiência prévia é necessária. Prompt Engineering & LLM Optimization for Developers no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Fundamentos da Geração Aumentada por Recuperação (RAG)”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Prompt Engineering & LLM Optimization for Developers?

Sim. Cada aula de Prompt Engineering & LLM Optimization for Developers inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Interação com APIs de LLMs (OpenAI, Anthropic)
  2. Fundamentos de LangChain e LlamaIndex
  3. Gerenciamento e controle de versões de prompts
  4. Fundamentos da Geração Aumentada por Recuperação (RAG)
← Voltar para Prompt Engineering & LLM Optimization for Developers