risha_testing / text_genrattion.py
rishach's picture
Upload full fitnetuned model + tokenizer +generation config
9e5fc05 verified
Raw
History Blame Contribute Delete
1.07 kB
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"])