Bemz
Bemz

Reputation: 147

from transformers import BertTokenizer

I am trying to implement the following model from hugging face but not entirely sure how to feed the model the texts that I need to pass to do the classification. The documentation (https://huggingface.co/DaNLP/da-bert-tone-subjective-objective) does not show how to pass your queries.

from transformers import BertTokenizer, BertForSequenceClassification

model = BertForSequenceClassification.from_pretrained("DaNLP/da-bert-tone-subjective-objective")
tokenizer = BertTokenizer.from_pretrained("DaNLP/da-bert-tone-subjective-objective")

Would appreciate further guidance here.

Upvotes: 1

Views: 1086

Answers (1)

Sachin Kohli
Sachin Kohli

Reputation: 1986

I also used one of the pretrained model from HF few weeks back... Following code I used to test out on my input... You can try the same, if works for you then best... Else, you can check the documentation or pretrained link on the same page which you shared in the query...

sent = "paste your input here"
inputs = tokenizer.encode(sent, return_tensors='pt', padding=True)
outputs = model(inputs)

print(outputs)
or
print(outputs[0])
or
print(outputs[0].detach().numpy())

Upvotes: 2

Related Questions