CoolFace
Modelpublic

Shuu12121/NightOwl

sourceHugging Faceapache-2.0updated 1d agoView on Hugging Face
1likes50downloads
Model Card

NightOwl

NightOwl is a ModernBERT-style code encoder pre-trained from scratch on a diverse mix of source code, natural language, and technical documentation.

NightOwl-large reaches 0.8508 average MRR on MTEB CodeSearchNetRetrieval, exceeding CodeBERT-base (0.7944), GraphCodeBERT-base (0.8325), UniXCoder-base (0.8003), and ModernBERT-base (0.8182) under an identical fine-tuning protocol.

Checkpoints

The NightOwl family is pre-trained in two phases. Both the intermediate (Phase 1) and final (Phase 2) checkpoints are released.

RepoSizePhaseDescription
Shuu12121/NightOwl-PrebasePhase 1Mixed-data MLM pre-training (code + NL + docs)
Shuu12121/NightOwlbasePhase 2Code-only line-level MLM continuation — recommended
Shuu12121/NightOwl-large-PrelargePhase 1Mixed-data MLM pre-training (code + NL + docs)
Shuu12121/NightOwl-largelargePhase 2Code-only line-level MLM continuation — recommended

For downstream code search, start from the Phase 2 checkpoints (NightOwl / NightOwl-large).

Model size

Both variants are ModernBERT encoders (alternating local/global attention, RoPE positional embeddings) with a custom 50,368-token BPE tokenizer.

**NightOwl****NightOwl-large**
ArchitectureModernBERTModernBERT
Parameters (approx.)≈150M≈300M
hidden_size7681024
num_hidden_layers1928
num_attention_heads1216
intermediate_size15361536
vocab_size50,36850,368
Max sequence length1024 (Phase 1) / 2048 (Phase 2)1024 (Phase 1) / 2048 (Phase 2)
Parameter counts are approximate, derived from the architecture configuration (token embeddings + transformer layers + MLM head).

Training data

NightOwl is trained on two source families. Phase 1 uses every source below; Phase 2 continues on the code-related subsets only.

1. bigcode/starcoder2data-extras (12 subsets)

Diverse code, natural-language, and technical-knowledge subsets. max_samples caps the rows sampled per subset; max_chars truncates very long documents to control memory.

Subset`max_samples`PriorityNotesPhase 2
kaggle2,000,000highNotebook-style code
stackoverflow2,000,000highQ&A code threads
issues1,000,000mediumGitHub issue text
owm1,000,000mediumOpen web math
lhq3,000,000highHigh-quality text
wikipedia1,000,000mediumEncyclopedic NL
arxiv600,000lowLong LaTeX docs (max_chars=10,000)
documentation2,000,000highTechnical docs
ir_cpp100,000lowC++ IR (max_chars=5,000)
ir_low_resource100,000lowLow-resource IR (max_chars=5,000)
ir_python100,000lowPython IR (max_chars=5,000)
ir_rust100,000lowRust IR (max_chars=5,000)

2. Shuu12121/github-file-programs-dataset (8 languages)

Whole-file source code, one Hugging Face repo per language (text field: content). Used in both phases.

python, javascript, typescript, java, go, rust, ruby, php

Sampling caps: Phase 1 — up to 1,000,000 files per language; Phase 2 — up to 2,000,000 files per language.

Training procedure

NightOwl is pre-trained in two phases, both using masked-language modeling with mlm_probability = 0.3.

  • Phase 1 — Mixed pre-training. Standard random-token MLM (mlm collator) over all data sources (code + NL + docs). Produces NightOwl-Pre / NightOwl-large-Pre.
  • Phase 2 — Code-only continuation. Line-level MLM (line_no_space collator) over the code-related subsets only. Entire source-code lines are masked rather than random tokens, aligning the objective with code-search downstream tasks. Produces NightOwl / NightOwl-large.

Long examples are split into chunks (split_long_examples: true) so all tokens are used rather than truncated.

HyperparameterNightOwl (base)NightOwl-large
mlm_probability0.30.3
Optimizer schedulecosine, warmup ratio 0.05cosine, warmup ratio 0.05
Learning rate5e-55e-5
Weight decay0.010.01
Precisionfp16fp16
Epochs11
per_device_train_batch_size84
gradient_accumulation_steps3264
Effective batch size256256
Phase 1 max_length10241024
Phase 2 max_length20482048

Evaluation

Evaluated on MTEB CodeSearchNetRetrieval after SentenceTransformer fine-tuning on CodeSearchNet pairs (10,000 samples per language, Multiple Negatives Ranking loss). Each model is swept over six learning rates; the best per-model result is reported. Only the pre-trained backbone differs between rows — the fine-tuning and evaluation recipe is held fixed.

CodeSearchNetRetrieval — MRR by language (best across learning rates)

ModelGoJavaJSPHPPythonRuby**Avg**best-lr
CodeBERT-base0.92420.71760.70070.80890.84990.76510.79443e-5
GraphCodeBERT-base0.93730.79910.74020.83390.87850.80590.83253e-5
UniXCoder-base0.86740.82760.69490.81150.86430.73600.80035e-5
ModernBERT-base0.92780.76630.74650.81530.87310.78020.81823e-5
NightOwl0.94120.82320.75540.83090.89840.81240.84361e-5
NightOwl-large0.93930.83140.77530.83980.90230.81690.85081e-5

NightOwl-large takes five of seven score columns, including the average.

Usage

NightOwl is an encoder backbone. Load it directly for masked-LM / feature-extraction, or wrap it as a SentenceTransformer for code search.

Masked language modeling

python
from transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("Shuu12121/NightOwl")
model = AutoModelForMaskedLM.from_pretrained("Shuu12121/NightOwl")

Feature extraction

python
from transformers import AutoTokenizer, AutoModel
import torch

tokenizer = AutoTokenizer.from_pretrained("Shuu12121/NightOwl")
model = AutoModel.from_pretrained("Shuu12121/NightOwl")

code = "def add(a, b):\n    return a + b"
inputs = tokenizer(code, return_tensors="pt", truncation=True, max_length=1024)
with torch.no_grad():
    embeddings = model(**inputs).last_hidden_state  # [1, seq_len, hidden_size]

Limitations

  • NightOwl is an encoder for understanding/retrieval, not a generative model — it does not produce code.
  • Code-search strength is best realized after SentenceTransformer fine-tuning; the raw backbone is not a ready-to-use retriever.
  • Training data is dominated by 8 programming languages; performance on other languages may be lower.
  • Pre-training data is sampled from public sources and may contain bugs, insecure patterns, or biased content.