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
datasets
loading (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