from transformers import ElectraForPreTraining, ElectraTokenizerFast
import torch

discriminator = ElectraForPreTraining.from_pretrained("josu/electra-pt-br-small-discriminator")
tokenizer = ElectraTokenizerFast.from_pretrained("josu/electra-pt-br-small-discriminator")

sentence = "os passaros estão cantando"
fake_sentence = "os passaros estão falando"

fake_tokens = tokenizer.tokenize(fake_sentence)
fake_inputs = tokenizer.encode(fake_sentence, return_tensors="pt")
discriminator_outputs = discriminator(fake_inputs)
predictions = torch.round((torch.sign(discriminator_outputs[0]) + 1) / 2)

[print("%7s" % token, end="") for token in fake_tokens]

[print("%7s" % int(prediction), end="") for prediction in predictions.squeeze().tolist()
Downloads last month
8
Inference API
Unable to determine this model’s pipeline type. Check the docs .