domenicrosati's picture
Update README.md
ae6b54e
---
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.']`