--- language: - he pipeline_tag: zero-shot-classification datasets: - HeTree/MevakerConcTree license: apache-2.0 widget: - text: "בשבוע שעבר שדרגתי את גרסת הטלפון שלי ." candidate_labels: "נייד לשיחות , חיוב חשבון , חולה על כדורגל" multi_class: false example_title: "שדרוג מכשיר" --- # Hebrew Cross-Encoder Model ## Usage ```python 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): ```python 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: ```python 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](https://arxiv.org/abs/2403.09719). ``` @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} } ```