Skip to content
Amresh Verma edited this page May 28, 2026 · 52 revisions
  • Prompt Engineering
  • RAG (Retrieval Augmented Generation)
  • Embeddings + Vector
  • DB Function Calling / Tools
🧠

1. Prompt Engineering

📌 What is it?

Writing smart input (prompt) to get correct output from LLM

🎯 Example

❌ Bad Prompt: Tell me about milk

✅ Good Prompt: You are a shop assistant.

Extract product name and quantity: Input: "2 milk and 1 bread"

Output JSON:

👉 Output becomes structured:

{ "milk": 2, "bread": 1 }

🧠

2. RAG (Retrieval Augmented Generation)

Overview

Retrieval-Augmented Generation (RAG) is an AI architecture that enhances large language models (LLMs) by allowing them to retrieve relevant external information before generating a response.

Instead of relying only on pre-trained knowledge, RAG enables models to access up-to-date, domain-specific, and private data sources, making responses more accurate and context-aware.

RAG is widely used in:

  • Customer support chatbots
  • Healthcare report summarization
  • Legal and compliance systems
  • Financial analysis tools
  • Enterprise knowledge search systems

Why RAG is Important

Traditional LLMs like GPT-style models generate responses based only on training data. This creates limitations:

Limitations of standard LLMs

  • Knowledge cutoff (no real-time updates)
  • Hallucinations (false or made-up answers)
  • No access to private company data
  • Lack of personalization/context
Screenshot 2026-05-28 at 12 31 42 PM

RAG solves these problems by:

  • Fetching real-time relevant data
  • Grounding answers in actual documents
  • Reducing hallucinations
  • Keeping knowledge updated without retraining

Real-Life Example

Imagine two students preparing for an exam:

Student 1 (LLM only)

  • Reads books once
  • Answers from memory only
  • Cannot verify facts
Screenshot 2026-05-28 at 1 51 20 PM

Student 2 (RAG system)

  • Reads books
  • Can open books during exam
  • Verifies answers in real-time
Screenshot 2026-05-28 at 1 51 20 PM

Student 2 performs better because they can retrieve information when needed.

Key Benefits of RAG

  1. Reduces Hallucination

    LLMs generate more factual and grounded responses. Some LLM is more overconfitent 
    and giving wrong response. In LLM we can not verified data but in RAG we can verified
    then respose will be more grounded and real data.
    
  2. Keeps Knowledge Updated

     Works with real-time and dynamic data sources. In LLM there is a knowlege cutoff date 
     mean till training date all info present. But by using RAG we can use current data or uptodate.
    
  3. Cost Efficient

     Avoids expensive retraining or fine-tuning of models mean new data then we can give access 
     by using RAG without training and finetuning.
    
  4. Data Privacy

    Sensitive enterprise data stays within controlled systems. Becuase our not access whole data same time for particular query 
    it is fetching/access only data. Suppose big company do not want to give full access to model. So he can control by using 
    RAG.
    
  5. Context Awareness

    Personalized responses using user-specific data.
    

Example:

     Airline chatbot knows your booking details (PNR, flight time, delay status)
🧠

RAG Architecture Overview

RAG consists of two major pipelines:

1. Ingestion Pipeline

This prepares data for retrieval.

Steps:

  • Data Collection
    • PDFs
    • Web pages
    • Databases
    • Excel files
    • APIs
  • Chunking
    • Large documents are split into smaller pieces (chunks)

Types of chunking:

  • Fixed-size chunking
  • Hierarchical chunking
  • Semantic chunking
  • Embedding Generation
  • Text is converted into numerical vectors using embedding models.

Popular embedding tools:

  • OpenAI Embeddings
  • Google Gemini Embeddings
  • Sentence Transformers (Hugging Face)
  • Vector Database Storage
  • Embeddings are stored in vector databases such as:
  • Pinecone
  • ChromaDB
  • FAISS
  • Elasticsearch

Vector databases enable semantic search (meaning-based search), not just keyword matching.

Screenshot 2026-05-28 at 2 38 11 PM

Clone this wiki locally