Skip to content

feat: ModernBERT - #54

Merged
EYH0602 merged 5 commits into
mainfrom
feat/modernbert
Feb 12, 2026
Merged

feat: ModernBERT#54
EYH0602 merged 5 commits into
mainfrom
feat/modernbert

Conversation

@EYH0602

@EYH0602 EYH0602 commented Feb 12, 2026

Copy link
Copy Markdown
Member

ModernBERT Support

Add ModernBERT as a supported model architecture for both pre-training and downstream evaluation.

Pre-training

  • Add model_type config parameter (roberta | modernbert) to select encoder architecture
  • Add pooling config parameter (cls | mean) for contrastive embedding extraction
  • Mean pooling (recommended for ModernBERT, which has no pooler head) averages non-padding token representations
  • Add ModelType and PoolingStrategy type aliases in modeling/_types.py
  • Wire model_type and pooling through PretrainConfig, ContrastiveTrainer, and CLI
  • Add experiments/modernbert_base.yaml example config
  • Add doc/modernbert.md with setup and usage documentation

Downstream Evaluation

  • Fix hardcoded pad_token_id=1 in attention mask construction to use tokenizer.pad_token_id (supports both RoBERTa pad=1 and ModernBERT pad=0)
  • Add mean pooling option to clone detection models (Clone-detection-POJ104, Clone-detection-CodeNet) for ModernBERT compatibility
  • Parameterize model_type and tokenizer_name in all downstream run.sh and run_aug_test.sh scripts with backward-compatible defaults
  • Affected tasks: Clone-detection-POJ104, Clone-detection-CodeNet, Clone-detection-BigCloneBench, Code-classification-POJ104, Code-classification-CodeNet, Defect-detection, Code-translation

Experiment Scripts

  • Add experiments_downstream/ with 88 generated bash scripts (via gen_all.py) covering all 8 models x 7 tasks (with CodeNet subsets)
  • Scripts organized by task directory, mirroring the downstream/ structure
  • Models: CodeBERT, GraphCodeBERT, ContraBERT_C, ContraBERT_G, and their InvPT-trained counterparts

- Fix hardcoded pad_token_id=1 in attention masks to use
  tokenizer.pad_token_id (supports both RoBERTa and ModernBERT)
- Add mean pooling for ModernBERT in clone detection models
  (ModernBERT has no pooler head; mean pooling is recommended)
- Parameterize model_type and tokenizer_name in all shell scripts
  with backward-compatible defaults
- Affected tasks: Clone-detection-POJ104, Clone-detection-CodeNet,
  Code-classification-POJ104, Code-classification-CodeNet
Generate 88 bash scripts in experiments_downstream/, one per
downstream-task + model combination. Covers 4 baselines (CodeBERT,
GraphCodeBERT, ContraBERT_C, ContraBERT_G) and 4 InvPT-trained models
across all 7 downstream tasks (with CodeNet subsets).

Includes gen_all.py generator script for reproducibility.
@EYH0602
EYH0602 merged commit 1ee1cde into main Feb 12, 2026
3 checks passed
@EYH0602
EYH0602 deleted the feat/modernbert branch February 28, 2026 19:18
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.

1 participant