Add an MLMHead layer
See original GitHub issueThis 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:
- Created a year ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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!
Sure I’d be interested to check that out!