Spaces:
Paused
Paused
import gradio as gr | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
# Cargar el modelo y el tokenizador | |
model_name = "meta-llama/Meta-Llama-3-8B" # Este es el nombre del repositorio en Hugging Face | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForCausalLM.from_pretrained(model_name) | |
def chat_with_llama(input_text): | |
inputs = tokenizer(input_text, return_tensors="pt") | |
outputs = model.generate(**inputs) | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
return response | |
# Crear la interfaz con Gradio | |
iface = gr.Interface( | |
fn=chat_with_llama, | |
inputs="text", | |
outputs="text", | |
title="Chat con LLaMA 3", | |
description="Interfaz simple para comunicarte con el modelo LLaMA 3." | |
) | |
iface.launch() |