Downloads · 30 days
18
3% of all-time downloads
sarthak1/Qodo-Embed-M-1-1.5B-M2V-Distilled
Qodo-Embed-M-1-1.5B-M2V-Distilled is a feature extraction model from sarthak1. Use it when you need embeddings to search or compare text. It is set up for model2vec. The card lists the license as other.
This project optimizes the Qodo-Embed-1-1.5B model using Model2Vec, reducing its size and dramatically improving inference speed while maintaining most of its performance capabilities.
Downloads · 30 days
18
3% of all-time downloads
All-time downloads
600
Public
Parameters
58.2M
244 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors233 MB · 95%
From the Hugging Face model README
This project optimizes the Qodo-Embed-1-1.5B model using Model2Vec, reducing its size and dramatically improving inference speed while maintaining most of its performance capabilities.
Qodo-Embed-1-1.5B is a state-of-the-art code embedding model designed for retrieval tasks in the software development domain. While powerful, it can be resource-intensive for production use cases.
Model2Vec is a technique to distill large sentence transformer models into small, fast static embedding models. This project applies Model2Vec to create an optimized version of Qodo-Embed-1-1.5B with the following benefits:
First, ensure you have the required dependencies:
# Install the base package
uv sync
To create a distilled version of Qodo-Embed-1-1.5B:
uv run python distill.py --pca_dims 384
Options:
--model_name - Source model name (default: "Qodo/Qodo-Embed-1-1.5B")--output_dir - Where to save the distilled model (default: "models/qodo_embed_m2v")--pca_dims - Dimensions for PCA reduction; smaller values create faster but less accurate models (default: 384)--save_to_hub - Push the model to HuggingFace Hub--hub_model_id - Model ID for HuggingFace Hub (required if saving to hub)--skip_readme - Skip generating README file (default: True)To evaluate the distilled model against the original:
uv run python evaluate.py
Options:
--original_model - Original model name (default: "Qodo/Qodo-Embed-1-1.5B")--distilled_model - Path to the distilled model (default: ".")--output_dir - Where to save evaluation results (default: "evaluation")from model2vec import StaticModel
from sentence_transformers import SentenceTransformer
import time
# Sample code for embedding
code_samples = [
"def process_data_stream(source_iterator):",
"implement binary search tree",
"how to handle memory efficient data streaming",
"""class LazyLoader:
def __init__(self, source):
self.generator = iter(source)
self._cache = []"""
]
# Load original model
print("Loading original model...")
original_model = SentenceTransformer("Qodo/Qodo-Embed-1-1.5B")
# Load distilled model
print("Loading distilled model...")
distilled_model = StaticModel.from_pretrained("models/qodo_embed_m2v")
# Compare embedding speed
print("\nGenerating embeddings with original model...")
start = time.time()
original_embeddings = original_model.encode(code_samples)
original_time = time.time() - start
print(f"Original model took: {original_time:.4f} seconds")
print("\nGenerating embeddings with distilled model...")
start = time.time()
distilled_embeddings = distilled_model.encode(code_samples)
distilled_time = time.time() - start
print(f"Distilled model took: {distilled_time:.4f} seconds")
print(f"Speed improvement: {original_time/distilled_time:.2f}x faster")
print(f"\nOriginal embedding dimensions: {original_embeddings.shape}")
print(f"Distilled embedding dimensions: {distilled_embeddings.shape}")
The distilled model achieves:
Detailed evaluation results, including similarity plots and performance metrics, are saved to the evaluation output directory.
distill.py - Script to create the distilled modelevaluate.py - Script to compare performance with the original modelexample.py - Example usage of the distilled modelevaluation/ - Directory containing evaluation results and visualizationsThis project is built upon the following technologies:
This model is licensed under the QodoAI-Open-RAIL-M license, the same as the original Qodo-Embed-1-1.5B model. Any derivative model must include "Qodo" at the beginning of its name per the license requirements.