Spaces:
Sleeping
Sleeping
File size: 1,040 Bytes
e2d40b4 b12281c e2d40b4 b12281c |
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 |
import gradio as gr
from transformers import AutoModel, AutoTokenizer
# Load the model and tokenizer
model = AutoModel.from_pretrained("kakaobank/kf-deberta-base")
tokenizer = AutoTokenizer.from_pretrained("kakaobank/kf-deberta-base")
def process_text(text):
# Tokenize the input text
tokens = tokenizer.tokenize(text)
token_output = f"Tokens: {tokens}"
# Generate model output
inputs = tokenizer(text, return_tensors="pt")
model_output = model(**inputs)
# You might want to format this output in a more readable way
model_output_str = str(model_output)
return token_output, model_output_str
# Create a Gradio interface
iface = gr.Interface(
fn=process_text,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
outputs=[gr.outputs.Textbox(label="Tokenized Output"), gr.outputs.Textbox(label="Model Output")],
title="DeBERTa Model Text Processing",
description="This interface tokenizes the input text and processes it with the DeBERTa model."
)
iface.launch()
|