Views
No views yet
optimizer=adamw_hf
learning_rate=3e-5
adam_beta1=0.9
adam_beta2=0.999
adam_epsilon=1e-08
num_train_epochs=2
per_device_train_batch_size=121from transformers import pipeline
2
3def prep_input(_context, _question):
4 return " ".join(["question:", _question.strip(), "context:", _context.strip()])
5
6t5qa = pipeline("text2text-generation", "fgaim/t5-small-squad-v2")
7
8context = """
9Oxygen is a chemical element with symbol O and atomic number 8. It is a member of the chalcogen group on the periodic table and is a highly reactive nonmetal and oxidizing agent that readily forms compounds (notably oxides) with most elements. By mass, oxygen is the third-most abundant element in the universe, after hydrogen and helium. At standard temperature and pressure, two atoms of the element bind to form dioxygen, a colorless and odorless diatomic gas with the formula O.
10"""
11
12t5qa(prep_input(context, "How many atoms combine to form dioxygen?"))
13# [{'generated_text': 'two'}]
14
15t5qa(prep_input(context, "What element makes up almost half of the earth's crust by mass?"))
16# [{'generated_text': 'oxygen'}]
17
18t5qa(prep_input(context, "What are the most abundent elements of the universe by mass?"))
19# [{'generated_text': 'hydrogen and helium'}]