Downloads · 30 days
13
13% of all-time downloads
agentlans/LaMini-Flan-T5-77M-qa-generation
LaMini-Flan-T5-77M-qa-generation is a question answering model from agentlans. Use it when the input is a question plus a passage.
This model is a fine-tuned version of MBZUAI/LaMini-Flan-T5-77M trained to generate question and answer pairs from raw text. It is based on the FLAN-T5 architecture and has been optimized for question-answer generatio…
Downloads · 30 days
13
13% of all-time downloads
All-time downloads
100
Public
Parameters
76.9M
308 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors308 MB · 99%
From the Hugging Face model README
This model is a fine-tuned version of MBZUAI/LaMini-Flan-T5-77M trained to generate question and answer pairs from raw text. It is based on the FLAN-T5 architecture and has been optimized for question-answer generation tasks.
[QUESTION_END], [ANSWER_END]To use this model for generating question-answer pairs:
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model_name = "agentlans/LaMini-Flan-T5-77M-qa-generation"
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
input_text = "Your input text here..."
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=512)
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
The model generates output in the following format:
Question[QUESTION_END]Answer[ANSWER_END]Question[QUESTION_END]Answer[ANSWER_END]...
To parse this output into a structured format:
import re
def clean_text(text):
return re.sub(r'\s+', ' ', text).strip()
def parse_qa_pairs(input_text):
qa_blocks = re.split(r'(\[ANSWER_END\])', input_text)
pairs = []
for i in range(0, len(qa_blocks) - 1, 2):
qa_block = qa_blocks[i]
parts = qa_block.split('[QUESTION_END]')
if len(parts) == 2:
question, answer = map(clean_text, parts)
if question and answer:
pairs.append({"question": question, "answer": answer})
return pairs
qa_pairs = parse_qa_pairs(decoded_output)
Input:
The ocean, covering over 70% of our planet's surface, is a vast and mysterious realm teeming with life and beauty. From the vibrant coral reefs that serve as bustling underwater cities to the deep, dark trenches that house some of the most bizarre creatures on Earth, the ocean is a treasure trove of biodiversity. It plays a crucial role in regulating the global climate, absorbing carbon dioxide and producing oxygen through its phytoplankton. Moreover, the ocean's depths remain largely unexplored, holding countless secrets and potential discoveries that could revolutionize our understanding of biology, medicine, and environmental science. As we continue to learn more about this incredible ecosystem, it becomes increasingly clear that protecting our oceans is essential for the health of our planet and future generations.
Output:
[
{
"question": "What is the ocean's role in regulating the global climate?",
"answer": "The ocean plays a crucial role in regulating the global climate by absorbing carbon dioxide and producing oxygen through its phytoplankton."
},
{
"question": "What are some of the key discoveries that could revolutionize our understanding of the ocean?",
"answer": "The ocean's depths remain largely unexplored, holding secrets and potential discoveries that could revolutionize our understanding of biology, medicine, and environmental science."
},
{
"question": "What is the significance of protecting our oceans for future generations?",
"answer": "Protecting our oceans is essential for the health of our planet and future generations because it is a vital part of our ecosystem and a vital resource for our survival and well-being."
}
]
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.6321 | 1.2361 | 500 | 1.4333 |
| 1.5305 | 2.4722 | 1000 | 1.4013 |
| 1.4754 | 3.7083 | 1500 | 1.3719 |
| 1.4425 | 4.9444 | 2000 | 1.3693 |
| 1.3781 | 6.1805 | 2500 | 1.3647 |
| 1.3687 | 7.4166 | 3000 | 1.3572 |
| 1.3413 | 8.6527 | 3500 | 1.3596 |
| 1.3539 | 9.8888 | 4000 | 1.3594 |