Downloads · 30 days
26
3% of all-time downloads
gaussalgo/mt5-large-priming-QA_en-cs
mt5-large-priming-QA_en-cs is a machine learning model from gaussalgo. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This is the mt5-large model with an LM head for a generation of extractive answers, given a small set of 2-5 demonstrations (i.e. primes).
Downloads · 30 days
26
3% of all-time downloads
All-time downloads
876
Public
Parameters
1.2B
9.9 GB on disk
Likes
0
Public
Click a slice to open those files.
.bin4.9 GB · 50%
From the Hugging Face model README
This is the mt5-large model with an LM head for a generation of extractive answers, given a small set of 2-5 demonstrations (i.e. primes).
Note that this is primarily a few-shot model that expects a set of demonstrations of your task of interest, similarly to GPT-3. Rather than performing well on the conventional question answering, it aims to learn to extrapolate the pattern of given demonstrations to novel tasks, such as Named Entity Recognition or Keywords Extraction from a given pattern. However, it can be also used as conventional QA model (see examples).
The reproducible training script is available for any use on our Github.
This model was trained on a combination of AdversarialQA and Czech SQAD 3.0 Question Answering datasets.
To train the model to use the demonstrations, we've clustered the samples by the question-word(s) in English AdversarialQA and by the category in the Czech SQAD and used the examples of the same cluster as the demonstrations of the task in training.
We find that the specific algorithm of selection of these demonstrations is crucial for the model's ability to extrapolate to new tasks. We'll share more details in the following article; stay tuned!
For the Czech SQAD 3.0, original contexts (=whole Wikipedia websites) were limited to a maximum of 4000 characters per a sequence of prime demonstrations. Pre-processing script for Czech SQAD is available here.
For training the model (and hence intended also for the inference), we've used the following patterns of 2-7 demonstrations:
For English samples:
input:
Question: {Q1} Context: {C1} Answer: {A1},
Question: {Q2} Context: {C2} Answer: {A2},
[...possibly more demonstrations...]
Question: {Q} Context: {C} Answer:`
=> target:
{A}
For Czech samples:
input:
Otázka: {Q1} Kontext: {C1} Odpověď: {A1},
Otázka: {Q2} Kontext: {C2} Odpověď: {A2},
[...possibly more demonstrations...]
Otázka: {Q} Kontext: {C} Odpověď:`
=> target:
{A}
The best checkpoint was picked to maximize the model's zero-shot performance on unseen Named Entity Recognition from the out-of-distribution domain of texts and labels.
This model is purposed for a few-shot application on any text extraction task in English and Czech, where the prompt can be stated as a natural question. E.g. to use this model for extracting the entities of customer names from the text, prompt it with demonstrations in the following format:
input_text = """
Question: What is the customer's name?
Context: Origin: Barrack Obama, Customer id: Bill Moe.
Answer: Bill Moe,
Question: What is the customer's name?
Context: Customer id: Barrack Obama, if not deliverable, return to Bill Clinton.
Answer:"""
Here is how to use this model to answer the question on a given context using 🤗 Transformers in PyTorch:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("gaussalgo/mt5-large-priming-QA_en-cs")
model = AutoModelForSeq2SeqLM.from_pretrained("gaussalgo/mt5-large-priming-QA_en-cs")
# For the expected format of input_text, see Intended use above
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs)
print("Answer:")
print(tokenizer.decode(outputs))