Post

๐Ÿ”Š Create your own LLM RAG application in just 3 days using this hands-on roadmap crafted from the best free resources!

Build Your RAG Application in 3 Days: A Hands-On Roadmap

Curiosity: How can we build a production-ready RAG application quickly? Whatโ€™s the fastest path from basics to advanced RAG implementation?

RAG (Retrieval Augmented Generation) has emerged as an extremely popular LLM application. Its appeal lies in its lightweight design and the simplicity of integrating it with any foundational LLM.

๐Ÿ“– Complete Roadmap: https://github.com/aishwaryanr/awesome-generative-ai-guide/blob/main/resources/RAG_roadmap.md

3-Day Learning Path

gantt
    title RAG Learning Roadmap (3 Days)
    dateFormat YYYY-MM-DD
    section Day 1
    RAG Basics           :a1, 2024-01-01, 1d
    Components           :a2, after a1, 1d
    section Day 2
    Advanced RAG         :b1, 2024-01-02, 1d
    Build Application    :b2, after b1, 1d
    section Day 3
    Evaluation           :c1, 2024-01-03, 1d
    Challenges           :c2, after c1, 1d

Time Commitment: 2-3 hours per day

Day 1: Introduction to RAG

Retrieve: Understand RAG fundamentals and core components.

Learning Objectives:

  • โœ… What is Retrieval Augmented Generation?
  • โœ… Key components: Ingestion, Retrieval, Synthesis
  • โœ… Pipeline components: Chunking, Embedding, Indexing, Top-k Retrieval, Generation

Topics Covered:

TopicDescriptionKey Concepts
RAG BasicsWhat is RAG?Retrieval + Generation
IngestionData preparationDocument loading, preprocessing
RetrievalInformation retrievalVector search, similarity
SynthesisAnswer generationLLM integration, context

RAG Pipeline:

graph LR
    A[Documents] --> B[Chunking]
    B --> C[Embedding]
    C --> D[Indexing]
    D --> E[Vector DB]
    
    F[Query] --> G[Embedding]
    G --> H[Top-k Retrieval]
    E --> H
    H --> I[Synthesis]
    I --> J[Answer]
    
    style A fill:#e1f5ff
    style E fill:#fff3cd
    style I fill:#d4edda
    style J fill:#f8d7da

Key Components:

  • Chunking: Split documents into manageable pieces
  • Embedding: Convert text to vectors
  • Indexing: Store in vector database
  • Top-k Retrieval: Find most relevant chunks
  • Generation: Create answer from context

Day 2: Advanced RAG + Build Your Own System

Innovate: Learn advanced techniques and build a complete RAG application.

Learning Objectives:

  • โœ… Advanced RAG optimizations
  • โœ… Build RAG system with LangChain and OpenAI
  • โœ… Implement advanced retrieval techniques

Advanced Techniques:

TechniqueDescriptionBenefit
Self-Querying RetrievalLLM-generated queriesโฌ†๏ธ Better retrieval
Parent Document RetrieverHierarchical retrievalโฌ†๏ธ Context preservation
Hybrid SearchSemantic + keywordโฌ†๏ธ Retrieval quality
CompressorsContext compressionโฌ‡๏ธ Token usage
HyDEHypothetical documentsโฌ†๏ธ Query understanding

Building RAG System:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Example: Building RAG with LangChain
from langchain.vectorstores import Chroma
from langchain.embeddings import OpenAIEmbeddings
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI

# 1. Load and chunk documents
from langchain.text_splitter import RecursiveCharacterTextSplitter
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
documents = text_splitter.split_documents(load_documents())

# 2. Create embeddings and vector store
embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(documents, embeddings)

# 3. Create retrieval chain
qa_chain = RetrievalQA.from_chain_type(
    llm=OpenAI(),
    chain_type="stuff",
    retriever=vectorstore.as_retriever(search_kwargs={"k": 3})
)

# 4. Query
result = qa_chain.run("What is RAG?")
print(result)

Advanced RAG Architecture:

graph TB
    A[Query] --> B[Query Rewriting]
    B --> C[Hybrid Search]
    C --> D[Semantic Search]
    C --> E[Keyword Search]
    D --> F[Retrieval]
    E --> F
    F --> G[Re-ranking]
    G --> H[Context Compression]
    H --> I[LLM Generation]
    I --> J[Answer]
    
    style A fill:#e1f5ff
    style C fill:#fff3cd
    style I fill:#d4edda
    style J fill:#f8d7da

Day 3: RAG Evaluation and Challenges

Retrieve: Learn how to evaluate RAG systems and address common challenges.

Learning Objectives:

  • โœ… Evaluation metrics (TruEra, RAGas)
  • โœ… RAG pain points and solutions
  • โœ… Production best practices

Evaluation Metrics:

MetricFrameworkPurpose
FaithfulnessRAGasFactual accuracy
Answer RelevancyRAGasAnswer quality
Context PrecisionRAGasRetrieval quality
Context RecallRAGasCoverage
TruEra MetricsTruEraComprehensive evaluation

Evaluation Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from ragas import evaluate
from datasets import Dataset

# Prepare evaluation dataset
dataset = Dataset.from_dict({
    "question": ["What is RAG?"],
    "contexts": [["RAG is retrieval augmented generation..."]],
    "answer": ["RAG combines retrieval and generation..."],
    "ground_truth": ["RAG is a technique that..."]
})

# Evaluate
results = evaluate(
    dataset=dataset,
    metrics=["faithfulness", "answer_relevancy", "context_precision"]
)
print(results)

Common RAG Challenges:

ChallengeDescriptionSolution
Poor RetrievalIrrelevant contextBetter embeddings, hybrid search
Context WindowLimited tokensCompression, summarization
HallucinationIncorrect factsBetter retrieval, fact-checking
LatencySlow responsesCaching, optimization
ScalabilityLarge datasetsEfficient indexing, sharding

Complete Roadmap Structure

graph TB
    A[3-Day RAG Roadmap] --> B[Day 1: Basics]
    A --> C[Day 2: Advanced + Build]
    A --> D[Day 3: Evaluation]
    
    B --> B1[RAG Introduction]
    B --> B2[Components]
    B --> B3[Pipeline]
    
    C --> C1[Advanced Techniques]
    C --> C2[Build System]
    C --> C3[LangChain + OpenAI]
    
    D --> D1[Evaluation Metrics]
    D --> D2[Challenges]
    D --> D3[Solutions]
    
    E[Optional Resources] --> A
    F[Research Papers] --> A
    
    style A fill:#e1f5ff
    style B fill:#fff3cd
    style C fill:#d4edda
    style D fill:#f8d7da

Additional Resources

Optional Reading:

  • RAG research papers
  • Advanced techniques
  • Best practices
  • Case studies

2024 RAG Research Papers:

  • Latest RAG improvements
  • Novel architectures
  • Evaluation methods
  • Production deployments

Key Takeaways

Retrieve: This 3-day roadmap provides a structured path from RAG basics to building and evaluating production-ready applications.

Innovate: By following this roadmap, youโ€™ll learn advanced RAG techniques, build your own system, and understand how to evaluate and optimize RAG applications.

Curiosity โ†’ Retrieve โ†’ Innovation: Start with curiosity about RAG, retrieve knowledge through the structured roadmap, and innovate by building your own RAG applications.

Next Steps:

  • Follow the 3-day roadmap
  • Build your RAG system
  • Evaluate and optimize
  • Deploy to production

 3 Day RAG Roadmap

Translate to Korean

RAG(Retrieval Augmented Generation)๋Š” LLM ๋ถ„์•ผ์—์„œ ๋งค์šฐ ์ธ๊ธฐ ์žˆ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ๋ถ€์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

์ด ๊ฒŒ์ž„์˜ ๋งค๋ ฅ์€ ๊ฒฝ๋Ÿ‰ ์„ค๊ณ„์™€ ๊ธฐ๋ณธ LLM๊ณผ ํ†ตํ•ฉํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์ ์— ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ’ก ์ด 3์ผ ๊ฐ€์ด๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ RAG์˜ ์ง„ํ™”ํ•˜๋Š” ํ™˜๊ฒฝ๊ณผ ์ตœ์‹  ๊ฐœ๋ฐœ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์„ธ์š”! ๋งค์ผ 2-3 ์‹œ๊ฐ„์„ ์ž์›์— ํˆฌ์žํ•˜์‹ญ์‹œ์˜ค.

๐Ÿฅ ๊ธฐ๋ณธ ์‚ฌํ•ญ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ ๊ณ ๊ธ‰ ์•„์ด๋””์–ด๋กœ ์ด๋™ํ•˜๊ณ , LangChain์„ ์‚ฌ์šฉํ•˜์—ฌ ์•ฑ์„ ๋นŒ๋“œํ•˜๊ณ , ํ‰๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. ๋˜ํ•œ ์ด ๋ถ„์•ผ์˜ ์ตœ์‹  ์—ฐ๊ตฌ๋ฅผ ๋”ฐ๋ผ์žก์„ ์ˆ˜ ์žˆ๋Š” ๋ฆฌ์†Œ์Šค๋„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

โ›ณ 1์ผ์ฐจ: RAG ์†Œ๊ฐœ

  • ๐Ÿ‘‰ ๊ฒ€์ƒ‰ ์ฆ๊ฐ• ์ƒ์„ฑ์ด๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?
  • ๐Ÿ‘‰ RAG์˜ ํ•ต์‹ฌ ๊ตฌ์„ฑ ์š”์†Œ: Ingestion, Retrieval, Synthesis
  • ๐Ÿ‘‰ RAG ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์„ฑ ์š”์†Œ: ์ฒญํฌ, ์ž„๋ฒ ๋”ฉ, ์ธ๋ฑ์‹ฑ, Top-k ๊ฒ€์ƒ‰ ๋ฐ ์ƒ์„ฑ

โ›ณ 2์ผ์ฐจ: ๊ณ ๊ธ‰ RAG + ๋‚˜๋งŒ์˜ RAG ์‹œ์Šคํ…œ ๊ตฌ์ถ•ํ•˜๊ธฐ

  • ๐Ÿ‘‰ ๊ณ ๊ธ‰ RAG ์ตœ์ ํ™”: Self Querying Retrieval, Parent Document ๐Ÿ‘‰ Retriever, Hybrid Search, Compressors, HyDE ๋“ฑ
  • ๐Ÿ‘‰ LangChain ๋ฐ OpenAI๋กœ ์ž์ฒด RAG ์‹œ์Šคํ…œ ๊ตฌ์ถ• ๊ณ ๊ธ‰ RAG ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๊ตฌ์ถ•์„ ์œ„ํ•œ ๋ฆฌ์†Œ์Šค

โ›ณ3์ผ์ฐจ: RAG ํ‰๊ฐ€ ๋ฐ ๊ณผ์ œ

  • ๐Ÿ‘‰TruEra ๋ฐ RAGas์—์„œ ์ผ๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ํ‰๊ฐ€ ์ง€ํ‘œ
  • ๐Ÿ‘‰RAG์˜ ๋ฌธ์ œ์  ๋ฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

๐Ÿฅ๐Ÿฅ๋กœ๋“œ๋งต์—๋Š” ๋‹ค์Œ ๋‚ด์šฉ๋„ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค: Optional Reading Resources & Top 2024 RAG research papers

This post is licensed under CC BY 4.0 by the author.