gemma-4-e4b-it-distill-ed

Reasoning entity-disambiguation model from the paper When Does Reasoning Help Entity Disambiguation? Small LLMs In-Domain and Under Shift (Findings of EACL 2027). It is google/gemma-4-E4B-it trained with LoRA (merged) by off-policy distillation from gemma-4-26B-A4B-it on ZELDA. Given a mention in context and a shortlist of candidates, it reasons and then answers with the index of the chosen candidate.

ZELDA (acc.) ZESHEL, true zero-shot (norm. acc.)
80.4 83.7

Usage

The model expects the prompt below: the mention is marked with [ ] and the candidates are numbered. It reasons, then ends with "answer": <index>. Sample 10 completions and take the majority vote.

import re
from collections import Counter
from vllm import LLM, SamplingParams

PROMPT = """You are an expert designed to disambiguate entities in text, taking into account the overall context and a list of entity candidates.
You are provided with an input text that includes a full contextual narrative, the mention enclosed between the '[' and ']' characters, and a list of candidates, each preceded by an index number.
Your task is to determine the most appropriate entity from the candidates based on the context and candidate entity descriptions.
Please show your choice in the answer field with only the choice index number, e.g., "answer": 3."""

text = "[Jordan] scored 45 points as the Bulls beat the Jazz in Game 6."
candidates = [
    ("Jordan", "Jordan is a country in Western Asia."),
    ("Michael Jordan", "Michael Jordan is an American former professional basketball player."),
    ("Jordan River", "The Jordan River is a river in the Middle East."),
]

user = f"Input text: {text}\nList of candidate entities:\n" + "\n".join(f"{i}. {t} - {d}" for i, (t, d) in enumerate(candidates, 1))
messages = [{"role": "system", "content": PROMPT}, {"role": "user", "content": user}]

llm = LLM("samyhaff/gemma-4-e4b-it-distill-ed")
params = SamplingParams(**(llm.model_config.get_diff_sampling_param() | {"n": 10, "max_tokens": 2048}))
outputs = llm.chat([messages], params, chat_template_kwargs={"enable_thinking": True})[0].outputs

answers = [int(m[-1]) for o in outputs if (m := re.findall(r"answer\D*:\s*(\d+)", o.text, re.I))]
answers = [a for a in answers if 1 <= a <= len(candidates)]
print(candidates[Counter(answers).most_common(1)[0][0] - 1][0])  # Michael Jordan

In the paper, the candidates are the top 10 of qwen3-4b-reranker-ed. Full pipeline and evaluation: github.com/samyhaff/ed-study.

Citation

@inproceedings{haffoudhi2027reasoning,
  title         = {When Does Reasoning Help Entity Disambiguation? Small {LLM}s In-Domain and Under Shift},
  author        = {Haffoudhi, Samy and Suchanek, Fabian M. and Holzenberger, Nils},
  booktitle     = {Findings of the Association for Computational Linguistics: EACL 2027},
  year          = {2027},
  eprint        = {2611.30334},
  archivePrefix = {arXiv}
}
Downloads last month
273
Safetensors
Model size
8B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for samyhaff/gemma-4-e4b-it-distill-ed

Finetuned
(507)
this model

Collection including samyhaff/gemma-4-e4b-it-distill-ed

Paper for samyhaff/gemma-4-e4b-it-distill-ed