Downloads · 30 days
21
11% of all-time downloads
tss-deposium/gemma300-leaf-embeddings-test
gemma300-leaf-embeddings-test is a feature extraction model from tss-deposium. Use it when you need embeddings to search or compare text. It is set up for pytorch. The card lists the license as gemma.
🚨 CRITICAL: This model FAILED quality evaluation - DO NOT USE for production.
Downloads · 30 days
21
11% of all-time downloads
All-time downloads
183
Public
Repo size
976 MB
Likes
0
Public
Click a slice to open those files.
.pt940 MB · 96%
From the Hugging Face model README
🚨 CRITICAL: This model FAILED quality evaluation - DO NOT USE for production.
⚠️ This is experiment v1 (512 tokens) - kept for research purposes only.
Status: Training completed successfully but MTEB evaluation shows critical quality loss. This serves as a baseline for comparison with the improved v2 model (2048 tokens, better architecture) currently in development.
This model is a distilled and quantized version of google/embeddinggemma-300m trained using the LEAF (Layer-wise Early-exit Alignment Framework) methodology. It generates 768-dimensional embeddings optimized for fast CPU inference with INT8 quantization.
LEAF is a knowledge distillation framework that:
| Property | This Model (LEAF) | Base Model (EmbeddingGemma-300m) |
|---|---|---|
| Dimensions | 768D | 768D (also 512D, 256D, 128D via Matryoshka) |
| Parameters | ~75M (6 layers, compressed) | 300M (full architecture) |
| Max Tokens | 512 | 2048 |
| Quantization | INT8 (441MB) | FP32 (~600MB) |
| Inference Speed | 695 texts/s (CPU) | ~50-100 texts/s (CPU) |
Trade-offs:
Evaluation Date: 2025-10-12 Status: ❌ CRITICAL FAILURE - Model does not capture semantic relationships
| Dataset | Metric | This Model (v1) | Base Model | Quality Loss |
|---|---|---|---|---|
| STSBenchmark | Spearman | 0.223 | 0.81 | -72% ❌ |
| STS22 English | Spearman | 0.373 | 0.75 | -50% ❌ |
| STS22 Average | Spearman | ~0.21 | 0.65 | -68% ❌ |
| Cross-lingual | Spearman | -0.14 to 0.12 | 0.55 | Complete loss ❌ |
Detailed STS22 Results by Language:
| Language | Spearman | Status |
|---|---|---|
| 🇨🇳 Chinese | 0.499 | 🟡 Moderate (best) |
| 🇸🇦 Arabic | 0.469 | 🟡 Moderate |
| 🇮🇹 Italian | 0.435 | 🟡 Moderate |
| 🇪🇸 Spanish | 0.403 | 🟠 Poor |
| 🇬🇧 English | 0.373 | 🟠 Poor |
| 🇫🇷 French | 0.300 | 🔴 Very poor |
| 🇷🇺 Russian | 0.268 | 🔴 Very poor |
| 🇹🇷 Turkish | 0.247 | 🔴 Very poor |
| 🇩🇪 German | 0.163 | ❌ Critical |
| 🇵🇱 Polish | 0.132 | ❌ Critical |
Cross-lingual pairs (translation tasks): All FAILED (scores 0.002 to -0.143)
Conclusion: This model cannot be used for semantic search, similarity tasks, or any production use. The embeddings do not preserve semantic meaning from the base model.
Training Metrics (from WandB logs):
| Metric | Final Value | Status |
|---|---|---|
| Distillation Loss | 0.976 | ✅ Good - Model learned from teacher |
| Alignment Loss | 2.18 | ⚠️ Moderate - Semantic space alignment could improve |
| Training Steps | 12,500 (3 epochs) | ✅ Complete |
| Training Time | 2h10min | ✅ Efficient |
| Eval Loss | NaN | ❌ Bug in evaluation aggregation |
Observations:
Quality Verdict: ❌ FAILED - Despite low distillation loss, the model failed to learn semantic representations.
What went wrong:
Architecture Too Aggressive ❌
Insufficient Training Data ❌
Misleading Distillation Loss ⚠️
Evaluation Bug ❌
Lessons learned for v2:
google/embeddinggemma-300msentence-transformers/all-nlisentence-transformers/stsbms_marcoView full training metrics on WandB
pip install torch>=2.6.0 transformers>=4.57.0 huggingface-hub
import torch
from transformers import AutoTokenizer
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(
repo_id="tss-deposium/gemma300-leaf-embeddings-test",
filename="model_quantized.pt"
)
# Load model
checkpoint = torch.load(model_path, map_location='cpu', weights_only=False)
model = checkpoint['model']
model.eval()
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(
"tss-deposium/gemma300-leaf-embeddings-test"
)
model.set_tokenizer(tokenizer)
# Generate embeddings
texts = ["Hello world", "Machine learning"]
with torch.no_grad():
embeddings = model.encode(texts, device='cpu', normalize=True)
print(embeddings.shape) # (2, 768)
This model is deployed as part of a FastAPI service:
import requests
response = requests.post(
"https://your-api-url/api/embed",
json={"model": "leaf", "input": "Your text here"}
)
embeddings = response.json()["embeddings"]
| Property | Value |
|---|---|
| Base Model | google/embeddinggemma-300m |
| Framework | LEAF (Knowledge Distillation) |
| Model Type | Sentence Embeddings |
| Dimensions | 768 |
| Max Tokens | 512 (reduced from 2048 for efficiency) |
| Quantization | INT8 |
| PyTorch Version | 2.6+ |
| Language | English (base model supports 100+ languages) |
| Training Dataset | 50k samples (NLI, STS, MS MARCO) |
model_quantized.pt (441MB) - INT8 quantized model for CPU inferencemodel_fp32.pt (477MB) - FP32 full precision version (optional)tokenizer.json (33MB) - Tokenizer vocabularyconfig.json - Model configurationtokenizer_config.json - Tokenizer settingsThis model is NOT suitable for ANY production use cases.
❌ NOT suitable for:
✅ Only suitable for:
| Metric | LEAF v1 (This Model) | EmbeddingGemma-300m | Quality Gap |
|---|---|---|---|
| Parameters | ~75M | 300M | -75% |
| Size (INT8/FP32) | 441MB | ~600MB | -26% ✅ |
| Speed (CPU) | 695 texts/s | ~50-100 texts/s | +6-10x ✅ |
| Context Length | 512 | 2048 | -75% ❌ |
| STSBenchmark | 0.223 | 0.81 | -72% ❌ |
| STS22 English | 0.373 | 0.75 | -50% ❌ |
| MTEB Score (est.) | ~25 | 61.15 | -59% ❌ |
| Latency | ~1.4ms | ~10-20ms | -85% ✅ |
Verdict: Speed improvements do NOT justify the catastrophic quality loss. Use base model instead.
Based on lessons learned from this failed v1 experiment, we are developing v2 with:
Expected release: After full training and validation (~12-15 hours on RTX 4050)
@misc{leaf-embeddings-test,
author = {TSS Deposium},
title = {LEAF Embeddings INT8 - Distilled from EmbeddingGemma-300m},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/tss-deposium/gemma300-leaf-embeddings-test}},
note = {Based on google/embeddinggemma-300m}
}
@misc{embeddinggemma,
author = {Google},
title = {EmbeddingGemma-300m},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/google/embeddinggemma-300m}}
}
For questions or issues, please open an issue on the model repository.
Disclaimer: This is an experimental model for testing purposes. Performance and quality may vary. Thorough evaluation recommended before production use.