Hugging Face · Transformers

Generate text with a pipeline

Generate text with a specific model.

from transformers import pipeline

generator = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
generator("Once upon a time", max_new_tokens=50)

Official Hugging Face documentation

More transformers commands

All transformers commands · Hugging Face cheatsheet

Was this page helpful?