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}
}