A simple yet powerful implementation of Retrieval-Augmented Generation (RAG) using Python, Langchain, and AWS Bedrock. This demo project showcases how to create a local RAG system using AWS Titan models and PostgreSQL as a vector database.
RAG is a machine learning architecture that combines information retrieval with language generation. It retrieves relevant documents from a knowledge base to generate more accurate and context-aware responses.
Embeddings are numerical representations of text data in a high-dimensional space. They capture semantic meaning and relationships between words and documents, enabling efficient similarity searches.
A specialized database designed to store and query vector embeddings. It enables fast similarity searches and is crucial for RAG systems to retrieve relevant documents efficiently.
A component in RAG systems that uses embeddings to find the most relevant documents from a knowledge base based on user queries.
This demo project implements a RAG system specifically for the UNO board game. It allows users to ask questions about UNO game rules and receive accurate answers based on the game's documentation.
- Python 3.11 or higher
- AWS CLI
- AWS Credentials configured in
~/.aws/credentials
- AWS Bedrock with access to Titan models
- PostgreSQL database
- Install UV package manager:
pip install uv
- Install pre-commit hooks:
uv run pre-commit install
- Set up your environment variables:
Create a
.env
file based on.env.template
with the following variables:
- Database configuration
- AWS Bedrock model configurations
- Initialize the PostgreSQL database: We use docker-compose to run the database.
docker compose up -d
The project uses the following key dependencies:
langchain
: For building the RAG pipelinelangchain-aws
: For AWS Bedrock integrationpgvector
: For PostgreSQL vector storage
- Load your UNO game rules PDF into the system
- Ask questions about UNO game rules
- The system will retrieve relevant sections from the PDF and generate accurate answers
- Using
uv
(local development):
uv run src/uno_game/main.py


- Embedding Model:
amazon.titan-embed-text-v1
- Language Model:
amazon.titan-text-express-v1
The project uses:
black
for code formattingpre-commit
for code quality checks
MIT License