Views
No views yet
{base_model}-{target_dataset}teabreac-{base_model}teabreac-{base_model}-{target_dataset}base_model above can be from: bart-large, t5-large, t5-3b, nt5-small, preasm-large.
The target_dataset above can be from: drop, tatqa, iirc-gold, iirc-retrieved, numglue.1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2from digit_tokenization import enable_digit_tokenization # digit_tokenization.py from https://github.com/stonybrooknlp/teabreac
3
4model_name = "StonyBrookNLP/teabreac-nt5-small-tatqa"
5tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False) # Fast doesn't work with digit tokenization
6model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7enable_digit_tokenization(tokenizer)
8input_texts = [
9 "answer_me: Who scored the first touchdown of the game?" +
10 "context: ... Oakland would get the early lead in the first quarter as quarterback JaMarcus Russell completed a 20-yard touchdown pass to rookie wide receiver Chaz Schilens..."
11 # Note: some models have slightly different qn/ctxt format. See the github repo.
12]
13input_ids = tokenizer(
14 input_texts, return_tensors="pt",
15 truncation=True, max_length=800,
16 add_special_tokens=True, padding=True,
17)["input_ids"]
18generated_ids = model.generate(input_ids, min_length=1, max_length=50)
19generated_predictions = tokenizer.batch_decode(generated_ids, skip_special_tokens=False)
20generated_predictions = [
21 tokenizer.fix_decoded_text(generated_prediction) for generated_prediction in generated_predictions
22]
23# => ["Chaz Schilens"]