Views
No views yet
intfloat/multilingual-e5-small and fine‑tuned on a synthetic dataset of word and sentence pairs.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3model_name = "ghananlpcommunity/twi-eng-qe-e5"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForSequenceClassification.from_pretrained(model_name)
6
7def predict(twi, english):
8 text = f"query: {twi} passage: {english}"
9 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
10 outputs = model(**inputs)
11 prob = outputs.logits.softmax(dim=-1)
12 return prob[0][1].item() # probability of "correct"
13
14print(predict("me ho ye", "I am fine")) # expected > 0.5
15print(predict("me ho ye", "The car is blue")) # expected < 0.5