- Overview
- Project Goals and Objectives
- Tech Stack
- Project Structure
- Code Structure
- Installation
- Backend Setup
- Frontend Setup
- Accessing the Backend Application
- Contributing
This project focuses on developing an enterprise-grade Retrieval-Augmented Generation (RAG) system that automates prompt generation, evaluation, and testing for Language Models (LLMs) like GPT-4. By integrating advanced prompt engineering techniques and cutting-edge tools like Pinecone and LangChain, this project aims to enhance the efficiency, effectiveness, and accessibility of LLMs in various business applications.
-
Automate Prompt Generation
- Develop a system that can automatically generate high-quality prompts based on user inputs.
-
Implement Evaluation Data Generation
- Create mechanisms to generate diverse test cases automatically for evaluating prompts.
-
Develop a Robust Prompt Testing and Ranking System
- Use methodologies like Monte Carlo matchmaking and ELO rating systems to assess and rank the generated prompts.
-
Integrate Advanced Tools like Pinecone and LangChain
- Utilize Pinecone for efficient vectorized data storage and retrieval and LangChain for seamless interaction with the RAG framework.
-
Design a User-Friendly Interface
- Create an intuitive interface for users to input objectives, generate prompts, and view evaluation results.
-
Ensure Comprehensive System Integration and Testing
- Integrate all components of the system and conduct thorough testing to ensure functionality, usability, and performance.
- Python: The core programming language used for prompt generation, evaluation, and backend logic.
- Flask: A lightweight WSGI web application framework used to build the backend and serve the user interface.
- Pinecone: A vector database used for efficient storage and retrieval of vectorized data.
- LangChain: A framework to facilitate seamless interaction with the RAG system components.
- HTML/CSS: Standard technologies used for structuring and styling the web interface.
- JavaScript: Enhances interactivity and user experience on the frontend.
- React: A JavaScript library for building user interfaces, used to create a responsive and interactive frontend.
- Jupyter Notebooks: Used for experimentation, development, and testing of various components and algorithms.
- Git: Version control system used for tracking changes and collaboration.
- Virtual Environment: Ensures a clean and isolated environment for dependency management.
automatic_prompt_engineer/
: Contains the core code for the automatic prompt engineering system.backend/
: Backend code for the project.evaluation/
: Code related to prompt evaluation.prompts/
: Code related to prompt generation.test-dataset/
: Dataset for testing the system.uploaded_docs/
: Directory for uploaded documents.utility/
: Utility scripts and functions.app.py
: Main backend application script.
data/
: Directory for storing data files.frontend/
: Frontend code for the project.notebooks/
: Jupyter notebooks for experimentation and development.rag/
: RAG system implementation.utils/
: Utility scripts.pdf_ingestion.py
: Script for ingesting PDF documents.pinecone.py
: Pinecone integration script.prompt_eng.py
: Prompt engineering script.rag.py
: RAG system script.req.py
: Script for handling requests.
promptfooconfig.yaml
: Configuration file.requirements.txt
: List of dependencies required for the project.
├── backend
│ ├── main.py # Main backend application script
│ ├── routes # API routes
│ ├── evaluation # Code related to prompt evaluation
│ ├── prompts # Code related to prompt generation
│ ├── test-dataset # Dataset for testing the system
│ ├── uploaded_docs # Directory for uploaded documents
│ ├── utility # Utility scripts and functions
│ └── app.py # Flask Entry point
├── data
│ ├── any.pdf # Raw data files
│ └──
├── frontend
│ └──src # source file directory
│ ├──App.jsx # Entry point main file
│ └──ListPrompts.jsx # used to populate List of prompts
│
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── requirements.txt # List of dependencies required for the project
├── README.md # Project documentation
├── notebooks # Jupyter notebooks for experimentation and development
├── rag # RAG system implementation
└── utils
├── pdf_ingestion.py # Script for ingesting PDF documents
├── pinecone.py # Pinecone integration script
├── prompt_eng.py # Prompt engineering script
├── rag.py # RAG system script
└── req.py # Script for handling requests
-
Clone the Repository
git clone https://github.com/dev-abuke/Precision-RAG-For_Enterprise-Grade-RAG-Systems.git PrecisionRag
-
Navigate to Directory
cd PrecisionRag
-
Set Up Environment Variables
Create a .env file in the backend directory and add your environment variables, such as Pinecone API key and other configurations.
touch .env
Then add the fo;;owing and your API key
OPENAI_API_KEY="sk-*****************************" PINECONE_API_KEY="******************************"
-
Set Up Virtual Environment
python -m venv myenv source myenv/bin/activate # On Windows use `env\Scripts\activate`
-
Navigate to the Backend Directory
cd backend
-
Run the Backend Application
flask --app app --debug run
-
Using Docker
Build the Docker Image
docker build -t backend-app .
Run the Docker Container
docker run -p 5000:5000 backend-app
-
Navigate to the Frontend Directory
cd frontend
-
Install Frontend Dependencies
npm install
-
Run the Frontend Application
npm run dev
-
Using Docker
If you prefer to run the frontend application in a Docker container, follow these steps
Build the Docker Image
docker build -t frontend-app .
Run the Docker Container:
docker run -p 3000:3000 frontend-app
Accessing the Application
- Open your browser and go to http://localhost:5173 to access the frontend application.
Open your browser and go to
http://localhost:5000
to access the backend application.
You can use tools like Postman
Thunderclient
or Curl
to send POST
requests to http://localhost:5000/generate
with a JSON payload to generate prompts.
Example JSON Payload for /generate
Endpoint
{
"question": "What is the impact of AI on social media management?"
}
API Endpoints
POST /generate
Generates prompts based on the input question and returns the evaluation scores.
We welcome contributions to this project! If you'd like to contribute, please follow these guidelines.
-
Fork the Repository
Start by forking the repository to your GitHub account. This will create a copy of the repository under your username.
-
Clone the Repository
Clone the forked repository to your local machine:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
If you encounter any issues or bugs, please open an issue on GitHub. Provide as much detail as possible to help us resolve the issue quickly.
We welcome new ideas and feature requests. If you have a suggestion for improving the project, please open an issue on GitHub and describe your idea.
See https://github.com/dev-abuke/Precision-RAG-For_Enterprise-Grade-RAG-Systems/blob/main/License.md