# QA model with human like answers

**URL:** <https://discuss.huggingface.co/t/qa-model-with-human-like-answers/30988>\
**Category:** Intermediate\
**Created:** [February 2, 2023, 1:08pm UTC](https://discuss.huggingface.co/t/qa-model-with-human-like-answers/30988 "2023-02-02T13:08:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javierquin](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Javierquin](https://discuss.huggingface.co/u/Javierquin)\
**Post date:** [February 2, 2023, 1:08pm UTC](https://discuss.huggingface.co/t/qa-model-with-human-like-answers/30988/1 "2023-02-02T13:08:09Z")

</div>

Hello, i’m looking for a model that not only answers my questions but also returns an answer in the way that a human would answer it and not just as an extraction of information from the context.

Examples:

Context:  
I have a red jumpsuit and it is available in sizes S, M and L  
Question:  
what color is the jumpsuit?  
Expected answer:  
the jumpsuit is red

Most QA model would answer simply “red”

---

<div class="post-metadata">

**Author:** ![theonerm2](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@theonerm2](https://discuss.huggingface.co/u/theonerm2)\
**Post date:** [February 4, 2023, 4:33pm UTC](https://discuss.huggingface.co/t/qa-model-with-human-like-answers/30988/2 "2023-02-04T16:33:05Z")

</div>

You could maybe use a GPT2 model and prime it with that info. I’d give it a few examples like… prime\_text = “Context: I have a red jumpsuit and it is available in sizes S, M and L. Question: What color is the jumpsuit? Answer: The jumpsuit is red. Context: I have a black jumpsuit and it is available in sizes S, M and L. Question: What color is the jumpsuit? Answer: The jumpsuit is black. Context: I have a blue jump suit and it is available in sizes S, M and L. Question: What color is the jumpsuit? Answer: The jumpsuit is blue.”

After that you could get your prompt however you want. A good example would be as follows.

prompt = “Context: I have a yellow jumpsuit and it is available in sizes, S, M and L. Question: What sizes are available for your jumpsuit?”

Next add the prime\_text and prompt together like this:

final\_prompt = prime\_text + prompt + " Answer:"

Then pass your final prompt to your model. Before you print or send the generated text you could process it like this:

string\_with\_unwanted\_characters = result[0][‘generated\_text’]  
step1 = string\_with\_unwanted\_characters.replace(final\_prompt, “”)  
step2 = step1.split(“Answer”)[1]  
step2 = step2.replace(“Context:”, “”)  
step2 = step2.replace(“Question:”, “”)  
step2 = step2.replace(“Answer:”, “”)  
step3 = step2.split(“.”)[0] +“.”  
After that you can remove other stuff a similar way if needed such as…  
step3 = step3.replace(“\n”, “”)  
step3 = step3.replace(“\t”, “”)  
step3 = step3.replace(“\_”, “”)

Finally output step3.  
print(step3)

I don’t know if this is a good method or not as I’m very new to all this but it seems to work in some situations. You could fine tune a model to be even better for your use case.
