Spaces:
Build error
Build error
import gradio as gr | |
from hf_olmo import AutoModelForCausalLM, AutoTokenizer # Importando do hf_olmo | |
import os | |
# Configurar PKG_CONFIG_PATH | |
os.environ['PKG_CONFIG_PATH'] = '/usr/local/lib/pkgconfig:/usr/lib/pkgconfig' | |
# Resto do código do app | |
from transformers import AutoTokenizer, AutoModelForCausalLM | |
# Carregar o modelo e tokenizer | |
model_name = "allenai/OLMo-7B" | |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True) | |
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) | |
def generate_text(prompt): | |
inputs = tokenizer(prompt, return_tensors="pt") | |
outputs = model.generate(**inputs) | |
return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text", | |
title="OLMo-7B Text Generator", description="Enter a prompt to generate text.") | |
iface.launch() | |