QA2D / README.md
Farnazgh's picture
Update README.md
a37df3c
|
raw
history blame
2.72 kB
metadata
language:
  - en
datasets:
  - SAMSum
metrics:
  - ROUGE-L
tags:
  - Question answering
  - T5
  - Declarative
  - Text generation
widget:
  - text: >-
      q: do you have any hobbies that you like to do while you are at home ? a:
      watching online shows
  - text: >-
      q: do you watch a lot of comedy ? a: yes it will helpful the mind
      relaxation

Transforming Question-Answer Pairs to Full Declarative Answer Form

Considering the question of "Which drug did you take?" and the answer of "Doliprane", the aim of this model is to derive a full answer to the question "I took Doliprane".

Model training

We fine-tune T5 (Raffel et al.,2019), a pre-trained encoder-decoder model, on two datasets of (question, incomplete answer, full answer) triples, one for wh- and one for yes-no(YN) questions. For wh-questions, we use 3,300 entries of the dataset consisting of (question, answer, declarative answer sentence) triples gathered by Demszky et al. (2018) using Amazon Mechanical Turk workers. For YN questions, we used the SAMSum corpus, (Gliwa et al., 2019) which contains short dialogs in chit-chat format. We created 1,100 (question, answer, full answer) triples by au- tomatically extracting YN (question, answer) pairs from this corpus and manually associating them with the corresponding declarative answer. Data was splitted into train and test (9:1) and the fine- tuned model achieved 0.90 ROUGE-L score on the test set.

Model Details

Model was developed as one of the proposed modules in the following paper for dialog transformation.

"F. Ghassemi Toudeshki, A. Liednikova, P Jolivet and C. Gardent, Exploring the Influence of Dialog Input Format for Unsupervised Clinical Questionnaire Filling, Proceedings of the 13th International Workshop on Health Text Mining and Information Analysis (co-located with EMNLP 2022), Abu Dhabi, 7 December 2022."

It was used to transform question-answer paris in information-seeking dialogs to declarative form and at the end to have the declarative transform of the whole dialog.

Test the model

!pip install transformers
!pip install sentencepiece
from transformers import AutoModelWithLMHead, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("Farnazgh/QA2D")
model = AutoModelWithLMHead.from_pretrained("Farnazgh/QA2D")

def transform_qa2d(question, answer, max_length=150):
  
  text = "q: "+question+" a: "+answer
  input_ids = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True)
  generated_ids = model.generate(input_ids=input_ids, num_beams=2, max_length=max_length, early_stopping=True)[0]
  preds = tokenizer.decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)

  return preds