YAML Metadata Warning: The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

Question decomposer Based t5 and Seq2seq

Example: What is the capital of France and when it entablish ?

  • What is the capital of France ?
  • When was the capital of France entablish ?

Checkout my demo here 👉🏻 demo

How to Usage

from transformers import T5Tokenizer, T5ForConditionalGeneration
import torch

# Set device
device = "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu"

# Load model and tokenizer
model_path = "thenHung/question_decomposer_t5"
tokenizer = T5Tokenizer.from_pretrained(model_path)
model = T5ForConditionalGeneration.from_pretrained(model_path)
model.to(device)
model.eval()

# Decompose question
question = "Who is taller between John and Mary?"
input_text = f"decompose question: {question}"
input_ids = tokenizer(
    input_text,
    max_length=128,
    padding="max_length",
    truncation=True,
    return_tensors="pt"
).input_ids.to(device)

with torch.no_grad():
    outputs = model.generate(
        input_ids,
        max_length=128,
        num_beams=4,
        early_stopping=True
    )

# Decode output
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
sub_questions = decoded_output.split(" [SEP] ")

# Print sub-questions
print(sub_questions)
# ['What is the height of John?', 'What is the height of Mary?']
Downloads last month
28
Safetensors
Model size
60.5M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for thenHung/question_decomposer_t5

Base model

google-t5/t5-base
Finetuned
(623)
this model

Dataset used to train thenHung/question_decomposer_t5

Space using thenHung/question_decomposer_t5 1