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

Add ModernBERT config #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ModernBERT config #119

wants to merge 1 commit into from

Conversation

jamt9000
Copy link
Collaborator

@jamt9000 jamt9000 commented Dec 28, 2024

Adds a ModernBERT config for the original toxic comment classification challenge, using the ModernBERT-base model.

Currently requires installing transformers from git to train: huggingface/transformers#35362 (comment)

CUDA_VISIBLE_DEVICES=1 python train.py -c configs/Toxic_comment_classification_ModernBERT.json

@jamt9000
Copy link
Collaborator Author

jamt9000 commented Dec 29, 2024

Currently the modernbert forward pass gives NaN outputs:

outputs
tensor([[    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [-0.8802, -0.9810, -0.5694, -0.4875,  0.7263,  0.0181],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan],
        [    nan,     nan,     nan,     nan,     nan,     nan]],
       device='cuda:0')

Edit: Seems to be fixed after installing flash attention pip install flash-attn --no-build-isolation

}
},
"optimizer": {
"type": "Adam",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth using the hyperparameters given here:

https://github.com/AnswerDotAI/ModernBERT/blob/main/examples/finetune_modernbert_on_glue.ipynb

    "optimizer": {
        "type": "AdamW",
        "args": {
            "lr": 8e-5,
            "weight_decay": 8e-6,
            "betas": [0.9, 0.98],
            "eps": 1e-6,
            "amsgrad": false
        }
    }

@jamt9000 jamt9000 requested a review from laurahanu January 2, 2025 09:13
Copy link
Collaborator

@laurahanu laurahanu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! would be good to have something about the benefits of modernbert in the description too

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

Successfully merging this pull request may close these issues.

2 participants