Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Does Flair support ModernBert 8k tokens context size? #3589

Closed
heukirne opened this issue Dec 22, 2024 · 2 comments
Closed

[Question]: Does Flair support ModernBert 8k tokens context size? #3589

heukirne opened this issue Dec 22, 2024 · 2 comments
Labels
question Further information is requested

Comments

@heukirne
Copy link
Contributor

Question

Recently ModernBert was launched with 8k context lenght: https://huggingface.co/blog/modernbert

Does Flair support fine tuning and inference of models with context lenght higher than 512?

Thanks!

@heukirne heukirne added the question Further information is requested label Dec 22, 2024
@heukirne
Copy link
Contributor Author

heukirne commented Jan 5, 2025

I was able to run it, just need to set the mex_length parameter:

from flair.embeddings import TransformerWordEmbeddings

embeddings = TransformerWordEmbeddings(model='answerdotai/ModernBERT-base',
                                       layers="all",
                                       subtoken_pooling="first",
                                       fine_tune=True,
                                       use_context=True, 
                                       transformers_tokenizer_kwargs={'model_max_length': 8192}
                                       )

Remember to install the main transformer, flash-attn and triton

pip install git+https://github.com/huggingface/transformers.git
pip install flash-attn --no-build-isolation
pip install triton

ModernBERT will be included in v4.48.0 of transformers. Until then, it requires installing transformers from main.

@heukirne heukirne closed this as completed Jan 5, 2025
@stefan-it
Copy link
Member

Hey @heukirne ,

if you plan to use ModernBERT for Token Classification tasks, please have a look at my NER repo:

https://github.com/stefan-it/modern-bert-ner

ModernBERT has currently a tokenizer issue, which is (probably) not seen for text classification tasks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants