Downloads · 30 days
6
6% of all-time downloads
swap-uniba/LLM-wsd-TT-ALL
LLM-wsd-TT-ALL is a machine learning model from swap-uniba. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as llama3.1.
LLM-wsd-TT-ALL is a Large Language Model (LLM) instruction-tuned over meta-llama/Meta-Llama-3.1-8B-Instruct. This model has been trained for the WSD task over the entire training dataset, with machine-translation. It…
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
106
Public
Parameters
8B
16.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
LLM-wsd-TT-ALL is a Large Language Model (LLM) instruction-tuned over meta-llama/Meta-Llama-3.1-8B-Instruct. This model has been trained for the WSD task over the entire training dataset, with machine-translation. It is capable of providing the definition of a word in a given sentence. Specifically, it can answer both:
More details regarding the training procedure (e.g. hyperparameters, dataset construction, and so on) can be found in Section 4.2 of the paper.
The model has been trained using several instructions depending on language, task (open-ended or closed-ended) and number of occurences of target word in the sentence. In Instructions, we provide the instructions used for all cases. The following placeholder variables have to be replaced:
Please note that the complete prompt also has the following string after the instruction:
" Input: \"{sentence}\""
where {sentence} is the input sentence containing the word to disambiguate.
Below you can find two examples of model usage, for open-ended and closed-ended generation respectively.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.trainer_utils import set_seed
target_word = "long"
instruction = f"Give a brief definition of the word \"{target_word}\" in the sentence given as input. Generate only the definition."
input_sentence = "How long has it been since you reviewed the objectives of your benefit and service program?"
model_id = "swap-uniba/LLM-wsd-TT-ALL"
set_seed(42)
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
tokenizer.padding_side = "left"
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map='cuda',
torch_dtype=torch.bfloat16,
).eval()
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
messages = [
{"role": "user", "content": instruction + " Input: \"" + input_sentence + "\""},
]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(
input_ids.to('cuda'),
max_new_tokens=512,
eos_token_id=terminators,
num_beams=1,
do_sample=False
)
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.trainer_utils import set_seed
target_word = "hurry"
instruction = f"Given the word \"{target_word}\" in the input sentence, choose the correct meaning from the following:\n1) Move very fast\n2) Urge to an unnatural speed\n\nGenerate only the number of the selected option."
input_sentence = "If you hurry you might beat the headquarters boys."
model_id = "swap-uniba/LLM-wsd-TT-ALL"
set_seed(42)
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
tokenizer.padding_side = "left"
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map='cuda',
torch_dtype=torch.bfloat16,
).eval()
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
messages = [
{"role": "user", "content": instruction + " Input: \"" + input_sentence + "\""},
]
input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(
input_ids.to('cuda'),
max_new_tokens=512,
eos_token_id=terminators,
num_beams=1,
do_sample=False
)
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
If you use this model in your research, please cite the following:
@misc{basile2025exploringwordsensedisambiguation,
title={Exploring the Word Sense Disambiguation Capabilities of Large Language Models},
author={Pierpaolo Basile and Lucia Siciliani and Elio Musacchio and Giovanni Semeraro},
year={2025},
eprint={2503.08662},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2503.08662},
}
"Give a brief definition of the word \"{target_word}\" in the sentence given as input. Generate only the definition."
"Donnez une brève définition du mot \"{target_word}\" dans la phrase d’entrée donnée. Ne donnez que la définition."
"Geben Sie eine kurze Definition des Wortes \"{target_word}\" in dem gegebenen Satz an. Erzeugen Sie nur die Definition."
"Fornisci una breve definizione della parola \"{target_word}\" nella frase data in input. Genera solo la definizione."
"Proporciona una definición breve de la palabra \"{target_word}\" en la frase dada en entrada. Genera solo la definición."
"Give a brief definition of the {occurrence} occurrence of the word \"{target_word}\" in the sentence given as input. Generate only the definition."
"Donnez une brève définition de l'occurrence {occurrence} du mot \"{target_word}\" dans la phrase d’entrée donnée. Ne donnez que la définition."
"Geben Sie eine kurze Definition des {occurrence} Vorkommens des Wortes \"{target_word}\" in dem gegebenen Eingabesatz an. Erzeugen Sie nur die Definition."
"Fornisci una breve definizione della {occurrence} occorrenza della parola \"{target_word}\" nella frase data in input. Genera solo la definizione."
"Proporciona una definición breve de la {occurrence} ocurrencia de la palabra \"{target_word}\" en la frase dada en entrada. Genera solo la definición."
"Given the word \"{target_word}\" in the input sentence, choose the correct meaning from the following:\n{options}\n\nGenerate only the number of the selected option."
"Étant donné le mot \"{target_word}\" dans la phrase saisie, choisissez la signification correcte parmi les suivantes:\n{options}\n\nNe donnez que le numéro de l’option sélectionnée."
"Wählen Sie für das Wort \"{target_word}\" im Eingabesatz die richtige Bedeutung aus den folgenden Angaben:\n{options}\n\nErzeugt nur die Nummer der ausgewählten Option"
"Data la parola \"{target_word}\" nella frase in input, scegli il significato corretto tra i seguenti:\n{options}\n\nGenera solo il numero dell'opzione selezionata."
"Dada la palabra \"{target_word}\" en la frase de entrada, elija el significado correcto entre los siguientes:\n{options}\n\nGenera solo el número de la opción seleccionada."
"Given the word \"{target_word}\" in the input sentence, choose the correct meaning from the following:\n{options}\n\nGenerate only the number of the selected option."
"Étant donné l'occurrence {occurrence} du mot \"{target_word}\" dans la phrase d'entrée, choisissez la signification correcte parmi les suivantes:\n{options}\n\nNe donnez que le numéro de l’option sélectionnée."
"Wählen Sie angesichts des {occurrence} Vorkommens des Wortes \"{target_word}\" im Eingabesatz die richtige Bedeutung aus der folgenden Liste aus:\n{options}\n\nErzeugt nur die Nummer der ausgewählten Option."
"Data la {occurrence} occorrenza della parola \"{target_word}\" nella frase in input, scegli il significato corretto tra i seguenti:\n{options}\n\nGenera solo il numero dell'opzione selezionata."
"Dada la {occurrence} ocurrencia de la palabra \"{target_word}\" en la frase de entrada, elije el significado correcto entre los siguientes:\n{options}\n\nGenera solo el número de la opción seleccionada."