banner-readme-light

EdgeCoder-31M

EdgeCoder-31M is a compact English text encoder (31M parameters, 8 layers) with a context of up to 8192 tokens. It is pre-trained with ModernELECTRA: replaced-token detection (RTD), as in ELECTRA and DeBERTaV3, plus a boundary-window reconstruction task.

RTD encoders are strong on classification but usually weak as backbones for embedding models. EdgeCoder-31M keeps the classification quality of RTD and, after fine-tuning, matches masked-language-model encoders of its size on embedding tasks.

Model details

Architecture DeBERTa-v2 (disentangled relative attention, no absolute positions)
Layers / hidden / FFN / heads 8 / 384 / 1536 / 6
Token embedding factorized: 128-d table with a linear projection to 384
Parameters 31.0M (14.2M without the embedding table)
Maximum sequence length 8192 tokens
Tokenizer DeBERTa-v3 SentencePiece (128,100 tokens)
Language English

The repository contains the discriminator encoder. It has no masked-language-model head, so it is meant for fine-tuning and feature extraction, not for fill-mask.

Usage

The checkpoint is a standard DeBERTa-v2 model and loads with transformers:

from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("knowledgator/EdgeCoder-31M")
model = AutoModel.from_pretrained("knowledgator/EdgeCoder-31M")

inputs = tokenizer("EdgeCoder is a compact text encoder.", return_tensors="pt")
outputs = model(**inputs)
hidden = outputs.last_hidden_state  # (batch, seq_len, 384)

For fine-tuning, use the usual task heads, for example AutoModelForSequenceClassification or AutoModelForTokenClassification.

Long inputs and faster inference with FlashDeBERTa

The standard DeBERTa attention needs memory that grows quadratically with the sequence length. For long inputs, we recommend FlashDeBERTa, the implementation the model was trained with. It loads the same checkpoint:

pip install flashdeberta -U
import torch
from transformers import AutoTokenizer
from flashdeberta import FlashDebertaV2Model

tokenizer = AutoTokenizer.from_pretrained("knowledgator/EdgeCoder-31M")
model = FlashDebertaV2Model.from_pretrained("knowledgator/EdgeCoder-31M").to("cuda")

inputs = tokenizer(long_text, truncation=True, max_length=8192, return_tensors="pt").to("cuda")
with torch.no_grad():
    outputs = model(**inputs)

FlashDeBERTa also provides heads for sequence and token classification, question answering and multiple choice.

Evaluation

All numbers are from the paper. Baselines were run with the same protocols.

GLUE (dev)

Single seed, best run of a hyperparameter sweep that follows the Ettin protocol.

Model Params CoLA SST-2 MRPC STS-B QQP MNLI QNLI RTE Avg
BERT-small 28.8M 44.8 90.1 83.1 87.6 90.1 79.2 88.2 69.3 79.0
MiniLM-L12 33.4M 59.1 93.3 91.2 89.2 91.5 85.6 91.9 74.7 84.6
Ettin-Enc-32m 31.9M 57.4 92.0 89.7 89.5 91.0 83.4 90.7 74.7 83.5
EdgeCoder-31M 31.0M 64.9 92.2 91.8 90.2 91.1 84.5 90.3 82.7 86.0
Larger models, for reference
DistilBERT 66.4M 56.9 92.2 86.8 87.4 90.8 82.7 89.5 66.1 81.5
BERT-base 109.5M 59.0 93.1 89.5 89.4 91.4 85.4 91.6 78.2 84.7
Ettin-Enc-68m 68.1M 64.8 94.4 92.2 91.1 91.9 87.0 92.9 83.8 87.2

MTEB English v2

Each backbone is fine-tuned once into a sentence embedding model on 1M MS MARCO triplets (one epoch, mean pooling, contrastive loss) and then evaluated on the 41 tasks of MTEB English v2. The scores describe the backbone after this fine-tuning, not the checkpoint in this repository used as is.

Model Params Class. Clust. PairCl. Rerank. Retr. STS Summ. Mean (Type)
BERT-small 28.8M 64.7 39.6 79.4 41.7 38.1 73.0 21.6 51.1
MiniLM-L12 33.4M 64.9 37.8 79.8 43.5 38.4 73.2 21.4 51.3
Ettin-Enc-32m 31.9M 64.2 39.6 77.1 42.6 39.7 73.2 19.9 50.9
EdgeCoder-31M 31.0M 65.3 39.7 78.0 42.3 38.6 73.1 20.9 51.1

Training

  • Objective. Replaced-token detection on every position, plus boundary-window reconstruction: each token is predicted from the two hidden states at the borders of a random window (3 to 12 tokens) that contains it. The window loss has weight 0.003.
  • Generator. A separate 4-layer generator is pre-trained with masked language modelling and then frozen. Replacements are sampled from it at a temperature that decreases from 1.5 to 0.9 during training. The masking rate is 30%.
  • Data. About 1.0 trillion tokens of English text: web pages, news, scientific papers and PDFs, books, legal text, source code, mathematics and Q&A forums.
  • Length curriculum. 512 tokens for about 90% of the training tokens, then 2048 and 8192 tokens on long documents.
  • Hardware. One node with 8 × NVIDIA RTX PRO 6000 Blackwell GPUs, bf16 mixed precision.

Limitations

  • English only. For other languages, use EdgeCoder-Multilingual-61M.
  • The model is a backbone. It needs fine-tuning for classification, token classification, retrieval or embedding tasks.
  • GLUE results are single runs with one seed, so differences below about one point should not be over-interpreted.
  • The paper does not include an ablation that isolates the effect of the window objective.

Citation

@misc{shtopko2026modernelectra,
  title         = {{ModernELECTRA}: Replaced-Token Detection with Boundary-Window Reconstruction for Compact Encoders that Classify and Embed},
  author        = {Shtopko, Mykhailo and Stepanov, Ihor and Vodianytskyi, Dmytro and Lukashov, Oleksandr},
  year          = {2026},
  eprint        = {2611.31495},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  url           = {https://arxiv.org/abs/2611.31495}
}
Downloads last month
13
Safetensors
Model size
31M params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including knowledgator/EdgeCoder-31M

Paper for knowledgator/EdgeCoder-31M