Downloads · 30 days
6
10% of all-time downloads
0x3/gemma-4-E4B-it-audio-encoder
gemma-4-E4B-it-audio-encoder is a feature extraction model from 0x3. Use it when you need embeddings to search or compare text. It is set up for transformers. The card lists the license as apache-2.0.
Audio encoder extracted from google/gemma-4-E4B-it.
Downloads · 30 days
6
10% of all-time downloads
All-time downloads
61
Public
Parameters
309M
618 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors618 MB · 100%
From the Hugging Face model README
Audio encoder extracted from google/gemma-4-E4B-it.
Requires transformers>=5.5.0.
from transformers import AutoFeatureExtractor, AutoModel
import librosa
import torch
model_id = "Aratako/gemma-4-E4B-it-audio-encoder"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
encoder = AutoModel.from_pretrained(model_id, trust_remote_code=True, dtype=torch.bfloat16).cuda()
y, sr = librosa.load("test.mp3", sr=feature_extractor.sampling_rate)
features = feature_extractor([y], return_tensors="pt", sampling_rate=feature_extractor.sampling_rate)
features["input_features"] = features["input_features"].to(device="cuda", dtype=torch.bfloat16)
features["input_features_mask"] = features["input_features_mask"].cuda()
# With projection to LLM embedding space (2560-dim)
output, mask = encoder(**features, project=True)
print(output.shape) # [B, L, 2560]
# Without projection, raw encoder output (1536-dim)
output, mask = encoder(**features, project=False)
print(output.shape) # [B, L, 1536]
project | Output dim | Description |
|---|---|---|
True (default) | 2560 | Projected to Gemma 4 E4B LLM embedding space |
False | 1536 | Raw audio encoder output |
Inspired by mesolitica/gemma-3n-e4b-it-audio-encoder.