Prompt Engineering & LLM Optimization for Developers · Pelajaran

Dasar-Dasar Retrieval-Augmented Generation (RAG)

Pelajari cara RAG mendasarkan respons LLM pada dokumen Anda sendiri dengan mengambil konteks relevan saat kueri dibuat dan memasukkannya ke dalam prompt.

Pelajaran 4 dari 413 langkah

Dasar-Dasar Retrieval-Augmented Generation (RAG) adalah pelajaran Prompt Engineering & LLM Optimization for Developers gratis di CoddyKit. Ini adalah pelajaran 4 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Prompt Engineering & LLM Optimization for Developers, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Prompt Engineering & LLM Optimization for Developers mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

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.

Gratis untuk memulai

Belajar Prompt Engineering & LLM Optimization for Developers dengan tutor AI — gratis

Tulis dan jalankan kode asli di browser kamu, dapatkan bantuan instan dari tutor AI 24/7, dan lanjutkan di mana kamu tinggalkan di web atau aplikasi.

Kursus
12
Pelajaran
48

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Dasar-Dasar Retrieval-Augmented Generation (RAG)” gratis?

Ya — teks lengkap “Dasar-Dasar Retrieval-Augmented Generation (RAG)” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Prompt Engineering & LLM Optimization for Developers, upgrade ke CoddyKit PRO. Kursus Prompt Engineering & LLM Optimization for Developers mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Dasar-Dasar Retrieval-Augmented Generation (RAG)”?

Pelajari cara RAG mendasarkan respons LLM pada dokumen Anda sendiri dengan mengambil konteks relevan saat kueri dibuat dan memasukkannya ke dalam prompt. Kamu berlatih Prompt Engineering & LLM Optimization for Developers dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Prompt Engineering & LLM Optimization for Developers?

Tidak diperlukan pengalaman sebelumnya. Prompt Engineering & LLM Optimization for Developers di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 4 dari 4.

Berapa lama pelajaran “Dasar-Dasar Retrieval-Augmented Generation (RAG)” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Prompt Engineering & LLM Optimization for Developers ini?

Ya. Setiap pelajaran Prompt Engineering & LLM Optimization for Developers menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Interaksi API LLM (OpenAI, Anthropic)
  2. Dasar-Dasar LangChain dan LlamaIndex
  3. Pengelolaan dan Penerapan Versi Perintah
  4. Dasar-Dasar Retrieval-Augmented Generation (RAG)
← Kembali ke Prompt Engineering & LLM Optimization for Developers