Zerx966's picture
Update app.py
a9d61a9 verified
raw
history blame contribute delete
886 Bytes
import gradio as gr
gr.load("models/mistralai/Mistral-Nemo-Instruct-2407").launch()
import gradio as gr
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load pre-trained BlackMamba model and tokenizer
model_name = "blackmamba"
model = GPT2LMHeadModel.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
def generate_text(prompt, max_length=50):
inputs = tokenizer.encode(prompt, return_tensors="pt")
outputs = model.generate(inputs, max_length=max_length, num_return_sequences=1)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
return generated_text
# Create Gradio interface
iface = gr.Interface(
fn=generate_text,
inputs="text",
outputs="text",
title="WormGPT",
description="An evil brother of ChatGPT for Hugging Face Gradio"
)
# Launch the interface
iface.launch()