File size: 6,061 Bytes
a7b3125
 
 
 
 
b753752
 
 
 
 
 
 
cbe0540
 
b753752
a7b3125
 
 
 
 
 
e181973
3a567d2
a7b3125
 
78dc861
8bcc609
a7b3125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eae2ed1
a7b3125
 
7b97ed2
a7b3125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3263898
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901362b
3263898
 
 
 
 
 
a7b3125
 
 
 
 
 
 
 
 
2030469
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a7b3125
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
language:
- it
pipeline_tag: text-generation
license: llama3
tags:
- facebook
- meta
- pythorch
- llama
- llama-3
- llamantino
- zero-shot NER
- NER
base_model: swap-uniba/LLaMAntino-3-ANITA-8B-Inst-DPO-ITA
---

# SLIMER-IT: Show Less Instruct More Entity Recognition - Italian language

SLIMER-IT is an LLM specifically instructed for zero-shot NER on Italian language.

Github repository: https://github.com/andrewzamai/SLIMER_IT

Instructed on a reduced number of tags (PER, ORG, LOC), it is designed to tackle never-seen-before Named Entity tags by leveraging a prompt enriched with a DEFINITION and GUIDELINES for the NE to be extracted.

Built with Meta Llama 3, based on the Italian instruction-tuned version swap-uniba/LLaMAntino-3-ANITA-8B-Inst-DPO-ITA

<!DOCTYPE html>
<html>
<head>
    <title>Instruction Tuning Prompt</title>
    <style>
        .container {
            border: none;
            padding: 5px;
            width: 300px;
            margin: 0 auto;
            font-family: Arial, sans-serif;
            font-size: 8px;
            border-radius: 10px; /* Rounded borders for container */
            overflow: hidden; /* Ensure child elements respect container's rounded borders */
        }
        .header {
            background-color: black;
            color: white;
            padding: 5px;
            text-align: center;
            font-weight: bold;
            font-size: 14px;
            border-top-left-radius: 10px; /* Rounded top-left corner */
            border-top-right-radius: 10px; /* Rounded top-right corner */
        }
        .content {
            padding: 5px;
        }
        .definition, .guidelines {
            padding: 5px;
            border-radius: 10px; /* Rounded borders for definition and guidelines */
        }
        .definition {
            background-color: #ffa3f0;
        }
        .guidelines {
            background-color: #93e2fa;
        }
        .footer {
            background-color: black;
            color: white;
            padding: 10px;
            font-weight: bold;
            border-bottom-left-radius: 10px;
            border-bottom-right-radius: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">Instruction Tuning Prompt</div>
        <div class="content">
            <p>Ti viene fornito un input di testo (delimitato da tre virgolette) e un'istruzione.<br>
            Leggi il testo e rispondi all'istruzione alla fine.</p>
            <p>"""<br>
            {input di testo}<br>
            """</p>
            <p><b>Istruzione:</b> Estrai tutte le entità di tipo <b>ENTITÀ MITOLOGICA</b> dal testo che hai letto.</p>
            <p>Ti vengono fornite una <b>DEFINIZIONE</b> e alcune <b>LINEE GUIDA</b>.</p>
            <div class="definition">
                <p><b>DEFINIZIONE:</b> <b>ENTITÀ MITOLOGICA</b> denota personaggi, divinità, creature o figure mitologiche provenienti da tradizioni religiose, miti, leggende o folklore.</p>
            </div>
            <div class="guidelines">
                <p><b>LINEE GUIDA:</b> Assicurati di non etichettare come ENTITÀ MITOLOGICA personaggi storici o letterari reali. Ad esempio, 'Alessandro Magno' è un personaggio storico, non una figura mitologica. Inoltre, fai attenzione a distinguere nomi comuni o nomi di luoghi che possono riferirsi anche a figure mitologiche, come 'Diana', che può essere un nome proprio e il nome della dea romana della caccia.</p>
            </div>
            <p>Restituisci una lista JSON di istanze di questo tipo. Restituisci una lista vuota se non sono presenti istanze.</p>
        </div>
        <div class="footer"></div>
    </div>
</body>
</html>


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON Template</title>
<style>
  body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    padding: 20px;
  }
  .description {
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
  }
  .template {
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
  }
  .highlight-orange {
    color: orange;
    font-weight: bold;
  }
</style>
</head>
<body>
  <div class="description">JSON SLIMER-IT prompt</div>
  <div class="template">
    <pre>{
  "description": "SLIMER prompt for Italian",
  "prompt_input": "<|start_header_id|>system<|end_header_id|>\n\n Sei un utile assistente.<|eot_id|>\n<|start_header_id|>user<|end_header_id|>\n\nTi viene fornito un input di testo (delimitato da tre virgolette) e un'istruzione. \nLeggi il testo e rispondi all'istruzione alla fine.\n\"\"\"\n{<span class="highlight-orange">input</span>}\n\"\"\"\nIstruzione: Estrai tutte le entità di tipo {<span class="highlight-orange">NE_name</span>} dal testo che hai letto. Ti vengono fornite una DEFINIZIONE e alcune LINEE GUIDA.\nDEFINIZIONE: {<span class="highlight-orange">definition</span>}\nLINEE GUIDA: {<span class="highlight-orange">guidelines</span>}\nRestituisci una lista JSON di istanze di questo tipo. Restituisci una lista vuota se non sono presenti istanze.<|eot_id|>\n<|start_header_id|>assistant<|end_header_id|>\n\n"
  }</pre>
  </div>
</body>
</html>


```python
from vllm import LLM, SamplingParams

vllm_model = LLM(model="expertai/SLIMER-IT")

sampling_params = SamplingParams(temperature=0, max_tokens=128)

prompts = [prompter.generate_prompt(instruction, input) for instruction, input in instruction_input_pairs]
responses = vllm_model.generate(prompts, sampling_params)
```

## Citation

If you find SLIMER-IT useful in your research or work, please cite the following paper:

``` latex
@misc{zamai2024slimeritzeroshotneritalian,
      title={SLIMER-IT: Zero-Shot NER on Italian Language}, 
      author={Andrew Zamai and Leonardo Rigutini and Marco Maggini and Andrea Zugarini},
      year={2024},
      eprint={2409.15933},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2409.15933}, 
}
```