Repository navigation
Conversation
|
Thanks for assigning @gante! Also cc'ing the others who may be interested again @Rocketknight1 @ArthurZucker. Let me know if I need to do anything else, I see I need to update the branch with main since it's been a while. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Hey! Thanks for the PR 🤗
As you already anticipated, my main concern is that this is a different "architecture" per say! With modular writing ModernBertDecoder + ModernBertForCausalLM should be easier, but we usually never change the codebase of existing models like this!
Other than this, the tokenizer is not needed either! The settings you added can be controlled directly via the template processor that needs to be different for each model ! 🤗
|
Thanks @ArthurZucker! I am not 100% sure if you are saying having them combined is a no-go or potentially still on the table, so I will give you my last attempt to describe why I think it's a good idea to have them combined.
What are your thoughts? You're the expert here, so if you still think it's best to separate them I will move the implementation to a |
|
@orionw a question: this would be the equivalent to what we have in the original If so, I'd be inclined to include your PR, given that it is a pattern present in such a staple model. One modeling file would be a near copy of the other. But @ArthurZucker has the final word here :) |
|
@ArthurZucker a gentle ping when you get a sec :) |
ArthurZucker
left a comment
There was a problem hiding this comment.
Happy to add support but it should be aligned with the rest of the lib! The way we create the causal mask etc and add a new class not monkey patch existing ones!
There was a problem hiding this comment.
we should not need this I don't see anything major
| # the local mask will override the global mask | ||
| if local_attention != (-1, -1): | ||
| attention_mask = sliding_window_mask | ||
| final_attention_mask = sliding_window_mask |
There was a problem hiding this comment.
we should create another class for this 😉
|
Thanks @ArthurZucker @gante for the reviews! Just to clarify then - is it correct you are saying there should be two classes for the decoder version and the encoder version? Even though they share all functionality except the attention masking. That's totally fine, just want to make sure I'm on the same page |
|
Small question on the tokenizer (for any of @gante @ArthurZucker @Rocketknight1). Arthur said about the tokenizer class:
But I need the BOS token always for the decoder-only version, just like Gemma (which I noticed has its own tokenizer class). However, I don't want the EOS token always, since it is a decoder-only LM. AFAIK there is no way to have it use only one of these special tokens with |
|
Just a quick ping if any of you could provide some quick high level guidance :) |
|
Hi @orionw, I'm sorry for the delay with reviewing this! We had quite a bit internal discussion about this and we decided that we probably don't want to bloat the attention implementations of a major MLM like ModernBERT with a full CausalLM path. Although we have other MLM ForCausalLM classes like RobertaForCausalLM, these are usually very simple and are intended for use by advanced developers who can create their own labels and triangular attention masks. Adding large tokenizer / internal layer changes to an MLM can create bugs, reduce performance and make it harder to maintain the core MLM functionality, which we don't want! Running MLMs as CLMs is a very niche thing to do. Instead, can we suggest refactoring the PR to be more limited, and add a ForCausalLM wrapper that simply handles labels and attention mask creation before passing inputs through a standard ModernBert stem? This would avoid the need for major changes in the modeling code. You can use something like RobertaForCausalLM as a guide. |
|
Thanks @Rocketknight1 that was super helpful :) Closing and simply making a new class/PR for ModernBERTDecoders instead. |
This PR adds CausalLM functionality to ModernBERT. This means:
is_causalsince otherwise we'd need to pad/repad too frequently. We lose a bit of speed, but the code is much cleaner.This is for an upcoming release that trained both options for a comparison of encoders and decoders.
Anticipated FAQs:
Q: Why not just make a new model class?
A: Models are trained in both settings and need to be able to operate back and forth with the same weights. This also reduces redundant code since all the base functionality is the same, other than kv caching and attention masking.
Q: Is there a test model?
A: Currently I have a test model at
https://huggingface.co/blab-jhu/test-32m-decthat has been trained with CLM and works with this PR.Q: Why are there two methods of CausalLM?
A: One works for the encoder-only models, which perform better than I anticipated on decoder-only tasks. The other is standard decoder-only modeling, which is the default.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Tagging those who have reviewed ModernBERT PRs @Rocketknight1 @ArthurZucker