scibert icon indicating copy to clipboard operation
scibert copied to clipboard

AttributeError while using SciBERT

Open Saichethan opened this issue 4 years ago • 3 comments

`` import tensorflow as tf from transformers import * #BertTokenizer, TFBertModel

tokenizer = AutoTokenizer.from_pretrained('allenai/scibert_scivocab_uncased') model = AutoModel.from_pretrained('allenai/scibert_scivocab_uncased')

input_ids = tf.constant(tokenizer.encode("My dog is cute"))[None, :] # Batch size 1

outputs = model(input_ids)

last_hidden_states = outputs[0] print(last_hidden_states) ``

I'm getting following error: input_shape = input_ids.size() AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute 'size'

Saichethan avatar May 27 '20 06:05 Saichethan

@Saichethan Our huggingface compatible weights are only for PyTorch.

kyleclo avatar May 27 '20 08:05 kyleclo

@kyleclo thanks for your response Then how can I get sentence embeddings in TF??

Saichethan avatar May 27 '20 08:05 Saichethan

Hmm.. I'd probably ask the folks on the HuggingFace repo. We uploaded model weights according to their specification for PyTorch compatibility. I'm unfamiliar with how they handle tensorflow compatibility; that's going to be something specific to their platform

kyleclo avatar May 27 '20 08:05 kyleclo