Edit model card

Hebrew Cross-Encoder Model

Usage

from sentence_transformers import CrossEncoder
model = CrossEncoder('HeTree/HeCross')

# Scores (already after sigmoid)
scores = model.predict([('כמה אנשים חיים בברלין?', 'ברלין מונה 3,520,031 תושבים רשומים בשטח של 891.82 קמ"ר.'), 
                        ('כמה אנשים חיים בברלין?', 'העיר ניו יורק מפורסמת בזכות מוזיאון המטרופוליטן לאומנות.')])
print(scores)

Usage with Transformers AutoModel

You can use the model also directly with Transformers library (without SentenceTransformers library):

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import numpy as np

# Function that applies sigmoid to a score
def sigmoid(x):
    return 1 / (1 + np.exp(-x))

model = AutoModelForSequenceClassification.from_pretrained('HeTree/HeCross')
tokenizer = AutoTokenizer.from_pretrained('HeTree/HeCross')
features = tokenizer(['כמה אנשים חיים בברלין?', 'כמה אנשים חיים בברלין?'],
                     ['ברלין מונה 3,520,031 תושבים רשומים בשטח של 891.82 קמ"ר.', 'העיר ניו יורק מפורסמת בזכות מוזיאון המטרופוליטן לאומנות.'],
                     padding=True, truncation=True, return_tensors="pt")
model.eval()
with torch.no_grad():
    scores = sigmoid(model(**features).logits)
    print(scores)

Zero-Shot Classification

This model can also be used for zero-shot-classification:

from transformers import pipeline
classifier = pipeline("zero-shot-classification", model='HeTree/HeCross')
sent = "בשבוע שעבר שדרגתי את גרסת  הטלפון שלי ."
candidate_labels = ["נייד לשיחות", "אתר", "חיוב חשבון", "גישה לחשבון בנק"]
res = classifier(sent, candidate_labels)
print(res)

Citing

If you use HeCross in your research, please cite Mevaker: Conclusion Extraction and Allocation Resources for the Hebrew Language.

@article{shalumov2024mevaker,
      title={Mevaker: Conclusion Extraction and Allocation Resources for the Hebrew Language}, 
      author={Vitaly Shalumov and Harel Haskey and Yuval Solaz},
      year={2024},
      eprint={2403.09719},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
Downloads last month
20
Safetensors
Model size
125M params
Tensor type
F32
·
Inference API
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Dataset used to train HeTree/HeCross