A flexible, production-ready Retrieval-Augmented Generation (RAG) pipeline built with FAISS, Hugging Face Transformers, and Gradio. This project includes real-time sentiment analysis, reward scoring simulation (RLHF-like), user-selectable LLMs (GPT-2 or LLaMA via Hugging Face Inference API), and local SQLite database logging.
- ✅ Hugging Face
datasetsloading (IMDB) - 🧠 Tokenization + Embeddings via Transformers
- 📊 Vector similarity using FAISS
- 🧮 Real-time Sentiment Analysis (positive, negative, neutral)
- 🎯 Reward Score Simulation (RLHF-style)
- 🧩 SQLite database to save and log interactions
- 🔁 Dynamic model switching between:
- GPT-2 (local)
- LLaMA (via Hugging Face Inference API)
- 🌈 Color-coded sentiment feedback
- 🖼️ Modern Gradio UI (Colab-compatible)
Make sure you're using Python 3.10+.
pip install -r requirements.txt
If using LLaMA via Hugging Face Inference API:
bash
Copy
Edit
huggingface-cli login
💡 Usage
bash
Copy
Edit
python script.py
The app will launch on your browser with a Gradio interface.
📂 Project Structure
graphql
Copy
Edit
├── script.py # Main script
├── requirements.txt # Dependencies
└── interaction_logs.db # Auto-created SQLite log file
📊 Example Use-Case
Enter a movie review or sentence.
Choose GPT-2 or LLaMA.
Click generate.
See:
Answer (generated)
Sentiment with color
RLHF-style reward score
Optionally, save the chat for future analysis.
🧠 Tech Stack
🤗 Transformers
🔍 FAISS (Facebook AI Similarity Search)
🔤 Hugging Face Datasets
📊 SQLite (lightweight database)
🎛️ Gradio for UI
🧪 GPT-2 / LLaMA for generation
✅ To-Do / Improvements
Add real reward model (e.g., PPO RLHF)
Multi-turn memory
Hugging Face Spaces deployment
Authenticated dashboard for logs
📜 License
MIT License