Skip to content
mat-mgmPublic

About

A dual-implementation Retrieval-Augmented Generation (RAG) system demonstrating different approaches to document processing and question answering.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

Repository files navigation

local-rag

Two Retrieval-Augmented Generation (RAG) pipelines that run entirely locally via Ollama — no cloud APIs required. Built as the final project for a Natural Language Processing course.

Pipelines

1. Simple RAG (simple_rag.py)

A from-scratch implementation with no RAG framework — manual cosine similarity, in-memory vector database, and direct Ollama API calls. Good for understanding how RAG works at the component level.

  • Processes panda-facts.txt line-by-line as chunks
  • Custom cosine similarity retrieval
  • Streamed response output

Run:

ollama pull hf.co/CompendiumLabs/bge-base-en-v1.5-gguf
ollama pull hf.co/bartowski/Llama-3.2-1B-Instruct-GGUF
python simple_rag.py

2. Library RAG (lib_rag.py)

A production-oriented pipeline built on LangChain. Ingests PDF, DOCX, TXT and Markdown documents, splits them into chunks, embeds them with HuggingFace models, and indexes them in a persistent FAISS vector store.

  • Multi-format document loading (PDF, DOCX, TXT, Markdown)
  • Recursive character chunking
  • FAISS persistent vector store (Chroma supported but experimental)
  • Configurable via a central config dict at the top of the file
  • HuggingFace embeddings + Ollama or HuggingFace inference

Run:

pip install -r requirements.txt
# Place PDF/DOCX/TXT files in inputs/
python lib_rag.py

Sample animal care documents from Wild Welfare are included in inputs/.

Repository Structure

├── simple_rag.py       # From-scratch RAG implementation
├── panda-facts.txt     # Sample dataset for simple_rag
├── lib_rag.py          # LangChain-based pipeline
├── requirements.txt    # Dependencies for lib_rag
├── inputs/             # Sample PDFs for lib_rag
├── demo/               # Standalone demo using llama.cpp directly
├── docs/               # Report and final presentation
└── docs/concepts.md    # RAG glossary and reference links

Prerequisites

  • Python 3.10+
  • Ollama installed and running locally

About

A dual-implementation Retrieval-Augmented Generation (RAG) system demonstrating different approaches to document processing and question answering.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages