StudSAR AI RAG evaluation and neural retrieval toolkit
Project description
StudSAR-AI: 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
- Data Loading and Processing: Sample documents are loaded and processed to create a knowledge base for both RAG systems.
- Retrieval: StudSAR uses a
SentenceTransformermodel for embedding queries and documents, enabling semantic search. Traditional RAG uses simpler keyword matching. - 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.
- Evaluation: A
evaluate_rag_systemsfunction 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_docsdictionary inapp.pydemonstrates how various AI-related topics are used as source material. - Modular Design: The
StudSarManagerandTraditionalRAGclasses (fromsrc.managers.managerandtraditional_rag.pyrespectively) 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_systemsfunction calculates scores for relevance, completeness, accuracy, and semantic similarity, providing a quantitative comparison.
Usage
Setup and Installation
- Clone this repository:
git clone https://github.com/your-username/StudSAR.git cd StudSAR
- Create a virtual environment and activate it:
python -m venv .venv .\.venv\Scripts\activate
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file studsar_ai-0.1.3.tar.gz.
File metadata
- Download URL: studsar_ai-0.1.3.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e7c1378b694d869104a451222b520d634e9d926d5a13c10eb3f5ae3ea32c79b
|
|
| MD5 |
782d1becd97e9dce5ca0821b75a0cbff
|
|
| BLAKE2b-256 |
cdb35cc8b2b3d8a51313768385add1f9b7ba5c3d4d930aae5bfb23546b77d13b
|
File details
Details for the file studsar_ai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: studsar_ai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1581969e2d01b96c141f9b911eee2c9e6076abb4102590cf420e95c53d9324a3
|
|
| MD5 |
ed78435e53eb7d40a49eff7d2c766f67
|
|
| BLAKE2b-256 |
587c4adcb05634a1e23ab3c018bace581174e42a5fcbbe0c510774b847ac8316
|