File size: 1,674 Bytes
12013bc
 
 
 
 
 
 
 
 
a0f0917
12013bc
3082743
 
 
 
 
 
 
f2e289c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3082743
 
 
17ae157
 
 
 
f2e289c
 
17ae157
 
 
 
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
---
license: apache-2.0
datasets:
- squad_v2
language:
- en
metrics:
- accuracy
- f1
pipeline_tag: sentence-similarity
---

# Albert-xxl-v1 with SQuAD 2.0 sentences

## Objective

The model was trained as cross-encoder classification model with the objective to re-rank the results in a QA pipline.

## How to use

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer


model = AutoModelForSequenceClassification.from_pretrained("apohllo/albert-xxl-squad-sentences", num_labels=2)
tokenizer = AutoTokenizer.from_pretrained("apohllo/albert-xxl-squad-sentences")

from transformers import pipeline

# Add device=0 if you want to use GPU!
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer, batch_size=16) #, device=0)

sentences = [...]    # some sentences to be re-ranked, wrt to the question
question = "..."     # a question to be asked against the sentences

samples = [{"text": s, "text_pair": question} for s in sentences]
results = classifier(samples)
    
results = [(idx, r["score"]) if r["label"] == 'LABEL_1' else (idx, 1 - r["score"]) 
            for idx, r in enumerate(results)]

top_k = 5
keys_values = sorted(results, key=lambda e: -e[1])[:top_k]
```

## Data

The data from SQuAD 2.0 was sentence-split. The question + the sentence containing the answer was a positive example. 
The question + the remaining sentence from the same Wikipedia passege were treated as hard negative examples.

The table balow reports the classification results on the validation set.

# Results


|                | accuracy | F1       |
|----------------|----------|----------|
|ALBERT-xxlarge  | 97.05    | 84.14    |