This project implements a RAG (Retrieval-Augmented Generation) application using the Google Gemini API. It was originally designed for OpenAI's API but has been adapted due to token limitations and system resource constraints.
Initially, this project was set up to use OpenAI's API. However, we encountered several challenges:
- OpenAI API token limitations (5000 tokens) were insufficient for this project.
- Creating the output.json file was time-consuming and caused system overheating.
- System errors occurred twice during processing.
To address these issues, we switched to the Google Gemini API, which offers a free tier with higher token limits.
- Python 3.10+
- Google Gemini API Key
-
Clone this repository:
git clone <repository-url> cd <repository-name>
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project root and add your Google Gemini API key:GOOGLE_API_KEY=your_google_gemini_api_key_here
-
Deprecated Imports: You may see warnings about deprecated imports from
langchain
. To resolve this, update the imports inrag_implementation.py
:from langchain_community.vectorstores import Chroma from langchain_community.embeddings import GooglePalmEmbeddings from langchain_community.llms import GooglePalm
-
API Key Not Found: If you encounter an error like "Did not find google_api_key", ensure that:
- Your
.env
file is in the correct location (project root). - The API key in the
.env
file is correct and properly formatted. - You're running the script from the project root directory.
- Your
-
Transcript Issues: The transcript of the one-hour video may sometimes cause issues. If you encounter problems related to the transcript, try:
- Checking the
docs/intro-to-llms-karpathy.txt
file for any formatting issues. - Splitting the transcript into smaller chunks if it's too large.
- Checking the
-
Implement the RAG system:
python rag_implementation.py
-
Generate answers to the question list:
python generate_answers.py
-
Evaluate the results:
python eval.py path/to/your/output.json
If you encounter the error "TypeError: str expected, not NoneType" when setting the API key, try modifying the rag_implementation.py
file: