Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG-unittesting

This repository demonstrates a basic Retrieval-Augmented Generation (RAG) pipeline using Hugging Face models and the LlamaIndex library, along with comprehensive unit tests for all major components.

Features

  • Loads documents from a Hugging Face dataset (e.g., SQuAD)
  • Embeds documents and builds a vector index
  • Retrieves relevant documents for a query
  • Generates answers using a language model
  • Includes robust unit and integration tests for the RAG workflow

Structure

  • main.py — Example script to run the RAG pipeline
  • rag_system.py — Core RAG implementation
  • test_ragsystem.py — Unit and integration tests (using unittest and unittest.mock)
  • requirements.txt — Python dependencies

Quick Start

  1. Install dependencies:
pip install -r requirements.txt
  1. Set your OpenAI API key in a .env file:
OPENAI_API_KEY=your_openai_api_key
  1. Run the example:
python main.py
  1. Run all tests:
python test_ragsystem.py

Notes

  • The RAG system uses Hugging Face models for embeddings and LLMs, and OpenAI for LLM inference.
  • All major RAG steps are covered by unit tests, including error handling.

For learning and experimentation.

About

Basic RAG on a documents dataset and unit test cases around the same

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages