anaksor-ocr
Sokheng · Kit
Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…
Predicts a hidden word in English text or code, and after fine-tuning serves as a long-context encoder for search, classification and retrieval. Made for developers and researchers who need a fast BERT-style encoder.
ModernBERT-base is a kit in the Developer category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page, a zip of its files. Nothing in it runs by itself.
pip install -U huggingface_hub hf download answerdotai/ModernBERT-base
ModernBERT-base is an updated BERT-style encoder with 22 layers and 149 million parameters. It predicts masked words out of the box, and you fine-tune it for tasks such as classification, retrieval or question answering.
It suits developers and researchers who build search, classification or retrieval systems and want a fast encoder that reads long documents and code.
| Industry | Who uses it | How they use it | Example |
|---|---|---|---|
| Search | Retrieval engineers | Embed long documents for semantic search | Index a large corpus of articles |
| Software | Developers | Search code and mixed text-and-code content | Find code snippets by meaning |
| Data science | ML engineers | Fine-tune a classifier on long text | Label support tickets by topic |
| Research | NLP researchers | Compare encoder models on standard benchmarks | Test GLUE and BEIR scores |
If you need a model that writes or chats, you can skip it, since it only encodes text.
It runs in Python through the transformers library, on a CPU or a GPU.
| Use case | Who | What they get back |
|---|---|---|
| Fill-mask prediction | Developers | The most likely word for a hidden position |
| Retrieval and semantic search | Search teams | Vectors for long documents after fine-tuning |
| Classification | ML teams | A fine-tuned encoder for labels |
You need Python and transformers at version 4.48.0 or newer. If your GPU supports it, the card recommends adding Flash Attention 2.
pip install -U huggingface_hub hf download answerdotai/ModernBERT-base
pip install -U transformers>=4.48.0
pip install flash-attn
Use the fill-mask pipeline, or load the model with AutoModelForMaskedLM. This is the model-class route.
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "answerdotai/ModernBERT-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = "The capital of France is [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# To get predictions for the mask:
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print("Predicted token:", predicted_token)The pipeline route is shorter.
import torch
from transformers import pipeline
from pprint import pprint
pipe = pipeline(
"fill-mask",
model="answerdotai/ModernBERT-base",
torch_dtype=torch.bfloat16,
)
input_text = "He walked to the [MASK]."
results = pipe(input_text)
pprint(results)| Tool | What it does |
|---|---|
| fill-mask pipeline | Predicts the word hidden behind the mask |
| AutoModelForMaskedLM | Loads the model for masked word prediction |
| flash-attn | Optional package for faster attention on supported GPUs |
| hf download | Fetches the model files to your computer |
You give the sentence "The capital of France is [MASK]." The model scores candidate words for the masked spot, and the card's sample prints Paris as the predicted token.
Fill-mask means the model guesses a hidden word from the words around it. Try the pipeline example with your own sentence, and keep the mask token in it.
The model uses rotary positional embeddings for long inputs, attention that alternates between local and global layers, and unpadding with Flash Attention for fast inference. It does not use token type IDs, so you can leave that parameter out. Downstream tasks follow standard BERT fine-tuning recipes.
The card evaluates the model on language understanding, general retrieval, long-context retrieval and code retrieval.
Predicts a hidden word in English text or code, and after fine-tuning serves as a long-context encoder for search, classification and retrieval. Made for developers and researchers who need a fast BERT-style encoder.
Made by answerdotai on Hugging Face. These notes are Mindket's, written from its model page and model card; the model's own files and license are on Hugging Face.
What it is: ModernBERT-base is an updated BERT-style encoder with 22 layers and 149 million parameters. It predicts masked words out of the box, and you fine-tune it for tasks such as classification, retrieval or question answering.
Who it suits: It suits developers and researchers who build search, classification or retrieval systems and want a fast encoder that reads long documents and code.
Industry | Who uses it | How they use it | Example
Search | Retrieval engineers | Embed long documents for semantic search | Index a large corpus of articles
Software | Developers | Search code and mixed text-and-code content | Find code snippets by meaning
Data science | ML engineers | Fine-tune a classifier on long text | Label support tickets by topic
Research | NLP researchers | Compare encoder models on standard benchmarks | Test GLUE and BEIR scores
If you need a model that writes or chats, you can skip it, since it only encodes text.
Where to use it: It runs in Python through the transformers library, on a CPU or a GPU.
Use case | Who | What they get back
Fill-mask prediction | Developers | The most likely word for a hidden position
Retrieval and semantic search | Search teams | Vectors for long documents after fine-tuning
Classification | ML teams | A fine-tuned encoder for labels
How to set it up: You need Python and transformers at version 4.48.0 or newer. If your GPU supports it, the card recommends adding Flash Attention 2.
pip install -U huggingface_hub
hf download answerdotai/ModernBERT-base
pip install -U transformers>=4.48.0
pip install flash-attn
How to use it: Use the fill-mask pipeline, or load the model with AutoModelForMaskedLM. This is the model-class route.
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "answerdotai/ModernBERT-base"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = "The capital of France is [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# To get predictions for the mask:
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print("Predicted token:", predicted_token)
The pipeline route is shorter.
import torch
from transformers import pipeline
from pprint import pprint
pipe = pipeline(
"fill-mask",
model="answerdotai/ModernBERT-base",
torch_dtype=torch.bfloat16,
)
input_text = "He walked to the [MASK]."
results = pipe(input_text)
pprint(results)
Tool | What it does
fill-mask pipeline | Predicts the word hidden behind the mask
AutoModelForMaskedLM | Loads the model for masked word prediction
flash-attn | Optional package for faster attention on supported GPUs
hf download | Fetches the model files to your computer
Example: You give the sentence "The capital of France is [MASK]." The model scores candidate words for the masked spot, and the card's sample prints Paris as the predicted token.
For newcomers and experts: Fill-mask means the model guesses a hidden word from the words around it. Try the pipeline example with your own sentence, and keep the mask token in it.
The model uses rotary positional embeddings for long inputs, attention that alternates between local and global layers, and unpadding with Flash Attention for fast inference. It does not use token type IDs, so you can leave that parameter out. Downstream tasks follow standard BERT fine-tuning recipes.
Tokenize text with a mask token
The encoder reads the whole sentence
Scores come out for each word
Pick the top word or fine-tune further
Good to know: The card evaluates the model on language understanding, general retrieval, long-context retrieval and code retrieval.
Download its files with Hugging Face's command line:
pip install -U huggingface_hub
hf download answerdotai/ModernBERT-base
Then follow the usage in its model card. Nothing in this kit runs by itself.
README.md 6 KB
Listed Hugging Face models in the same category that share the most tags with this one.
| Product | Downloads, last 30 days | Likes | Parameters | License | Last change |
|---|---|---|---|---|---|
| ModernBERT-base This page | 2,939,636 | 1,155 | 150M | apache-2.0 | |
| ModernBERT-largeShares masked-lm · fill-mask · modernbert | 572,085 | 504 | 396M | apache-2.0 | |
| mmBERT-baseShares fill-mask · modernbert · pytorch | 353,305 | 283 | — | mit | |
| BERT base model (uncased)Shares fill-mask · pytorch · onnx | 31,346,528 | 3,071 | 110M | apache-2.0 | |
| UltraBERT-380MShares fill-mask · long-context · transformers | 15,830 | 82 | 430M | apache-2.0 | |
| auto-150m-3Shares modernbert · long-context · transformers | 207 | 4 | 150M | apache-2.0 |
Posts and comments that name this project on Hacker News, Bluesky, X, Reddit, Facebook and YouTube, found by a weekly search and on Trendshift. Mindket doesn’t write or check them. Open one to read it where it was posted.
Sokheng · Kit
Reads Khmer and English text from documents, receipts and photos of signs, using a detector for text lines and a recogniser for each line. Suits developers who…
Qwen · Kit
Qwen2.5-7B-Instruct as GGUF files in eight quantization sizes, to chat with locally through llama.cpp. For people who want a capable 7.6B model on their own co…
ACE-Step · Kit
Generates music from text with a 4B diffusion decoder, 50 steps and guidance control, aiming for higher audio quality than the base. For creators with a GPU of…
alirezarezvani · Skill
Adds 411 ready-made skills for Claude Code and other coding agents, grouped by role from engineering and product to marketing, finance and compliance. Installs…
block · Kit
Self-hostable workspace where people and AI agents share the same rooms, built on a Nostr relay that logs every action as a signed event. For teams that want t…
backnotprop · Kit
Opens your AI coding agent's plans, specs and code changes in a browser so you can annotate or comment on them and send the feedback straight back to the agent.