Views
No views yet
metaphor_type == "met") are labeled positive.0 = non_metaphor, 1 = metaphor| Fragment | Genre | Tokens | Gold metaphors |
|---|---|---|---|
| a1e-fragment01 | News | 671 | 86 |
| a3k-fragment11 | News | 1,413 | 186 |
| a7s-fragment03 | News | 983 | 121 |
| amm-fragment02 | Academic | 4,313 | 491 |
| b17-fragment02 | Academic | 1,806 | 256 |
| ccw-fragment03 | Fiction | 2,443 | 181 |
| faj-fragment17 | Fiction | 5,049 | 290 |
| fpb-fragment01 | Fiction | 5,012 | 447 |
| kbd-fragment21 | Conversation | 3,299 | 208 |
| kcu-fragment02 | Conversation | 4,252 | 243 |
| Parameter | Value |
|---|---|
| Loss | Cross-Entropy |
| Epochs | 4 |
| Learning rate | 2e-5 |
| Batch size | 2 |
| Gradient accumulation steps | 8 (effective batch 16) |
| Max sequence length | 192 |
| Optimizer / scheduler | AdamW, linear decay |
| Metric | Value |
|---|---|
| F1 | 77.03 |
| Precision | 79.12 |
| Recall | 75.05 |
| Accuracy | 96.16 |
a*; Academic: amm, b17; Fiction: ccw, faj, fpb; Conversation: k*).| Genre | Docs | Tokens | Metaphors | Precision | Recall | F1 | Accuracy |
|---|---|---|---|---|---|---|---|
| News | 3 | 3,067 | 393 | 84.32 | 90.33 | 87.22 | 96.61 |
| Fiction | 3 | 12,504 | 918 | 80.11 | 80.28 | 80.20 | 97.09 |
| Academic | 2 | 6,119 | 747 | 82.45 | 66.67 | 73.72 | 94.20 |
| Conversation | 2 | 7,551 | 451 | 67.36 | 64.97 | 66.14 | 96.03 |
| Fragment | Genre | Tokens | Metaphors | Precision | Recall | F1 |
|---|---|---|---|---|---|---|
| a7s-fragment03 | News | 983 | 121 | 87.60 | 87.60 | 87.60 |
| a3k-fragment11 | News | 1,413 | 186 | 85.71 | 90.32 | 87.96 |
| b17-fragment02 | Academic | 1,806 | 256 | 84.82 | 85.16 | 84.99 |
| fpb-fragment01 | Fiction | 5,012 | 447 | 83.22 | 82.10 | 82.66 |
| faj-fragment17 | Fiction | 5,049 | 290 | 79.10 | 84.83 | 81.86 |
| a1e-fragment01 | News | 671 | 86 | 77.88 | 94.19 | 85.26 |
| ccw-fragment03 | Fiction | 2,443 | 181 | 73.81 | 68.51 | 71.06 |
| amm-fragment02 | Academic | 4,313 | 491 | 80.69 | 57.03 | 66.83 |
| kbd-fragment21 | Conversation | 3,299 | 208 | 70.97 | 63.46 | 67.01 |
| kcu-fragment02 | Conversation | 4,252 | 243 | 64.66 | 66.26 | 65.45 |
| POS | Full name | Tokens | Metaphors | Precision | Recall | F1 |
|---|---|---|---|---|---|---|
| DET | Determiner | 2,145 | 129 | 94.62 | 95.35 | 94.98 |
| ADP | Preposition | 2,308 | 735 | 89.91 | 86.12 | 87.98 |
| PRON | Pronoun | 3,279 | 160 | 89.71 | 76.25 | 82.43 |
| VERB | Verb | 3,149 | 712 | 76.28 | 73.17 | 74.70 |
| ADJ | Adjective | 1,712 | 221 | 77.84 | 68.33 | 72.77 |
| SCONJ | Subord. Conjunction | 583 | 37 | 72.97 | 72.97 | 72.97 |
| ADV | Adverb | 1,228 | 90 | 72.94 | 68.89 | 70.86 |
| NOUN | Noun | 4,216 | 415 | 77.42 | 57.83 | 66.21 |
| AUX | Auxiliary | 2,039 | 4 | 66.67 | 50.00 | 57.14 |
| PART | Particle | 859 | 2 | 33.33 | 50.00 | 40.00 |
| PROPN | Proper noun | 1,081 | 4 | 50.00 | 25.00 | 33.33 |
1{
2 "0": "non_metaphor",
3 "1": "metaphor"
4}word_ids; the first subword of each word is used for prediction.1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4model_path = "tommyleo2077/deberta-v3-large-clause-metaphor" # or local path
5tokenizer = AutoTokenizer.from_pretrained(model_path)
6model = AutoModelForTokenClassification.from_pretrained(model_path)
7model.eval()
8
9words = ["The", "government", "attacked", "the", "proposal", "."]
10inputs = tokenizer(
11 words,
12 is_split_into_words=True,
13 return_tensors="pt",
14 truncation=True,
15 max_length=192,
16)
17word_ids = inputs.word_ids(batch_index=0)
18
19with torch.no_grad():
20 logits = model(**inputs).logits
21preds = logits.argmax(dim=-1)[0].tolist()
22
23word_preds = {}
24for i, wid in enumerate(word_ids):
25 if wid is not None and wid not in word_preds:
26 word_preds[wid] = preds[i]
27
28for i, w in enumerate(words):
29 label = "metaphor" if word_preds.get(i, 0) == 1 else "non_metaphor"
30 print(f"{w}\t{label}")1@book{steen2010method,
2 title = {A Method for Linguistic Metaphor Identification: From {MIP} to {MIPVU}},
3 author = {Steen, Gerard and Dorst, Aletta G. and Herrmann, J. Berenike and Kaal, Anna and Krennmayr, Tina and Pasma, Thea},
4 year = {2010},
5 publisher = {John Benjamins}
6}1@inproceedings{leong2018vua,
2 title = {A Report on the 2018 {VUA} Metaphor Detection Shared Task},
3 author = {Leong, Chee Wee and Beigman Klebanov, Beata and Shutova, Ekaterina},
4 booktitle = {Proceedings of the Workshop on Figurative Language Processing at NAACL-HLT 2018},
5 year = {2018}
6}1@misc{leo2025debertav3largeclausemetaphor,
2 title = {deberta-v3-large-clause-metaphor: Metaphor Detection at Clause Level},
3 author = {Leo, Tommy},
4 year = {2025},
5 howpublished = {\url{https://huggingface.co/tommyleo2077/deberta-v3-large-clause-metaphor}},
6 note = {Contact: 1683619168tl@gmail.com}
7}