Skip to content

Opikadash/text-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG System with Sentiment, Reward Scoring & LLM Switch

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.

🚀 Features

  • ✅ 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)

📦 Installation

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

About

An advanced Retrieval-Augmented Generation (RAG) pipeline with integrated sentiment analysis, user-selectable LLMs (GPT-2 or LLaMA), FAISS vector search, and RLHF-inspired reward scoring. It supports conversational memory with SQLite logging and features a dynamic Gradio UI for end-user interaction.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages