datht's picture
Add model card
2e7978b verified
|
Raw History Blame Contribute Delete
4.58 kB
---
license: gemma
base_model: google/embeddinggemma-2
library_name: pytorch
pipeline_tag: zero-shot-classification
language:
- multilingual
tags:
- zero-shot-classification
- text-classification
- intent-classification
- multilingual
- embeddinggemma
- gemma
- bi-encoder
- decision-model
---
# EmbeddingGemma-2 Zero-Shot Classifier (multilingual)
A small, fast zero-shot classifier and decision model: give it a state (message, ticket, request) and a typed question (`choice`, `noul` yes/no,
or `score` level 0..n-1), and it returns probabilities over the options in one forward pass.
- **Base:** [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2) at revision `914f7f8`, fully
fine-tuned. About 270M parameters.
- **Good at:** label choice, many labels, multilingual input. About 15x faster than Kev-0.8B (8.7 ms against
128.9 ms per question on a T4).
- **Weak at:** yes/no and score questions. It does **not** beat Kev-0.8B overall.
## Results (accuracy)
The checkpoint was chosen on a separate dev set only. Each benchmark was run once at the end.
**Laya harness, zero-shot suites.** Laya numbers are their published results on the same suites.
| suite | **this model** | Kev-0.8B | laya (421M) |
|---|---|---|---|
| MASSIVE intent, 51 languages | **0.679** | 0.529 | 0.227 |
| DAIR Emotion | **0.613** | 0.555 | 0.595 |
| Jailbreak (toxic-chat) | 0.770 | **0.890** | 0.708 |
| Toxicity (toxic-chat) | 0.620 | **0.708** | 0.530 |
| Model routing | 0.714 | **0.847** | 0.639 |
| typed-decisions | 0.373 | **0.460** | 0.362 |
| **mean** | 0.628 | **0.665** | 0.510 |
**xbench, 11 public tasks outside the training data.** Binary tasks are balanced, so 0.5 is chance.
| task | type | **this model** | Kev-0.8B |
|---|---|---|---|
| MTOP intent, 6 languages | choice | **0.780** | 0.483 |
| TweetTopic | choice | **0.818** | 0.763 |
| 20 Newsgroups | choice | **0.540** | 0.533 |
| Tweet sentiment | choice | 0.625 | **0.678** |
| XSTest | yes/no | 0.735 | **0.760** |
| JailbreakBench | yes/no | 0.660 | **0.780** |
| HateCheck | yes/no | 0.560 | **0.630** |
| SMS spam | yes/no | 0.500 | **0.610** |
| WikiQA | yes/no | 0.580 | **0.730** |
| SciTail | yes/no | 0.583 | **0.690** |
| SICK relatedness | score | 0.315 | **0.398** |
| **mean** | | 0.609 | **0.641** |
## How it works
Query and options are embedded separately (mean pooling over the text tower's last hidden states). With type index
t (choice 0, score 1, noul 2):
```
logit_k = exp(log_scale[t]) * (gate[t] * cos(q1, o_k) + gate2[t] * cos(q2, o_k))
+ noul_head(q1) for noul, on the "true" option only
p = softmax(logit / temperature[type]), with noul_bias added to the "true" logit
```
| text | format (each wrapped in `<bos>` ... `<eos>`) |
|---|---|
| option | `title: none \| text: <key>: <description>` (score: `level <i>: <description>`; noul: `false: no, the statement does not hold` / `true: yes, the statement holds`) |
| q1, choice/score | `task: <instructions> \| query: <state values, one per line>` |
| q2, choice/score | `task: classification \| query: <state values, one per line>` |
| q1, noul (no q2) | `task: classification \| query: noul question: <instructions>\n<key: value lines>` |
**Files.**
- `model.safetensors`: the fine-tuned EmbeddingGemma-2 text tower (`encoder.*`), plus `log_scale`, `gate` and `gate2`
(each [3]), and `noul_head` (LayerNorm, Linear(d,d), GELU, Linear(d,1)).
- `sys1b_config.json`: the temperatures, `noul_bias` and the input limits (query 512 tokens, option 64 tokens).
No inference code is included.
## Training
- **Data:** 58k questions.
- Soft labels from the teacher `jaredpalmer/kev-4b`.
- Gold-labelled public sets for jailbreak, toxicity, NLI, BoolQ and domain routing. These share task families with
some harness suites, but not the test datasets.
- **Losses:** distillation, InfoNCE, and relational distillation toward the base encoder (to keep multilingual
ability).
- **Optimisation:** 2 epochs.
## Limitations
- Yes/no questions are weak: spam detection is at chance (0.50). Do not use it as the only guardrail.
- typed-decisions zero-shot is below the majority-class baseline (0.461).
- Refit the temperatures on your own data before thresholding on confidence.
## License
Derivative of EmbeddingGemma, distributed under the [Gemma Terms of Use](https://ai.google.dev/gemma/terms) and the
[Gemma Prohibited Use Policy](https://ai.google.dev/gemma/prohibited_use_policy).