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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
tags:
|
| 6 |
+
- multimodal
|
| 7 |
+
- embedding
|
| 8 |
+
- matryoshka
|
| 9 |
+
- trimodal
|
| 10 |
+
- image-text-audio
|
| 11 |
+
- retrieval
|
| 12 |
+
- cross-modal
|
| 13 |
+
- edge
|
| 14 |
+
- rag
|
| 15 |
+
library_name: safetensors
|
| 16 |
+
pipeline_tag: feature-extraction
|
| 17 |
+
base_model:
|
| 18 |
+
- MongoDB/mdbr-leaf-ir
|
| 19 |
+
datasets:
|
| 20 |
+
- custom
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# TE-75M β Trimodal Embeddings
|
| 24 |
+
|
| 25 |
+
**TE-75M** maps image, audio, and text into a shared 1280-dim embedding space, enabling cross-modal retrieval with a single vector index. All three modalities share a unified space with full Matryoshka truncation support down to 128 dims.
|
| 26 |
+
|
| 27 |
+
Built for edge deployment β the entire model runs on a Raspberry Pi 5.
|
| 28 |
+
|
| 29 |
+
> Also available in [GGUF format](https://huggingface.co/augmem/TE-75M-GGUF) for quantized edge deployment (114 MB at Q8_0).
|
| 30 |
+
|
| 31 |
+
## Architecture
|
| 32 |
+
|
| 33 |
+
TE-75M uses lightweight edge encoders with learned projection heads into a shared 1280-dim space:
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
Text --> LEAF-IR (768-d) -----------> DeepProjectionHead --> 1280-dim (L2-normalized)
|
| 37 |
+
Image --> MobileNetV4-Medium (1280-d) --> DeepProjectionHead --> 1280-dim
|
| 38 |
+
Audio --> EfficientAT mn20_as (1920-d) --> DeepProjectionHead --> 1280-dim
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
| Component | Architecture | Params | Size |
|
| 42 |
+
|---|---|---|---|
|
| 43 |
+
| Text encoder | LEAF-IR (MongoDB/mdbr-leaf-ir) | 22.7M | 87.2 MB |
|
| 44 |
+
| Image encoder | MobileNetV4-Medium (timm) | 8.4M | 32.4 MB |
|
| 45 |
+
| Audio encoder | EfficientAT mn20_as | 17.9M | 68.5 MB |
|
| 46 |
+
| Image projection | DeepProjectionHead (1280 -> 1920 -> 1280) | 8.6M | 32.9 MB |
|
| 47 |
+
| Audio projection | DeepProjectionHead (1920 -> 1920 -> 1280) | 9.8M | 37.5 MB |
|
| 48 |
+
| Text projection | DeepProjectionHead (768 -> 1920 -> 1280) | 7.6M | 29.1 MB |
|
| 49 |
+
| **Total** | | **75.2M** | **287.7 MB** |
|
| 50 |
+
|
| 51 |
+
### Projection head detail
|
| 52 |
+
|
| 53 |
+
Each `DeepProjectionHead` is a depth-1 residual MLP with Matryoshka-aware training:
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
Linear(encoder_dim, 1920) -> GELU -> LayerNorm -> Dropout(0.2)
|
| 57 |
+
-> Linear(1920, 1920) -> GELU -> LayerNorm -> Dropout(0.2) + residual
|
| 58 |
+
-> Linear(1920, 1280)
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
### Matryoshka dimensions
|
| 62 |
+
|
| 63 |
+
Embeddings can be truncated to `[1280, 768, 512, 256, 128]` dimensions while preserving retrieval quality β trained with Matryoshka Representation Learning (MRL).
|
| 64 |
+
|
| 65 |
+
## Benchmarks
|
| 66 |
+
|
| 67 |
+
All benchmarks run on a single NVIDIA L4 GPU with 5K SALT samples.
|
| 68 |
+
|
| 69 |
+
### Cross-modal retrieval β SALT (5K trimodal samples)
|
| 70 |
+
|
| 71 |
+
| Direction | TE-75M (75M) | TEG-421M (421M) | ImageBind (1.2B) | EBind (1.78B*) |
|
| 72 |
+
|---|---|---|---|---|
|
| 73 |
+
| Image -> Text R@1 | 0.615 | 0.620 | 0.736 | **0.783** |
|
| 74 |
+
| Text -> Image R@1 | 0.614 | 0.672 | 0.712 | **0.779** |
|
| 75 |
+
| Text -> Audio R@1 | **0.103** | 0.113 | 0.038 | 0.047 |
|
| 76 |
+
| Audio -> Text R@1 | 0.082 | **0.115** | 0.039 | 0.035 |
|
| 77 |
+
| Image -> Audio R@1 | **0.062** | 0.083 | 0.023 | 0.027 |
|
| 78 |
+
| Audio -> Image R@1 | **0.063** | 0.081 | 0.025 | 0.032 |
|
| 79 |
+
|
| 80 |
+
### Audio retrieval β AudioCaps & Clotho
|
| 81 |
+
|
| 82 |
+
| Benchmark | Direction | TE-75M | CLAP-Large | ImageBind | EBind |
|
| 83 |
+
|---|---|---|---|---|---|
|
| 84 |
+
| AudioCaps | A->T R@1 | 0.210 | **0.420** | 0.116 | 0.225 |
|
| 85 |
+
| AudioCaps | T->A R@1 | 0.148 | **0.280** | 0.080 | 0.219 |
|
| 86 |
+
| Clotho | A->T R@1 | **0.208** | 0.195 | 0.061 | 0.088 |
|
| 87 |
+
| Clotho | T->A R@1 | 0.172 | **0.167** | 0.074 | 0.118 |
|
| 88 |
+
|
| 89 |
+
TE-75M beats Clotho A->T R@1 for all models including CLAP-Large, while being fully trimodal.
|
| 90 |
+
|
| 91 |
+
### Image-text retrieval β MSCOCO & Flickr30k
|
| 92 |
+
|
| 93 |
+
| Benchmark | Direction | TE-75M (75M) | EBind (1.78B*) | ImageBind (1.2B) |
|
| 94 |
+
|---|---|---|---|---|
|
| 95 |
+
| Flickr30k | I->T R@1 | 0.478 | β | β |
|
| 96 |
+
| MSCOCO 5K | I->T R@1 | 0.320 | **0.743** | 0.658 |
|
| 97 |
+
| MSCOCO 5K | T->I R@1 | 0.208 | **0.559** | 0.490 |
|
| 98 |
+
|
| 99 |
+
### Zero-shot classification β ESC-50
|
| 100 |
+
|
| 101 |
+
| Model | Params | Accuracy |
|
| 102 |
+
|---|---|---|
|
| 103 |
+
| CLAP-Large | 67.8M | **90.5%** |
|
| 104 |
+
| TE-75M | 75M | 93.2% |
|
| 105 |
+
| EBind | 1.78B* | 77.0% |
|
| 106 |
+
| ImageBind | 1.2B | 66.4% |
|
| 107 |
+
|
| 108 |
+
**#1 on ESC-50** (93.2%) at 75M params β beats CLAP-Large (90.5%) while being trimodal.
|
| 109 |
+
|
| 110 |
+
### Text retrieval β MTEB (NDCG@10)
|
| 111 |
+
|
| 112 |
+
Text-text retrieval quality in the shared embedding space, measured on MTEB retrieval tasks:
|
| 113 |
+
|
| 114 |
+
| Task | TE-75M | Raw LEAF-IR | Recovery |
|
| 115 |
+
|---|---|---|---|
|
| 116 |
+
| ArguAna | 0.544 | 0.594 | 92% |
|
| 117 |
+
| CQADupstackGaming | 0.506 | 0.607 | 83% |
|
| 118 |
+
| CQADupstackUnix | 0.355 | 0.428 | 83% |
|
| 119 |
+
| FEVERHardNegatives | 0.551 | 0.863 | 64% |
|
| 120 |
+
| HotpotQAHardNegatives | 0.531 | 0.700 | 76% |
|
| 121 |
+
| FiQA2018 | 0.292 | 0.392 | 74% |
|
| 122 |
+
| ClimateFEVER | 0.215 | 0.353 | 61% |
|
| 123 |
+
| SCIDOCS | 0.153 | 0.198 | 77% |
|
| 124 |
+
| TRECCOVID | 0.474 | 0.820 | 58% |
|
| 125 |
+
|
| 126 |
+
The text projection head recovers 58-92% of raw LEAF-IR's retrieval quality while mapping into the cross-modal shared space.
|
| 127 |
+
|
| 128 |
+
## Usage
|
| 129 |
+
|
| 130 |
+
### Loading components
|
| 131 |
+
|
| 132 |
+
```python
|
| 133 |
+
from safetensors.torch import load_file
|
| 134 |
+
|
| 135 |
+
# Load entire model
|
| 136 |
+
tensors = load_file("TE-75M.safetensors")
|
| 137 |
+
|
| 138 |
+
# Extract components by prefix
|
| 139 |
+
text_enc_sd = {k.removeprefix("text_encoder."): v for k, v in tensors.items() if k.startswith("text_encoder.")}
|
| 140 |
+
image_enc_sd = {k.removeprefix("image_encoder."): v for k, v in tensors.items() if k.startswith("image_encoder.")}
|
| 141 |
+
audio_enc_sd = {k.removeprefix("audio_encoder."): v for k, v in tensors.items() if k.startswith("audio_encoder.")}
|
| 142 |
+
image_proj_sd = {k.removeprefix("image_projection."): v for k, v in tensors.items() if k.startswith("image_projection.")}
|
| 143 |
+
audio_proj_sd = {k.removeprefix("audio_projection."): v for k, v in tensors.items() if k.startswith("audio_projection.")}
|
| 144 |
+
text_proj_sd = {k.removeprefix("text_projection."): v for k, v in tensors.items() if k.startswith("text_projection.")}
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
### Matryoshka truncation
|
| 148 |
+
|
| 149 |
+
```python
|
| 150 |
+
import torch.nn.functional as F
|
| 151 |
+
|
| 152 |
+
# Full 1280-dim embedding
|
| 153 |
+
embedding = model(input) # (N, 1280)
|
| 154 |
+
|
| 155 |
+
# Truncate to 256-dim and re-normalize
|
| 156 |
+
embedding_256 = F.normalize(embedding[:, :256], dim=-1)
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
## File layout
|
| 160 |
+
|
| 161 |
+
```
|
| 162 |
+
TE-75M.safetensors # All components in one file (~288 MB)
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
### Tensor key prefixes
|
| 166 |
+
|
| 167 |
+
| Prefix | Component | Tensors |
|
| 168 |
+
|---|---|---|
|
| 169 |
+
| `text_encoder.*` | LEAF-IR (float32) | 103 |
|
| 170 |
+
| `image_encoder.*` | MobileNetV4-Medium | 462 |
|
| 171 |
+
| `audio_encoder.*` | EfficientAT mn20_as | 312 |
|
| 172 |
+
| `image_projection.*` | Projection head | 10 |
|
| 173 |
+
| `audio_projection.*` | Projection head | 10 |
|
| 174 |
+
| `text_projection.*` | Projection head | 10 |
|
| 175 |
+
|
| 176 |
+
## Training
|
| 177 |
+
|
| 178 |
+
- **Loss**: InfoNCE (contrastive) with Matryoshka Representation Learning
|
| 179 |
+
- **Data**: ~2.2M synthetically generated trimodal triplets (WordNet) + 200K MSCOCO img+txt + 262K WavCaps aud+txt + 1.5M Nomic text pairs
|
| 180 |
+
- **Hardware**: 2x NVIDIA L4 GPUs
|
| 181 |
+
- **Text retrieval fine-tune**: Phase 1 warm start from d20 checkpoint, text-head-only with frozen image/audio heads, Nomic supervised text pairs mixed at lambda_tt=0.25
|
| 182 |
+
- **Optimizer**: AdamW, lr=1e-3, weight decay=1e-4, cosine scheduler
|
| 183 |
+
- **Epochs**: 7 (text fine-tune from pre-trained trimodal base)
|
| 184 |
+
- **Projection heads only** β source encoders are frozen during training
|
| 185 |
+
|
| 186 |
+
### Design decisions
|
| 187 |
+
|
| 188 |
+
- **3-head shared space**: All modalities project into a learned 1280-dim space (image-native dimension) instead of targeting a pre-existing text encoder space
|
| 189 |
+
- **LEAF-IR text encoder**: 23M-param retrieval-optimized text encoder replaces 300M Gemma, enabling fully edge-deployable text inference
|
| 190 |
+
- **Frozen source encoders**: MobileNetV4, EfficientAT, and LEAF-IR are kept frozen; only projection heads are trained
|
| 191 |
+
- **Text retrieval fine-tune**: Nomic supervised text pairs (1.5M) mixed into trimodal training to improve text-text retrieval while preserving cross-modal alignment
|
| 192 |
+
- **Edge-first**: All source encoders can run on devices like Raspberry Pi 5
|
| 193 |
+
|
| 194 |
+
## Limitations
|
| 195 |
+
|
| 196 |
+
- Audio retrieval lags behind specialist models like CLAP on audio-only benchmarks
|
| 197 |
+
- Image-text retrieval trades accuracy vs larger vision encoders for edge deployability
|
| 198 |
+
- Text retrieval recovers 58-92% of raw LEAF-IR quality (gap is domain-dependent)
|
| 199 |
+
- Trained primarily on synthetic trimodal data β real-world distribution shifts may affect performance
|
| 200 |
+
|
| 201 |
+
## Links
|
| 202 |
+
|
| 203 |
+
- **Website**: [augmem.ai](https://augmem.ai)
|
| 204 |
+
- **GitHub**: [github.com/augmem](https://github.com/augmem)
|
| 205 |
+
|
| 206 |
+
## License
|
| 207 |
+
|
| 208 |
+
Apache 2.0
|