Views
No views yet

| Model | Hypernym Discovery (Eng., MRR) | Hypernym Discovery (Span., MRR) | Taxonomy Construction (Enivornment, F1) | Taxonomy Enrichment (WordNet Verb, MRR) |
|---|---|---|---|---|
| TaxoLLaMA | 54.39 | 58.61 | 45.13 | 52.4 |
| TaxoLLaMA-bench | 51.39 | 57.44 | 44.82 | 51.9 |
| Previous SoTA | 45.22 | 37.56 | 40.00 | 45.2 |
<s>[INST] <<SYS>> You are a helpfull assistant. List all the possible words divided with a coma. Your answer should not include anything except the words divided by a coma<</SYS>>
hyponym: tiger (large feline of forests in most of Asia having a tawny coat with black stripes)| hypernyms: [/INST]1import torch
2from transformers import LlamaForCausalLM, LlamaTokenizer
3from peft import PeftConfig, PeftModel
4
5torch.set_default_device('cuda')
6config = PeftConfig.from_pretrained('VityaVitalich/TaxoLLaMA')
7# Do not forget your token for Llama2 models
8model = LlamaForCausalLM.from_pretrained(config.base_model_name_or_path, load_in_4bit=True, torch_dtype=torch.bfloat16)
9tokenizer = LlamaTokenizer.from_pretrained(config.base_model_name_or_path)
10inference_model = PeftModel.from_pretrained(model, 'VityaVitalich/TaxoLLaMA')
11
12processed_term = "hyponym: tiger | hypernyms:"
13
14system_prompt = """<s>[INST] <<SYS>> You are a helpfull assistant. List all the possible words divided with a coma. Your answer should not include anything except the words divided by a coma<</SYS>>"""
15processed_term = system_prompt + '\n' + processed_term + '[/INST]'
16
17input_ids = tokenizer(processed_term, return_tensors='pt')
18
19# This is an example of generation hyperparameters, they could be modified to fit your task
20gen_conf = {
21 "no_repeat_ngram_size": 3,
22 "do_sample": True,
23 "num_beams": 8,
24 "num_return_sequences": 2,
25 "max_new_tokens": 32,
26 "top_k": 20,
27 }
28
29out = inference_model.generate(inputs=input_ids['input_ids'].to('cuda'), **gen_conf)
30
31text = tokenizer.batch_decode(out)[0][len(system_prompt):]
32print(text)
33@misc{moskvoretskii2024taxollama,
title={TaxoLLaMA: WordNet-based Model for Solving Multiple Lexical Sematic Tasks},
author={Viktor Moskvoretskii and Ekaterina Neminova and Alina Lobanova and Alexander Panchenko and Irina Nikishina},
year={2024},
eprint={2403.09207},
archivePrefix={arXiv},
primaryClass={cs.CL}
}