Skip to content

Instantly share code, notes, and snippets.

@AlexDel
Last active June 16, 2020 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDel/0c6a2887bef47ec5102be528b53466e1 to your computer and use it in GitHub Desktop.
Save AlexDel/0c6a2887bef47ec5102be528b53466e1 to your computer and use it in GitHub Desktop.
RuBERT
from transformers import AutoModelWithLMHead, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("DeepPavlov/rubert-base-cased-conversational")
model = AutoModelWithLMHead.from_pretrained("DeepPavlov/rubert-base-cased-conversational")
tokens = tokenizer.tokenize('Привет, друг!')
input_ids = torch.tensor(tokenizer.encode(tokens, add_special_tokens=True)).unsqueeze(0) # Batch size 1
outputs = model(input_ids)
last_hidden_states = outputs[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment