ZurichNLP/sensidiff-wikimatrix
Viewer โข Updated โข 41.5k
Encoder model that predicts a difference score for every token in a text pair. Example prediction:
| Text A | He 0.028 |
now 0.055 |
works 0.336 |
in 0.240 |
London 0.803 |
. 0.011 |
|---|---|---|---|---|---|---|
| Text B | Er 0.027 |
lebt 0.111 |
jetzt 0.029 |
in 0.083 |
Berlin 0.950 |
. 0.010 |
The model was trained on Wikimatrix pairs that were annotated with GPT 5.6 Terra. The dataset is found here: https://huggingface.co/datasets/jvamvas/sensidiff-wikimatrix
Code for reproducing the example is below. Note that the model was only trained to label the second text. To obtain labels for Text A, you would need to do a second pass with the texts swapped.
from transformers import AutoTokenizer, AutoModelForTokenClassification
model_id = "jvamvas/sensidiff-small"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id)
text_a = "He now works in London."
text_b = "Er lebt jetzt in Berlin."
# The model labels the second text in the input pair.
inputs = tokenizer(text_a, text_b, return_tensors="pt")
scores = model(**inputs).logits[0, :, 0].sigmoid().tolist()
print("| Token | Difference score |")
print("| --- | ---: |")
for token, side, score in zip(inputs.tokens(), inputs.sequence_ids(), scores):
if side == 1:
print(f"| {token} | {score:.3f} |")
Base model
jhu-clsp/mmBERT-small