---
title: embeddinggemma-300m-bf16
canonical_url: "https://www.modelscope.cn/models/mlx-community/embeddinggemma-300m-bf16"
md_url: "https://www.modelscope.cn/models/mlx-community/embeddinggemma-300m-bf16.md"
repository: mlx-community/embeddinggemma-300m-bf16
last_updated: 2025-09-05
license: gemma
pipeline_tag: sentence-similarity
tasks:
  - sentence-similarity
model_type:
  - gemma3_text
architectures:
  - Gemma3TextModel
parameters: 307.6M
tensor_type:
  - F16
library_name:
  - sentence-transformers
  - mlx
  - safetensors
  - pytorch
frameworks:
  - pytorch
downloads: 94
stars: 0
tags:
  - sentence-transformers
  - sentence-similarity
  - feature-extraction
  - text-embeddings-inference
  - mlx
---

# embeddinggemma-300m-bf16

> embeddinggemma-300m-bf16 - mlx-community 在 ModelScope 开源的模型。mlx-community/embeddinggemma-300m-bf16

mlx-community/embeddinggemma-300m-bf16 是 ModelScope 魔搭社区上的 307.6M 参数sentence-similarity模型，采用 gemma 许可。

- **Repository**: mlx-community/embeddinggemma-300m-bf16
- **License**: gemma
- **Tasks**: sentence-similarity
- **Parameters**: 307.6M
- **Tags**: sentence-transformers, sentence-similarity, feature-extraction, text-embeddings-inference, mlx
- **Downloads**: 94
- **Stars**: 0
- **Last updated**: 2025-09-05

Source: https://www.modelscope.cn/models/mlx-community/embeddinggemma-300m-bf16

---

# mlx-community/embeddinggemma-300m-bf16

The Model [mlx-community/embeddinggemma-300m-bf16](https://huggingface.co/mlx-community/embeddinggemma-300m-bf16) was converted to MLX format from [google/embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m) using mlx-lm version **0.0.4**.

## Use with mlx

```bash
pip install mlx-embeddings
```

```python
from mlx_embeddings import load, generate
import mlx.core as mx

model, tokenizer = load("mlx-community/embeddinggemma-300m-bf16")


# For text embedding
sentences = [
    "task: sentence similarity | query: Nothing really matters.",
    "task: sentence similarity | query: The dog is barking.",
    "task: sentence similarity | query: The dog is barking.",
]

encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='mlx')

# Compute token embeddings
input_ids = encoded_input['input_ids']
attention_mask = encoded_input['attention_mask']
output = model(input_ids, attention_mask)

embeddings = output.text_embeds  # Normalized embeddings

# Compute dot product between normalized embeddings
similarity_matrix = mx.matmul(embeddings, embeddings.T)

print("Similarity matrix between texts:")
print(similarity_matrix)


# You can use these task-specific prefixes for different tasks
task_prefixes = {
    "BitextMining": "task: search result | query: ",
    "Clustering": "task: clustering | query: ",
    "Classification": "task: classification | query: ",
    "MultilabelClassification": "task: classification | query: ",
    "PairClassification": "task: sentence similarity | query: ",
    "InstructionRetrieval": "task: code retrieval | query: ",
    "Reranking": "task: search result | query: ",
    "Retrieval": "task: search result | query: ",
    "Retrieval-query": "task: search result | query: ",
    "Retrieval-document": "title: none | text: ",
    "STS": "task: sentence similarity | query: ",
    "Summarization": "task: summarization | query: ",
    "document": "title: none | text: "
}

```
