from transformers import pipeline # ──────────────────────────────────────────────────────────────── # 7. Text Generation (causal LM – free continuation) # ──────────────────────────────────────────────────────────────── # Default model: openai-community/gpt2 # → Used for: very small & fast English generation (~124M params) # good for quick testing & prototyping # # Modern alternative: mistralai/Mistral-7B-Instruct-v0.3 # → Used for: much smarter, coherent, instruction-following text # excellent for creative writing, explanations, code pipe = pipeline("text-generation", max_new_tokens=70) # pipe = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3", max_new_tokens=70) print(pipe("In Ludhiana people love to eat")[0]["generated_text"])