question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an MLMHead layer

See original GitHub issue

This layer can go with the MLMMaskGenerator layer to make it easy to write a masked language model transformer.

The layer should map two inputs:

  • embedded tokens of shape (batch, sequence_length, model_dim)
  • mask positions of shape (batch, prediction_length)

To one output:

  • predictions of shape (batch, prediction_length, vocabulary_size)

Where the outputs contains either logits or softmax probabilities per word in the vocabulary.

The layer should optionally allow reusing the embedding weights to reverse word embeddings from model_dim -> vocabulary_size.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mattdangerwcommented, Apr 19, 2022

@aflah02 thanks, but this one I already have 😃, made it while working on a guide for keras-nlp. We will open up more issues this week!

0reactions
aflah02commented, Apr 19, 2022

Sure I’d be interested to check that out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MLMHead layer - Keras
Masked Language Model (MLM) head. This layer takes two inputs: inputs : which should be a tensor of encoded tokens with shape (batch_size,...
Read more >
BERT - Hugging Face
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A BERT...
Read more >
Understanding output of models and relation to token probability
Naturally, this embedding is specialized on a given task by adding one or several heads after the encoder. the MLMHead is one of...
Read more >
Create Multi-Output Model with KerasNLP (CLS + MLM)
I am trying to use Keras_NLP to pretrain a model through both Masked Language Modelling and using a proxy for the CLS token...
Read more >
Adding Custom Layers on Top of a Hugging Face Model
Some models on Hugging Face are trained on downstream tasks like question-answering or text classification and contain knowledge about the data they were ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found