Spaces:
Runtime error
Runtime error
File size: 1,064 Bytes
5b1fbfd 73fa793 5b1fbfd f53a293 5b1fbfd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Model in Hugging Hub
tokenizer = AutoTokenizer.from_pretrained("Andresmfs/st5s-es-inclusivo")
model = AutoModelForSeq2SeqLM.from_pretrained("Andresmfs/st5s-es-inclusivo")
def make_neutral(phrase):
# Define prompt for converting gendered text to neutral
input_ids = tokenizer(phrase, return_tensors="pt").input_ids
# Call the LLM to generate neutral text
outputs = model.generate(input_ids)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Ejemplos de preguntas
mis_ejemplos = [
["La cocina de los gallegos es fabulosa."],
["Los niños juegan a la pelota."],
["Los científicos son muy listos"],
["Las enfermeras se esforzaron mucho durante la pandemia."],
]
iface = gr.Interface(
fn=make_neutral,
inputs="text",
outputs="text",
title="ES Inclusive Language",
description="Enter a Spanish phrase and get it converted into neutral/inclusive form.",
examples = mis_ejemplos
)
iface.launch() |