allenai / scibert

A BERT model for scientific text.
https://arxiv.org/abs/1903.10676
Apache License 2.0
1.49k stars 217 forks source link

AttributeError while using SciBERT #88

Open Saichethan opened 4 years ago

Saichethan commented 4 years ago

`` 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'

kyleclo commented 4 years ago

@Saichethan Our huggingface compatible weights are only for PyTorch.

Saichethan commented 4 years ago

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

kyleclo commented 4 years ago

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