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.1.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.1-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: studsar_ai-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ae3ed4005c743ba1fcc2ecdf07c5a84e92b39bc69b0cbe298ab8dfb47824d919
MD5 628febaf5b6613fc041cebb36025635e
BLAKE2b-256 96247836d18c27436671ec311331de3fc5a2b5abcaf579d6af534c9b7255464a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: studsar_ai-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70c6f2e2d98d11fc86c3602cb18b05c97578c0c3e77fcfada40c58e3b0bbdc94
MD5 a42a0a5dcbcbd58f13c2d19ede190a65
BLAKE2b-256 e40078ee6c492b7f1375371f9ca86506e4408fcdb9c7577f18bf490b26f52412

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