Skip to content

Commit

Permalink
Remove obsolete code from GLUE models after transformers>=4.25.1.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 622202706
  • Loading branch information
RyanMullins authored and LIT team committed Apr 5, 2024
1 parent 96eff29 commit 82abec6
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lit_nlp/examples/models/glue_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,7 @@ def predict_minibatch(self, inputs: Iterable[JsonDict]):
# Gathers word embeddings from BERT model embedding layer using input ids
# of the tokens.
input_ids = encoded_input["input_ids"]
# TODO(b/236276775): Unify on the TFBertEmbeddings.weight API after
# transformers is updated to v4.25.1 (or newer).
if hasattr(self.model.bert.embeddings, "word_embeddings"):
word_embeddings = self.model.bert.embeddings.word_embeddings
else:
word_embeddings = self.model.bert.embeddings.weight
word_embeddings = self.model.bert.embeddings.weight
# <tf.float32>[batch_size, num_tokens, emb_size]
input_embs = tf.gather(word_embeddings, input_ids)

Expand Down

0 comments on commit 82abec6

Please sign in to comment.