File size: 566 Bytes
d44b8fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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() |