Instructions to use zeromodels/mpnet_base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/mpnet_base with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/mpnet_base") - Keras
How to use zeromodels/mpnet_base with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/mpnet_base") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from zeromodels/mpnet_base: direct link, hf CLI and curl.
- Browser
- Download file 4.12 kB
-
https://huggingface.co/zeromodels/mpnet_base/resolve/main/README.md
- Command line
-
hf download hf://zeromodels/mpnet_base/README.md
-
curl -L -o README.md https://huggingface.co/zeromodels/mpnet_base/resolve/main/README.md
4.12 kB
| pipeline_tag: fill-mask | |
| license: mit | |
| base_model: microsoft/mpnet-base | |
| library_name: zeromodels | |
| language: | |
| - en | |
| tags: | |
| - keras | |
| - zeromodels | |
| - mpnet | |
| - fill-mask | |
| - text-encoder | |
| - arxiv:2004.09297 | |
| - pytorch | |
| - jax | |
| - tf | |
| ## ***See [our collection](https://huggingface.co/collections/zeromodels/mpnet-6ab0702ad43a267bae54ded1) for all versions of MPNet.*** | |
| # Run MPNet with Keras 3: JAX, PyTorch, or TensorFlow | |
| [](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/mpnet/) [](https://huggingface.co/collections/zeromodels/mpnet-6ab0702ad43a267bae54ded1) | |
| # zeromodels/mpnet_base | |
| Paper: [MPNet: Masked and Permuted Pre-training for Language Understanding (arXiv:2004.09297)](https://arxiv.org/abs/2004.09297) · [HF Papers](https://huggingface.co/papers/2004.09297) | |
| MPNet is a bidirectional encoder pre-trained with **masked and permuted** language modeling, unifying BERT's masked-LM objective with XLNet's permuted one. Unlike BERT it has no token-type embeddings, offsets position ids past the padding id, and adds a shared relative position bias to every attention layer. | |
| For more details on the model, please go to the upstream [model card](https://huggingface.co/microsoft/mpnet-base). | |
| Pure-**Keras 3** conversion of [`microsoft/mpnet-base`](https://huggingface.co/microsoft/mpnet-base) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**. | |
| This is a **fill-mask / encoder** checkpoint (`MPNetMaskedLM`, 12 layers / 768 dim). Task heads load via `hf:` fine-tunes. | |
| ## ✨ Quick start (fill-mask) | |
| ```python | |
| import os | |
| os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow" | |
| from zeromodels.models.mpnet import MPNetMaskedLM, MPNetTokenizer | |
| mlm = MPNetMaskedLM.from_weights("zeromodels/mpnet_base") | |
| tokenizer = MPNetTokenizer.from_weights("zeromodels/mpnet_base") | |
| inputs = tokenizer("the capital of France is <mask>.") | |
| logits = mlm(inputs) # (1, L, vocab_size) | |
| mask = int((inputs["input_ids"][0] == tokenizer.mask_token_id).argmax()) | |
| print(tokenizer.decode([int(logits[0, mask].argmax())])) | |
| ``` | |
| Load any MPNet variant the same way with `from_weights("zeromodels/<variant>")`: | |
| | Variant | Hub | | |
| |---|---| | |
| | `mpnet_base` | [`zeromodels/mpnet_base`](https://huggingface.co/zeromodels/mpnet_base) | | |
| ## Available classes | |
| Load any of these from this repo with `from_weights("zeromodels/mpnet_base")` (or on the fly via the `hf:` prefix). The pretrained backbone is shared; task heads not stored in this checkpoint start randomly initialized, ready for fine-tuning (or load a `hf:` fine-tune). | |
| | Class | Task | | |
| |---|---| | |
| | `MPNetModel` | Encoder backbone | | |
| | `MPNetMaskedLM` | Masked language modeling (fill-mask) | | |
| | `MPNetSequenceClassify` | Sequence classification | | |
| | `MPNetTokenClassify` | Token classification (NER / POS) | | |
| | `MPNetQnA` | Extractive question answering | | |
| | `MPNetMultipleChoice` | Multiple choice | | |
| ```python | |
| from zeromodels.models.mpnet import MPNetSequenceClassify | |
| model = MPNetSequenceClassify.from_weights("zeromodels/mpnet_base") | |
| ``` | |
| ## Tips | |
| - Set `KERAS_BACKEND` **before** importing Keras / zeromodels. | |
| - Prefer `MPNetTokenizer.from_weights(...)` so the WordPiece vocab matches. | |
| - Use `<mask>` (not `[MASK]`); MPNet pairs RoBERTa-style special tokens with a WordPiece vocabulary. | |
| - MPNet takes `input_ids` + `attention_mask` only — there are no `token_type_ids`. | |
| - See [MPNet docs](https://imvision12.github.io/ZeroModels/mpnet/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/). | |
| - Community / upstream safetensors still work via the `hf:` prefix, e.g. `MPNetMaskedLM.from_weights("hf:microsoft/mpnet-base")`. | |
| ## Special Thanks | |
| A huge thank you to the Microsoft MPNet authors for creating and releasing these models. | |
| License: MIT. | |