I am trying to use the batch_encode_plus()
function from BERT. The problem comes when it says that this function does not exist. I go to the documentation in this page and it says the following: "This method is deprecated, __call__
should be used instead.". I tried to use __call__
as a function but it does not work.
Then I get into this page and it seems that the function batch_encode_plus()
was replaced by __call__
. But when I use the function is not working. I tried to use encoded_plus()
but it does not give the the expected results.
I do not know how to use this __call__
function, any suggestions?
I've been working with this recently. Here is a good look at some documentation for the call function
call( inputs*args**kwargs ) → A list or a list of list of dict
Parameters:
Returns: A list or a list of list of dict
Here's an example of how I used it. (keep in mind that I'm using the fill-mask mode of BERT which is a one word prediction model and the python language)
from transformers import pipeline
predicter = pipeline('fill-mask', model='bert-base-uncased')
print(predicter.__call__("example string. Hello [MASK]",top_k=1)
The model will predict the word that is tokenized by [MASK] the example output for this is:
{'score': 0.9415972232818604, 'token': 1037, 'token_str': 'kitty', 'sequence': 'example string. Hello kitty'}