Skip to content

itsPreto/GPT-Rex

Repository files navigation

GPT-Rex - A Retrieval Augmented Recommendation Engine

A lightweight & extremely fast, RAG-powered recommendation engine-- leveraging advanced NLP, prompt engineering, and linear algebra to create a unique and narutal search experience.

Screenshot 2024-07-13 at 7 37 04 PM Screenshot 2024-07-13 at 7 36 27 PM

Key Features

  • Vector Embeddings: Employs vector embeddings for efficient and accurate movie recommendations.
  • Retrieval Augmented Generation: Integrates R.A.G for dynamic, context-aware recommendations.
  • Few-Shot Prompting: Utilizes few-shot prompting techniques for better understanding user queries.
  • Re-Ranking Mechanism: Incorporates a re-ranking system to optimize the relevance of search results.

Technical Overview

The engine is built using Flask, allowing easy integration into web applications. It uses the SentenceTransformer model for generating vector embeddings of movie descriptions. The HyperDB module is employed for efficient storage and retrieval of these embeddings.

Key functions include:

  • create_and_save_db: Generates and stores the database of movie vectors.
  • load_db: Loads the pre-processed movie database.
  • search_movies: Handles the query processing and vector similarity computations to find the best movie matches.

API Endpoints

  • POST /search: Accepts a search query and returns a list of recommended movies based on the query.

Frontend

A basic frontend is provided for interacting with the recommendation engine. It includes:

  • Search Bar: For entering movie-related queries.
  • Results Display: Showcases the recommended movies with details such as title, overview, and similarity score.

Setup and Running

To set up and run GPT-Rex:

  1. Install dependencies.
  2. Run the Flask app.

Note: You will need to first create the vector db.

if __name__ == "__main__":
    db_file = "assets/movies_hyperdb.pickle.gz"
    json_file = "assets/all_movies.json"
    create_new_db = False  # Toggle based on need
    if create_new_db:
        create_and_save_db(json_file, db_file)
    db = load_db(db_file)
    with open(json_file, "r") as f:
        original_documents = json.load(f)
    model = SentenceTransformer('all-MiniLM-L6-v2')
    app.run(debug=True, port=8080)

Resources

About

🦕 A HyperDB Recommendation Engine.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published