File size: 3,878 Bytes
d5cca0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b30358f
 
 
 
 
 
 
 
d5cca0c
abc899d
d5cca0c
ef69456
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f632b52
 
 
 
 
b7ce4cd
f632b52
 
 
 
 
 
 
 
 
b7ce4cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef69456
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
---
dataset_info:
  features:
  - name: uid
    dtype: string
  - name: premise
    dtype: string
  - name: hypothesis
    dtype: string
  - name: label
    dtype:
      class_label:
        names:
          '0': entailment
          '1': neutral
          '2': contradiction
  - name: reason
    dtype: string
  splits:
  - name: train
    num_bytes: 44720719
    num_examples: 100459
  - name: validation
    num_bytes: 663148
    num_examples: 1200
  - name: test
    num_bytes: 657586
    num_examples: 1200
  download_size: 15202058
  dataset_size: 46041453
task_categories:
- text-classification
language:
- en
tags:
- NLI
size_categories:
- 100K<n<1M
---
# The Adversarial Natural Language Inference (ANLI)

- Source: https://huggingface.co/datasets/anli
- Num examples: 
  - 100,459 (train)
  - 1,200 (validation)
  - 1,200 (test)
- Language: English

```python
from datasets import load_dataset

load_dataset("vietgpt/anli_r3_en")
```

- Format for NLI task

```python
def preprocess(sample):
    premise = sample['premise']
    hypothesis = sample['hypothesis']
    label = sample['label']

    if label == 0:
        label = "entailment"
    elif label == 1:
        label = "neutral"
    else:
        label = "contradiction"
    return {'text': f'<|startoftext|><|premise|> {premise} <|hypothesis|> {hypothesis} <|label|> {label} <|endoftext|>'}

"""
<|startoftext|><|premise|> TOKYO, Dec 18 (Reuters) - Japan’s Shionogi & Co said on Tuesday that it has applied to health regulators in the United States, Canada and Europe for approval of its HIV drug Dolutegravir. Shionogi developed Dolutegravir with a Viiv Healthcare, an AIDS drug joint venture between GlaxoSmithKline and Pfizer, in exchange for its rights to the drug. <|hypothesis|> The article was written on December 18th. <|label|> entailment <|endoftext|>
"""
```

- Format for Rationale task

```python
def preprocess_rationale(sample):
    premise = sample['premise']
    hypothesis = sample['hypothesis']
    rationale = sample['reason']

    return {'text': f'<|startoftext|><|premise|> {premise} <|hypothesis|> {hypothesis} <|rationale|> {rationale} <|endoftext|>'}

"""
<|startoftext|><|premise|> TOKYO, Dec 18 (Reuters) - Japan’s Shionogi & Co said on Tuesday that it has applied to health regulators in the United States, Canada and Europe for approval of its HIV drug Dolutegravir. Shionogi developed Dolutegravir with a Viiv Healthcare, an AIDS drug joint venture between GlaxoSmithKline and Pfizer, in exchange for its rights to the drug. <|hypothesis|> The article was written on December 18th. <|rationale|> TOKYO, Dec 18 (Reuters) is when the article was written as it states in the first words of the sentence <|endoftext|>
"""
```

- Format for GPT-3

```python
def preprocess_gpt3(sample):
    premise = sample['premise']
    hypothesis = sample['hypothesis']
    label = sample['label']

    if label == 0:
        output = f'\n<|correct|> True\n<|incorrect|> False\n<|incorrect|> Neither'
    elif label == 1:
        output = f'\n<|correct|> Neither\n<|incorrect|> True\n<|incorrect|> False'
    else:
        output = f'\n<|correct|> False\n<|incorrect|> True\n<|incorrect|> Neither'

    return {'text': f'<|startoftext|> anli 2: {premise} <|question|> {hypothesis}\nTrue, False, or Neither? <|answer|> {output} <|endoftext|>'}

"""
<|startoftext|> anli 2: TOKYO, Dec 18 (Reuters) - Japan’s Shionogi & Co said on Tuesday that it has applied to health regulators in the United States, Canada and Europe for approval of its HIV drug Dolutegravir. Shionogi developed Dolutegravir with a Viiv Healthcare, an AIDS drug joint venture between GlaxoSmithKline and Pfizer, in exchange for its rights to the drug. <|question|> The article was written on December 18th.
True, False, or Neither? <|answer|> 
<|correct|> True
<|incorrect|> False
<|incorrect|> Neither <|endoftext|>
"""
```