RAG for Competitive Programming (rag_4_cpr) is a Retrieval-Augmented Generation (RAG) system designed to assist with solving competitive programming problems efficiently. The project aims to combine retrieval-based techniques with advanced LLM reasoning to deliver optimal solutions.
The dataset is sourced from Project Euler (https://projecteuler.net/archives), specifically using the first 100 problems and solutions. Shout out to the Project Euler community for their exceptional resources.
- NVIDIA NIM API (https://build.nvidia.com/explore/discover): Used to integrate the meta/llama3-8b-instruct foundation model for generating responses.
- SQLite3: Database
cpr.db
is used to store problem-solution pairs, facilitating scalability through the pipeline in./problems/main.py
. - Hugging Face: Embedding generation with the
intfloat/e5-large-v2
model. - Chroma Vector Store: Manages embeddings for retrieval tasks.
- LangChain: Facilitates prompt engineering, LLM integration, and retrieval workflows.
- Retrieve problem-solution pairs from the
problem_solution
table incpr.db
. - Format the data into a list of dictionaries, each containing an ID and combined problem-solution text.
- Generate embeddings using the Hugging Face
intfloat/e5-large-v2
model. - Initialize a Chroma vector store with the embeddings and associate metadata for problem retrieval.
- Employ a custom prompt template to guide the meta/llama3-8b-instruct model to provide concise, performance-focused solutions.
Below is an example output, showcasing the system's reasoning and selected solutions.