Skip to content

Instantly share code, notes, and snippets.

@SharathHebbar
Last active January 24, 2024 05:47
Show Gist options
  • Save SharathHebbar/527f6d9515ee2dc458e209413350447c to your computer and use it in GitHub Desktop.
Save SharathHebbar/527f6d9515ee2dc458e209413350447c to your computer and use it in GitHub Desktop.
Text Generation vs Text2TextGeneration

Text Generation

from transformers import pipeline
task = "text-generation"
model_name = "gpt2"
max_output_length = 30
num_of_return_sequences = 2
input_text = "Hello, "
text_generator = pipeline(
    task,
    model = model_name)

text_generator(
    input_text,
    max_length=max_output_length,
    num_return_sequences=num_of_return_sequences)

Text 2 Text Generation

from transformers import pipeline
task = "text2text-generation"
model_name = "google/flan-t5-base"
input_text = "Can you convert this text to French language: Hello, How are you"
text2text_generator = pipeline(
    task,
    model = model_name)

text2text_generator(input_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment