test / app.py
jairwaal's picture
Upload app.py
d44b8fc
import gradio as gr
import torch
from transformers import AutoTokenizer, AutoModel
def get_embeddings(text):
tokenizer = AutoTokenizer.from_pretrained("GroNLP/bert-base-dutch-cased")
model = AutoModel.from_pretrained("GroNLP/bert-base-dutch-cased", output_hidden_states=True)
sent = str(text)
encoded = tokenizer.encode_plus(sent, return_tensors="pt")
with torch.no_grad():
output = model(**encoded)
states = output.hidden_states
return states
iface = gr.Interface(fn=get_embeddings,inputs="text",outputs="text")
iface.launch()