pierluigic's picture
Update README.md
a8a150f verified
|
raw
history blame
2.46 kB
metadata
license: apache-2.0
widget:
  - text: WN results
    output:
      url: cfn.svg

Cross-Encoder for Word Sense Relationships Classification

This model was trained on word sense relationships extracted by WordNet for the semantic change type classification.

The model can be used to detect which kind of relatioships (among homonymy, antonymy, hypernonym, hyponymy, and co-hypnomy) intercur between word senses: Given a pair of word sense definitions, encode the query will all possible passages (e.g. retrieved with ElasticSearch). Then sort the passages in a decreasing order.

The training code is available here: SBERT.net Training MS Marco

Citation

@inproceedings{change_type_classification_cassotti_2024,
  author    = {Pierluigi Cassotti and
               Stefano De Pascale and
               Nina Tahmasebi},
  title     = {Using Synchronic Definitions and Semantic Relations to Classify Semantic Change Types},
  year      = {2024},
}

Usage with Transformers

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model = AutoModelForSequenceClassification.from_pretrained('ChangeIsKey/change-type-classifier')
tokenizer = AutoTokenizer.from_pretrained('ChangeIsKey/change-type-classifier')


features = tokenizer([['to quickly take something in your hand(s) and hold it firmly', 'to understand something, especially something difficult'], ['To move at a leisurely and relaxed pace, typically by foot', 'To move or travel, irrespective of the mode of transportation']],  padding=True, truncation=True, return_tensors="pt")

model.eval()
with torch.no_grad():
    scores = model(**features).logits
    print(scores)

Usage with SentenceTransformers

The usage becomes easier when you have SentenceTransformers installed. Then, you can use the pre-trained models like this:

from sentence_transformers import CrossEncoder
model = CrossEncoder('ChangeIsKey/change-type-classifier', max_length=512)
labels = model.predict([('to quickly take something in your hand(s) and hold it firmly', 'to understand something, especially something difficult'), ('To move at a leisurely and relaxed pace, typically by foot', 'To move or travel, irrespective of the mode of transportation')])