Skip to content

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.

Notifications You must be signed in to change notification settings

Opikadash/text-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Extended 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

No packages published

Languages