File size: 13,090 Bytes
26b46c0
 
fc743ec
 
 
 
 
26b46c0
d069798
fc743ec
 
e0ae669
5dc088a
b5c1274
5b28de0
30be815
 
 
5d5ae7a
30be815
864cf7c
 
 
 
 
 
 
 
 
30be815
18eb22c
0fcd9a7
e61d685
864cf7c
 
 
 
 
 
30be815
864cf7c
30be815
 
864cf7c
30be815
864cf7c
 
4070c70
30be815
864cf7c
 
30be815
 
 
864cf7c
 
 
30be815
 
 
864cf7c
 
 
 
 
 
 
 
 
 
 
30be815
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
864cf7c
30be815
 
 
 
 
864cf7c
497b810
e0ae669
7068ade
e0ae669
2d7e780
4946b33
12a6fed
 
 
 
 
 
 
 
 
 
e42769f
12a6fed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4fa6dc
51cc6c6
 
 
 
 
 
 
 
 
0979f85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51cc6c6
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
---
license: llama2
datasets:
- Universal-NER/Pile-NER-type
language:
- en
pipeline_tag: text-generation
---

# SLIMER: Show Less Instruct More Entity Recognition

SLIMER is an LLM specifically instructed for zero-shot NER.

Instructed on a reduced number of samples, 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.

<!DOCTYPE html>
<html>
<head>
    <title>Instruction Tuning Prompt</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 14px;
            text-align: center;
            margin: 0; /* Remove default margin */
            min-height: 100vh; /* Ensure full viewport height coverage */
            display: flex;
            flex-direction: column;
        }
        .container {
            border: none;
            padding: 5px;
            width: 300px;
            margin: auto;
            border-radius: 10px;
            overflow: hidden;
            flex: 1; /* Take up remaining vertical space */
            display: flex;
            flex-direction: column;
        }
        .header {
            background-color: black;
            color: white;
            padding: 10px;
            font-weight: bold;
            border-top-left-radius: 10px;
            border-top-right-radius: 10px;
        }
        .content {
            flex: 1;
            padding: 10px;
        }
        .definition {
            background-color: #ccffcc;
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 10px;
        }
        .guidelines {
            background-color: #ffffcc;
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 10px;
        }
        .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><b>[INST]</b></p>
            <p>You are given a text chunk (delimited by triple quotes) and an instruction.<br>
            Read the text and answer to the instruction in the end.</p>
            <p>"""<br>
            {input text}<br>
            """</p>
            <p><b>Instruction:</b> Extract the Named Entities of type <b>DATE</b> from the text chunk you have read.</p>
            <p>You are given a <b>DEFINITION</b> and some <b>GUIDELINES</b>.</p>
            <div class="definition">
                <p><b>DEFINITION:</b> <b>DATE</b> refers to specific points in time, including days, months, years, and relative time expressions like 'Week 2'.</p>
            </div>
            <div class="guidelines">
                <p><b>GUIDELINES:</b> Avoid labeling non-specific time references like 'recently' or 'soon'. Exercise caution with ambiguous terms like 'May' (month or verb) and 'Wednesday Adams' (person's name which includes a day of the week).</p>
            </div>
            <p>Return a JSON list of instances of this Named Entity type. Return an empty list if no instances are present.</p>
            <p><b>[/INST]</b></p>
        </div>
        <div class="footer">Footer content</div>
    </div>
</body>
</html>



Currently existing approaches fine-tune on an extensive number of entity classes (around 13K) and assess zero-shot NER capabilities on Out-Of-Distribution input domains.
SLIMER performs comparably to these state-of-the-art models on OOD input domains, while being trained only a reduced number of samples and a set of NE tags that overlap in lesser degree with test sets.

We extend the standard zero-shot evaluations (CrossNER and MIT) with BUSTER, which is characterized by financial entities that are rather far from the more traditional tags observed by all models during training.
An inverse trend can be observed, with SLIMER emerging as the most effective in dealing with these unseen labels, thanks to its lighter instruction tuning methodology and the use of definition and guidelines.

<!DOCTYPE html>
<html>
<head>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12px;
        }
        th, td {
            border: 1px none;
            padding: 4px;
            text-align: center;
        }
        th {
            background-color: #f2f2f2;
        }
        .col-model { width: 10%; }
        .col-backbone { width: 15%; }
        .col-params { width: 10%; }
        .col-mit, .col-crossner, .col-buster, .col-avg { width: 7%; }
    </style>
</head>
<body>

<table>
    <thead>
        <tr>
            <th class="col-model">Model</th>
            <th class="col-backbone">Backbone</th>
            <th class="col-params">#Params</th>
            <th class="col-mit" colspan="2">MIT</th>
            <th class="col-crossner" colspan="5">CrossNER</th>
            <th class="col-buster">BUSTER</th>
            <th class="col-avg">AVG</th>
        </tr>
        <tr>
            <th></th>
            <th></th>
            <th></th>
            <th class="col-mit">Movie</th>
            <th class="col-mit">Restaurant</th>
            <th class="col-crossner">AI</th>
            <th class="col-crossner">Literature</th>
            <th class="col-crossner">Music</th>
            <th class="col-crossner">Politics</th>
            <th class="col-crossner">Science</th>
            <th class="col-buster"></th>
            <th class="col-avg"></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="col-model">ChatGPT</td>
            <td class="col-backbone">gpt-3.5-turbo</td>
            <td class="col-params">-</td>
            <td class="col-mit">5.3</td>
            <td class="col-mit">32.8</td>
            <td class="col-crossner">52.4</td>
            <td class="col-crossner">39.8</td>
            <td class="col-crossner">66.6</td>
            <td class="col-crossner">68.5</td>
            <td class="col-crossner">67.0</td>
            <td class="col-buster">-</td>
            <td class="col-avg">-</td>
        </tr>
        <tr>
            <td class="col-model">InstructUIE</td>
            <td class="col-backbone">Flan-T5-xxl</td>
            <td class="col-params">11B</td>
            <td class="col-mit">63.0</td>
            <td class="col-mit">21.0</td>
            <td class="col-crossner">49.0</td>
            <td class="col-crossner">47.2</td>
            <td class="col-crossner">53.2</td>
            <td class="col-crossner">48.2</td>
            <td class="col-crossner">49.3</td>
            <td class="col-buster">-</td>
            <td class="col-avg">-</td>
        </tr>
        <tr>
            <td class="col-model">UniNER-type</td>
            <td class="col-backbone">LLaMA-1</td>
            <td class="col-params">7B</td>
            <td class="col-mit">42.4</td>
            <td class="col-mit">31.7</td>
            <td class="col-crossner">53.5</td>
            <td class="col-crossner">59.4</td>
            <td class="col-crossner">65.0</td>
            <td class="col-crossner">60.8</td>
            <td class="col-crossner">61.1</td>
            <td class="col-buster">34.8</td>
            <td class="col-avg">51.1</td>
        </tr>
        <tr>
            <td class="col-model">UniNER-def</td>
            <td class="col-backbone">LLaMA-1</td>
            <td class="col-params">7B</td>
            <td class="col-mit">27.1</td>
            <td class="col-mit">27.9</td>
            <td class="col-crossner">44.5</td>
            <td class="col-crossner">49.2</td>
            <td class="col-crossner">55.8</td>
            <td class="col-crossner">57.5</td>
            <td class="col-crossner">52.9</td>
            <td class="col-buster">33.6</td>
            <td class="col-avg">43.6</td>
        </tr>
        <tr>
            <td class="col-model">UniNER-type+sup.</td>
            <td class="col-backbone">LLaMA-1</td>
            <td class="col-params">7B</td>
            <td class="col-mit">61.2</td>
            <td class="col-mit">35.2</td>
            <td class="col-crossner">62.9</td>
            <td class="col-crossner">64.9</td>
            <td class="col-crossner">70.6</td>
            <td class="col-crossner">66.9</td>
            <td class="col-crossner">70.8</td>
            <td class="col-buster">37.8</td>
            <td class="col-avg">58.8</td>
        </tr>
        <tr>
            <td class="col-model">GoLLIE</td>
            <td class="col-backbone">Code-LLaMA</td>
            <td class="col-params">7B</td>
            <td class="col-mit">63.0</td>
            <td class="col-mit">43.4</td>
            <td class="col-crossner">59.1</td>
            <td class="col-crossner">62.7</td>
            <td class="col-crossner">67.8</td>
            <td class="col-crossner">57.2</td>
            <td class="col-crossner">55.5</td>
            <td class="col-buster">27.7</td>
            <td class="col-avg">54.6</td>
        </tr>
        <tr>
            <td class="col-model">GLiNER-L</td>
            <td class="col-backbone">DeBERTa-v3</td>
            <td class="col-params">0.3B</td>
            <td class="col-mit">57.2</td>
            <td class="col-mit">42.9</td>
            <td class="col-crossner">57.2</td>
            <td class="col-crossner">64.4</td>
            <td class="col-crossner">69.6</td>
            <td class="col-crossner">72.6</td>
            <td class="col-crossner">62.6</td>
            <td class="col-buster">26.6</td>
            <td class="col-avg">56.6</td>
        </tr>
        <tr>
            <td class="col-model">GNER-T5</td>
            <td class="col-backbone">Flan-T5-xxl</td>
            <td class="col-params">11B</td>
            <td class="col-mit">62.5</td>
            <td class="col-mit">51.0</td>
            <td class="col-crossner">68.2</td>
            <td class="col-crossner">68.7</td>
            <td class="col-crossner">81.2</td>
            <td class="col-crossner">75.1</td>
            <td class="col-crossner">76.7</td>
            <td class="col-buster" style="color: red;">27.9</td>
            <td class="col-avg">63.9</td>
        </tr>
        <tr>
            <td class="col-model">GNER-LLaMA</td>
            <td class="col-backbone">LLaMA-1</td>
            <td class="col-params">7B</td>
            <td class="col-mit">68.6</td>
            <td class="col-mit">47.5</td>
            <td class="col-crossner">63.1</td>
            <td class="col-crossner">68.2</td>
            <td class="col-crossner">75.7</td>
            <td class="col-crossner">69.4</td>
            <td class="col-crossner">69.9</td>
            <td class="col-buster" style="color: red;">23.6</td>
            <td class="col-avg">60.8</td>
        </tr>
        <tr>
            <td class="col-model">SLIMER w/o D&amp;G</td>
            <td class="col-backbone">LLaMA-2-chat</td>
            <td class="col-params">7B</td>
            <td class="col-mit">46.4</td>
            <td class="col-mit">36.3</td>
            <td class="col-crossner">49.6</td>
            <td class="col-crossner">58.4</td>
            <td class="col-crossner">56.8</td>
            <td class="col-crossner">57.9</td>
            <td class="col-crossner">53.8</td>
            <td class="col-buster">40.4</td>
            <td class="col-avg">49.9</td>
        </tr>
        <tr>
            <td class="col-model"><b>SLIMER</b></td>
            <td class="col-backbone"><b>LLaMA-2-chat</b></td>
            <td class="col-params"><b>7B</b></td>
            <td class="col-mit"><b>50.9</b></td>
            <td class="col-mit"><b>38.2</b></td>
            <td class="col-crossner"><b>50.1</b></td>
            <td class="col-crossner"><b>58.7</b></td>
            <td class="col-crossner"><b>60.0</b></td>
            <td class="col-crossner"><b>63.9</b></td>
            <td class="col-crossner"><b>56.3</b></td>
            <td class="col-buster"><b>45.3</b></td>
            <td class="col-avg"><b>52.9</b></td>
        </tr>
    </tbody>
</table>

</body>
</html>


```python
from vllm import LLM, SamplingParams

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

sampling_params = SamplingParams(temperature=0, max_tokens=128, stop=['</s>'])

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 useful in your research or work, please cite the following paper:

``` latex
@misc{zamai2024lessinstructmoreenriching,
      title={Show Less, Instruct More: Enriching Prompts with Definitions and Guidelines for Zero-Shot NER}, 
      author={Andrew Zamai and Andrea Zugarini and Leonardo Rigutini and Marco Ernandes and Marco Maggini},
      year={2024},
      eprint={2407.01272},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2407.01272}, 
}
```