File size: 1,751 Bytes
3b6b954
 
 
 
 
 
ae6b54e
3b6b954
 
 
 
 
 
d0551f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b6b954
d0551f1
 
 
 
 
 
 
 
a7ed627
 
d0551f1
 
 
 
 
 
 
a7ed627
d0551f1
 
 
 
 
 
a7ed627
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
---
language:
- en
tags:
- text2text-generation
datasets:
- domenicrosati/QA2D
widget:
- text: "Where in the world is Carmen Sandiego. She is in Abruzzo"
  example_title: "Where is Carmen Sandiego?"
- text: "Halifax is a city in which province. Nova Scotia"
  example_title: "A Halifact"
---
# Question-Answer to Statement Converter

A question answer pair to statement converter from https://github.com/jifan-chen/QA-Verification-Via-NLI

See:
```
@article{chen2021can,
  title={Can NLI Models Verify QA Systems' Predictions?},
  author={Chen, Jifan and Choi, Eunsol and Durrett, Greg},
  journal={EMNLP Findings},
  year={2021}
}
```

**Note:** I am not the maintainer or orginal author just keeping it here to use huggingface APIs to produce statements from question answer pair for downstream applications.

## TL;DR:
We fine-tune a seq2seq model,
T5-3B (Raffel et al., 2020), using the \\((a, q, d)\\) pairs
annotated by Demszky et al. (2018).

Where a is answer, q is question, and d is declerative sentence (i.e. a statement).

See Appendex B.2 of Chen et al. for more.

## Usage

The prompt should be `{question} {seperator} {answer}` where the seperator is `</s>`.

```python
from transformers import AutoTokenizer,  AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained('domenicrosati/question_converter-3b')
model = AutoModelForSeq2SeqLM.from_pretrained('domenicrosati/question_converter-3b')

question = "Where in the world is Carmen Sandiego?"
answer = "She is in Abruzzo"

prompt = f'{question} </s> {answer}'
input_ids = tokenizer(prompt, return_tensors='pt').input_ids
output_ids = model.generate(input_ids)
responses = tokenizer.batch_decode(output_ids, skip_special_tokens=True)
```
> `['Carmen Sandiego is in Abruzzo.']`