LLM-FineTuned / app.py
Hadeel11's picture
Create app.py
0797b92 verified
raw
history blame
602 Bytes
from transformers import AutoTokenizer, AutoModelForCausalLM, TextGenerationPipeline
from gradio import Interface
model_name = "Hadeel11/fine-tuned-model-2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
model.half()
text_generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
def generate_text(prompt):
return text_generator(prompt, max_length=512, num_return_sequences=1)[0]['generated_text']
iface = Interface(fn=generate_text, inputs="text", outputs="text", title="Text Generation Inference")
iface.launch()