Skip to main content

StudSAR AI RAG evaluation and neural retrieval toolkit

Project description


title: StudSAR RAG Evaluation emoji: ๐Ÿš€ colorFrom: 'purple' colorTo: 'indigo' sdk: gradio sdk_version: "3.41.2" app_file: app.py pinned: false

StudSAR RAG Evaluation

Project Overview

This project implements and evaluates a Retrieval Augmented Generation (RAG) system, StudSAR, designed to enhance the accuracy and relevance of AI-generated responses by integrating a robust retrieval mechanism with a language model. The system is compared against a traditional RAG approach to highlight its advantages.

Implementation Details

The core of the project is built around a Gradio web interface, allowing for interactive demonstrations and comparisons between StudSAR and Traditional RAG. Key components include:

  • StudSAR RAG: Utilizes a neural search approach for document retrieval, aiming for more semantically relevant results.
  • Traditional RAG: Employs a keyword-based or simpler retrieval method for baseline comparison.
  • Evaluation Metrics: A custom evaluation framework assesses both systems based on relevance, completeness, accuracy, and semantic similarity.

Technical Approach

  1. Data Loading and Processing: Sample documents are loaded and processed to create a knowledge base for both RAG systems.
  2. Retrieval: StudSAR uses a SentenceTransformer model for embedding queries and documents, enabling semantic search. Traditional RAG uses simpler keyword matching.
  3. Generation: (Implicit) The retrieved information is intended to augment a language model's generation capabilities, though the language model itself is abstracted for this comparison.
  4. Evaluation: A evaluate_rag_systems function compares the outputs of both systems using a combination of keyword matching, semantic similarity (cosine similarity of embeddings), and a simplified coherence score.

Key Observations from app.py

  • Dynamic Document Loading: The sample_docs dictionary in app.py demonstrates how various AI-related topics are used as source material.
  • Modular Design: The StudSarManager and TraditionalRAG classes (from src.managers.manager and traditional_rag.py respectively) encapsulate the logic for each RAG system.
  • Interactive Interface: Gradio is used to create a user-friendly interface where users can input queries and see comparative results and evaluation scores.
  • Evaluation Logic: The evaluate_rag_systems function calculates scores for relevance, completeness, accuracy, and semantic similarity, providing a quantitative comparison.

Usage

Setup and Installation

  1. Clone this repository:
    git clone https://github.com/your-username/StudSAR.git
    cd StudSAR
    
  2. Create a virtual environment and activate it:
    python -m venv .venv
    .\.venv\Scripts\activate
    
  3. Install the required dependencies:
    pip install -r requirements.txt
    

Running the Application

To run the Gradio application locally, navigate to the StudSar directory and execute the following command:

cd StudSar
python app.py

The application will typically be available at http://localhost:7860 or a similar address provided in the console output.

Deployment to Hugging Face Spaces

This application can be easily deployed to Hugging Face Spaces. Ensure your app.py and requirements.txt files are in the root directory of your Space. Hugging Face Spaces will automatically detect and run the Gradio application.

Repository Structure

StudSar/
โ”œโ”€โ”€ app.py                  # Main Gradio application and evaluation logic
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ managers/           # Contains StudSarManager for neural RAG
โ”‚   โ”‚   โ””โ”€โ”€ manager.py
โ”‚   โ”œโ”€โ”€ models/             # (Potentially) Neural network models or components
โ”‚   โ”‚   โ””โ”€โ”€ neural.py
โ”‚   โ”œโ”€โ”€ rag/                # RAG-related utilities or base classes
โ”‚   โ”‚   โ””โ”€โ”€ rag_connector.py
โ”‚   โ”œโ”€โ”€ studsar.py          # Core StudSAR implementation
โ”‚   โ””โ”€โ”€ utils/              # Utility functions (e.g., text processing)
โ”‚       โ””โ”€โ”€ text.py
โ”œโ”€โ”€ traditional_rag.py      # Implementation of the traditional RAG system
โ”œโ”€โ”€ temp_docs/              # Sample documents for RAG knowledge base
โ”œโ”€โ”€ examples/               # Example usage scripts
โ”œโ”€โ”€ tests/                  # Unit and integration tests
โ””โ”€โ”€ studsar_neural_demo.pth # Pre-trained model weights (if applicable)

Performance Analysis

The evaluation metrics within app.py provide a direct comparison:

  • Relevance: Measured by keyword overlap.
  • Completeness: Assessed by the proportion of query keywords found in results.
  • Accuracy: Determined by semantic similarity to the query.
  • Semantic Similarity: Cosine similarity between query and result embeddings.

StudSAR is designed to outperform Traditional RAG in semantic understanding and retrieval accuracy, leading to higher scores in these metrics.

References

  • Gradio: For building the interactive web interface.
  • Sentence Transformers: For generating embeddings for semantic search.
  • Hugging Face Spaces: For easy deployment and sharing of the application.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

studsar_ai-0.1.2.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

studsar_ai-0.1.2-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file studsar_ai-0.1.2.tar.gz.

File metadata

  • Download URL: studsar_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for studsar_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bd5666ca3f347379eafe80bf08fcfd9c09496036fdc3e9c67a22068e962b7d4f
MD5 1b5ca1a556a47eaa6c52086d553f2bed
BLAKE2b-256 17a879568b25e84433cca982e1b3ca004405cd69916724f6af35a221a719086e

See more details on using hashes here.

File details

Details for the file studsar_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: studsar_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for studsar_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1b74e784e655a7de638e85c3985b6bc6275d838a78219e660a69315539344346
MD5 fbc1cbcace1e7caf0a3cf43edae8ba07
BLAKE2b-256 346b2cd1935b426d75f4dfd5d8529dae3503562cbd119937ccadb15d6f09ea17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page