Nana Casmana Ade WikartaAI Systems
Back to projects

Retrieval-Augmented Generation

Simple RAG Pipeline with LangChain

A minimal RAG pipeline that reads local documents, chunks and embeds them, retrieves relevant context, and answers questions with source citations.

Project statusDemo
PythonLangChainOpenAI EmbeddingsChromaDBLLM

Overview

A compact RAG implementation that reads .md and .txt files, splits them into chunks, generates embeddings via OpenAI, stores them in ChromaDB, retrieves relevant context for a user question, and sends the grounded prompt to a chat model. Built to demonstrate the full RAG loop without unnecessary abstraction.

Problem

Most RAG tutorials skip the practical details: chunking strategy, retrieval tuning, and how to inspect what the LLM actually received as context.

Goal

Build the simplest possible RAG pipeline that still shows the complete flow : ingestion → embedding → retrieval → generation : with observable inputs and outputs at each stage.

Architecture

  • File loader for local .md and .txt documents.
  • Recursive text splitting with configurable chunk size and overlap.
  • OpenAI embedding generation and ChromaDB storage.
  • Similarity search retrieval with top-k results.
  • LLM call with grounded context and source citations.

System Flow

Input

Documents placed in the input folder.

Process

Script loads, chunks, and embeds all documents.

AI Layer

User asks a question via CLI.

Storage/API

System retrieves top-k relevant chunks.

Review

Context + question sent to LLM.

Tech Stack

PythonLangChainOpenAI EmbeddingsChromaDBLLM

Key Features

  • Full pipeline from document folder to answer.
  • Configurable chunk size and retrieval count.
  • Printed context window for debugging.
  • Source document citation in answers.

AI / ML Component

  • OpenAI text-embedding-ada-002 for chunk embeddings.
  • Cosine similarity search for retrieval.
  • Chat completion with system prompt for grounded answering.

Data Flow

  1. 1Documents placed in the input folder.
  2. 2Script loads, chunks, and embeds all documents.
  3. 3User asks a question via CLI.
  4. 4System retrieves top-k relevant chunks.
  5. 5Context + question sent to LLM.
  6. 6Answer returned with source references.

Challenges

  • Choosing chunk size that balances detail with retrieval relevance.
  • Handling documents that span multiple topics.
  • Measuring retrieval quality without a labeled test set.

Solution / Trade-off

  • Keep the pipeline simple and readable over optimizing retrieval metrics.
  • Use OpenAI embeddings for reliability during development.
  • Print the full context window for debugging instead of hiding it.

Result

Working CLI-based RAG pipeline. Drop documents in a folder, ask questions, get grounded answers with source references.

Screenshot / Demo Placeholder

/images/simple-rag-placeholder.png

Replace this area with real screenshots, dashboard captures, architecture diagrams, or a short demo video once the asset is ready.

GitHub / Live Link Placeholder

What I Would Improve

  • Add support for PDF ingestion.
  • Add hybrid search (keyword + vector).
  • Add evaluation script for retrieval quality.