Skip to content

feat: Add MPNet model family - #434

Merged
jonatanklosko merged 1 commit into
elixir-nx:mainfrom
georgeguimaraes:feat/mpnet-implementation
Jan 2, 2026
Merged

feat: Add MPNet model family#434
jonatanklosko merged 1 commit into
elixir-nx:mainfrom
georgeguimaraes:feat/mpnet-implementation

Conversation

@georgeguimaraes

@georgeguimaraes georgeguimaraes commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Adds the MPNet model family to Bumblebee.

MPNet (Masked and Permuted Pre-training) is an encoder model that combines masked language modeling with permuted language modeling.

Supported architectures

  • :base
  • :for_masked_language_modeling
  • :for_sequence_classification
  • :for_token_classification
  • :for_question_answering
  • :for_multiple_choice

Implementation notes

  • Uses relative position bias shared across all encoder layers
  • Does not use token_type_ids (unlike BERT/RoBERTa)
  • Position IDs start at pad_token_id + 1 (matching Python transformers)

Testing

  • All 6 architecture tests pass with tiny-random models
  • Tokenizer test added with expected values from Python
  • Verified output matches Python transformers exactly with microsoft/mpnet-base
  • Tested sequence classification with real model (moshew/mpnet-base-sst2-distilled)

References

Copilot AI review requested due to automatic review settings December 27, 2025 15:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive support for the MPNet model family to Bumblebee, enabling the use of models like sentence-transformers/all-mpnet-base-v2. The implementation follows the patterns established by similar encoder models (BERT, RoBERTa) in the codebase.

  • Implements all standard MPNet architectures (base, masked LM, sequence/token classification, question answering, multiple choice)
  • Adds proper tokenizer configuration with MPNet-specific special tokens
  • Registers all model types in the main Bumblebee module
  • Includes comprehensive test coverage for all architectures using tiny random models from HuggingFace

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lib/bumblebee/text/mpnet.ex Core MPNet implementation with all architectures, configuration options, and HuggingFace parameter mappings
lib/bumblebee/text/pre_trained_tokenizer.ex Adds MPNet tokenizer configuration with appropriate special tokens
lib/bumblebee.ex Registers MPNet model classes and tokenizer type mapping
test/bumblebee/text/mpnet_test.exs Comprehensive tests for all six MPNet architectures

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/bumblebee/text/mpnet_test.exs
@georgeguimaraes
georgeguimaraes force-pushed the feat/mpnet-implementation branch 3 times, most recently from 6ea3784 to 15041b4 Compare January 1, 2026 19:55
@georgeguimaraes

Copy link
Copy Markdown
Contributor Author

Squashed commits and updated the description.

Tested with real models beyond the tiny-random ones. microsoft/mpnet-base outputs match Python transformers exactly, and moshew/mpnet-base-sst2-distilled works for sequence classification.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jonatanklosko jonatanklosko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, just one nitpick and good to merge!

Comment thread lib/bumblebee/text/mpnet.ex Outdated
MPNet (Masked and Permuted Pre-training) is an encoder model that combines
masked language modeling with permuted language modeling objectives.

Supported architectures:
- :base
- :for_masked_language_modeling
- :for_sequence_classification
- :for_token_classification
- :for_question_answering
- :for_multiple_choice

Key implementation details:
- Uses relative position bias shared across all encoder layers
- Does not use token_type_ids (unlike BERT/RoBERTa)
- Position IDs start at pad_token_id + 1 (matching Python transformers)
@georgeguimaraes
georgeguimaraes force-pushed the feat/mpnet-implementation branch from ccbd044 to c474aeb Compare January 2, 2026 20:34
@jonatanklosko
jonatanklosko merged commit 2252d44 into elixir-nx:main Jan 2, 2026
2 checks passed
@georgeguimaraes
georgeguimaraes deleted the feat/mpnet-implementation branch January 3, 2026 00:13
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.

3 participants