A comprehensive framework for evaluating, optimizing, and benchmarking Small Language Models (SLMs) with a focus on edge deployment, ONNX optimization, and robustness testing. This project provides extensive evaluation of 6 state-of-the-art small language models across multiple metrics including accuracy, inference time, memory usage, model size, and robustness.
Clone the repository
git clone <repository-url>
cd LLMComp2025
Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Linux/macOS
# or venv\Scripts\activate on Windows
Install required packages
pip install -r requirements.txt
Evaluate a pre-trained model
python test_models.py
Run ONNX evaluation on all models
python src/evaluation/usecase3/final_comparison.py
Generate visualization plots
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
Export a model to ONNX
python src/onnx_env/usecase3/distilbert.py # Replace with desired model
Our comprehensive evaluation reveals the following performance characteristics:
| Model | Clean Accuracy | Robust Accuracy | Inference Time (ms) | Model Size (MB) | Energy/Query (CPU) |
|---|---|---|---|---|---|
| TinyLLaMA | 93.27% | 89.11% | 15.40 | 4.49 | 0.616J |
| Phi-3-mini | 92.17% | 84.62% | 69.80 | 2213.84 | 2.792J |
| MobileBERT | 91.87% | 78.35% | 1.67 | 95.36 | 0.067J |
| DistilBERT | 91.70% | 79.61% | 1.13 | 256.43 | 0.045J |
| ALBERT | 91.45% | 78.05% | 2.21 | 47.11 | 0.088J |
| MobileLLaMA | 91.38% | 80.50% | 0.55 | 169.31 | 0.022J |
LLMComp2025/
├── README.md # This file
├── Documentation.md # Detailed technical documentation
├── requirements.txt # Python dependencies
├── run.py # Command-line interface
├── test_models.py # Quick model testing script
├── config/ # Configuration files
│ ├── config.json # Model configurations
│ └── evaluation_config.py # Evaluation settings
├── src/ # Source code
│ ├── main.py # Main entry point
│ ├── training/ # Training scripts for use cases
│ ├── evaluation/ # Evaluation and benchmarking
│ ├── onnx_env/ # ONNX export and optimization
│ └── utils/ # Utility functions
├── data/ # Dataset storage
│ ├── raw/ # Original datasets
│ └── processed/ # Preprocessed datasets
├── Data_scripts/ # Data preprocessing scripts
├── onnx_results_usecase3*/ # ONNX evaluation results
└── results_baseline_comparison/ # Baseline comparison results
# Run complete ONNX evaluation pipeline
python src/evaluation/usecase3/final_comparison.py
# Generate comparative visualization
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
# Export DistilBERT
python src/onnx_env/usecase3/distilbert.py
# Export ALBERT
python src/onnx_env/usecase3/albert.py
# Export TinyLLaMA
python src/onnx_env/usecase3/tinyllama.py
# Evaluate ALBERT with detailed metrics
python src/evaluation/usecase3/albert_eval.py
# Evaluate Phi-3 with robustness testing
python src/evaluation/usecase3/eval_phi3.py
# Test any model interactively
python test_models.py
# Enter text when prompted to get real-time predictions
Our energy analysis across different hardware platforms shows:
# Add your own model to the evaluation framework
from src.models import register_model
@register_model("your_model")
def load_your_model():
# Model loading logic
return model, tokenizer
# Extend evaluation with custom metrics
from src.evaluation import add_custom_metric
@add_custom_metric
def custom_efficiency_score(predictions, ground_truth, inference_times):
# Your metric calculation
return score
The framework supports optimization for different target devices:
See requirements.txt for complete list. Key dependencies:
# 1. Set up environment
source venv/bin/activate
# 2. Run full evaluation pipeline
python src/evaluation/usecase3/final_comparison.py
# 3. Generate all plots and visualizations
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
# 4. Review results
ls onnx_results_usecase3/
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
| Name | GitHub Username |
|---|---|
| Claudia Saleem | @claudiasaleem |
| Mostafa Elshabasy | @Mosspheree |
This work was conducted as part of LLMComp2025, focusing on advancing the state of small language model optimization for practical deployment scenarios. Special thanks to the open-source community for providing the foundational models and tools that made this research possible.
If you use this framework in your research, please cite:
@misc{llmcomp2025,
title={LLMComp2025: Small Language Model Optimization \& Evaluation Framework},
author={Saleem, Claudia and Elshabasy, Mostafa},
year={2025},
howpublished={\url{https://github.com/your-repo/LLMComp2025}}
}
15 commits
3 commits
Python
100.0%
A comprehensive framework for evaluating, optimizing, and benchmarking Small Language Models (SLMs) with a focus on edge deployment, ONNX optimization, and robustness testing. This project provides extensive evaluation of 6 state-of-the-art small language models across multiple metrics including accuracy, inference time, memory usage, model size, and robustness.
Clone the repository
git clone <repository-url>
cd LLMComp2025
Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # On Linux/macOS
# or venv\Scripts\activate on Windows
Install required packages
pip install -r requirements.txt
Evaluate a pre-trained model
python test_models.py
Run ONNX evaluation on all models
python src/evaluation/usecase3/final_comparison.py
Generate visualization plots
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
Export a model to ONNX
python src/onnx_env/usecase3/distilbert.py # Replace with desired model
Our comprehensive evaluation reveals the following performance characteristics:
| Model | Clean Accuracy | Robust Accuracy | Inference Time (ms) | Model Size (MB) | Energy/Query (CPU) |
|---|---|---|---|---|---|
| TinyLLaMA | 93.27% | 89.11% | 15.40 | 4.49 | 0.616J |
| Phi-3-mini | 92.17% | 84.62% | 69.80 | 2213.84 | 2.792J |
| MobileBERT | 91.87% | 78.35% | 1.67 | 95.36 | 0.067J |
| DistilBERT | 91.70% | 79.61% | 1.13 | 256.43 | 0.045J |
| ALBERT | 91.45% | 78.05% | 2.21 | 47.11 | 0.088J |
| MobileLLaMA | 91.38% | 80.50% | 0.55 | 169.31 | 0.022J |
LLMComp2025/
├── README.md # This file
├── Documentation.md # Detailed technical documentation
├── requirements.txt # Python dependencies
├── run.py # Command-line interface
├── test_models.py # Quick model testing script
├── config/ # Configuration files
│ ├── config.json # Model configurations
│ └── evaluation_config.py # Evaluation settings
├── src/ # Source code
│ ├── main.py # Main entry point
│ ├── training/ # Training scripts for use cases
│ ├── evaluation/ # Evaluation and benchmarking
│ ├── onnx_env/ # ONNX export and optimization
│ └── utils/ # Utility functions
├── data/ # Dataset storage
│ ├── raw/ # Original datasets
│ └── processed/ # Preprocessed datasets
├── Data_scripts/ # Data preprocessing scripts
├── onnx_results_usecase3*/ # ONNX evaluation results
└── results_baseline_comparison/ # Baseline comparison results
# Run complete ONNX evaluation pipeline
python src/evaluation/usecase3/final_comparison.py
# Generate comparative visualization
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
# Export DistilBERT
python src/onnx_env/usecase3/distilbert.py
# Export ALBERT
python src/onnx_env/usecase3/albert.py
# Export TinyLLaMA
python src/onnx_env/usecase3/tinyllama.py
# Evaluate ALBERT with detailed metrics
python src/evaluation/usecase3/albert_eval.py
# Evaluate Phi-3 with robustness testing
python src/evaluation/usecase3/eval_phi3.py
# Test any model interactively
python test_models.py
# Enter text when prompted to get real-time predictions
Our energy analysis across different hardware platforms shows:
# Add your own model to the evaluation framework
from src.models import register_model
@register_model("your_model")
def load_your_model():
# Model loading logic
return model, tokenizer
# Extend evaluation with custom metrics
from src.evaluation import add_custom_metric
@add_custom_metric
def custom_efficiency_score(predictions, ground_truth, inference_times):
# Your metric calculation
return score
The framework supports optimization for different target devices:
See requirements.txt for complete list. Key dependencies:
# 1. Set up environment
source venv/bin/activate
# 2. Run full evaluation pipeline
python src/evaluation/usecase3/final_comparison.py
# 3. Generate all plots and visualizations
python src/evaluation/usecase3/plots_ONNX/general_plots_onnx.py
# 4. Review results
ls onnx_results_usecase3/
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
| Name | GitHub Username |
|---|---|
| Claudia Saleem | @claudiasaleem |
| Mostafa Elshabasy | @Mosspheree |
This work was conducted as part of LLMComp2025, focusing on advancing the state of small language model optimization for practical deployment scenarios. Special thanks to the open-source community for providing the foundational models and tools that made this research possible.
If you use this framework in your research, please cite:
@misc{llmcomp2025,
title={LLMComp2025: Small Language Model Optimization \& Evaluation Framework},
author={Saleem, Claudia and Elshabasy, Mostafa},
year={2025},
howpublished={\url{https://github.com/your-repo/LLMComp2025}}
}
15 commits
3 commits
Python
100.0%