Two fully fine-tuned mmBERT regressors that predict five continuous repository-context scores from 0 to 5:
pretraining_valuerepo_qualitycoding_standarddifficultyeducational_valueThese models score the visible source context provided to them. They do not fetch a repository or establish the quality of unseen files. The outputs are regression scores, not class probabilities. Higher difficulty means more difficult material; it is not a quality recommendation.
This branch contains mmbert-small. Both evaluated variants are published in the same repository:
| Revision | Model |
|---|---|
main or mmbert-small |
Fully fine-tuned jhu-clsp/mmBERT-small |
mmbert-base |
Fully fine-tuned jhu-clsp/mmBERT-base |
Install the tested Transformers version and PyTorch for your CPU/GPU platform:
pip install "transformers==5.5.4" "torch>=2.4" "safetensors>=0.4.3"
import torch
from transformers import AutoModel, AutoTokenizer
repo_id = "Machacini/stackifiers-repo"
revision = "mmbert-small" # change to "mmbert-base" for the larger model
tokenizer = AutoTokenizer.from_pretrained(repo_id, revision=revision)
model = AutoModel.from_pretrained(
repo_id,
revision=revision,
trust_remote_code=True,
).to("cuda" if torch.cuda.is_available() else "cpu").eval()
text = """Repository: example/calculator
File: calculator.py
def add(a, b):
return a + b
"""
scores = model.predict(text, tokenizer=tokenizer, chunk_batch_size=4)
print(scores) # a dictionary of five floating-point scores
# A list of texts returns a list of dictionaries in the same order.
batch_scores = model.predict([text, text], tokenizer=tokenizer, chunk_batch_size=4)
For reproducible deployments, replace revision with a specific commit SHA. trust_remote_code=True loads the included, inspectable configuration and model wrapper. The checkpoints themselves use safetensors, with the encoder and trained scoring head together in model.safetensors. No external training repository or original upstream checkpoint download is needed to run the exported model.
model.predict retains the full input instead of truncating it. It tokenizes the text without special tokens, divides it into chunks that fit 8,192 tokens including special tokens, and encodes batches of chunks. Each chunk uses attention-mask-weighted mean pooling over non-padding tokens, including special tokens. Chunk representations are averaged using content-token counts excluding special tokens, then scored once by the trained head:
source text → token chunks → mmBERT → masked mean per chunk
→ content-token-weighted mean across chunks
→ LayerNorm → dropout(0.1) → linear(5) → 5 × sigmoid
chunk_batch_size controls encoder memory use. Lower it if your device runs out of memory. At inference, dropout is disabled. model.predict returns final scores: do not apply another sigmoid or softmax.
For an already tokenized single-chunk batch, model(**tokenizer(texts, padding=True, return_tensors="pt")).logits returns a [batch, 5] tensor in the metric order above. For inputs that may exceed the model's per-chunk limit, use predict or supply explicit owners, chunk_weights, and num_contexts tensors to forward.
Both models use the same 26,754 repository-held-out test contexts. The table includes genuine annotated zero scores; missing/N/A targets are excluded separately for each metric. Results measure agreement with LLM teacher annotations, rather than independent human judgments.
| Variant | Parameters | Test MAE ↓ | Test RMSE ↓ |
|---|---|---|---|
| mmbert-small | 140,496,389 | 0.326695 | 0.557302 |
| mmbert-base | 306,945,029 | 0.318769 | 0.546326 |
Macro MAE is the unweighted mean of the five per-score MAEs. Macro RMSE is the unweighted mean of per-score RMSEs, not the square root of macro MSE. Lower MAE/RMSE and higher Spearman correlation are better.
| Score | MAE ↓ | RMSE ↓ | Spearman ↑ | Labeled test contexts |
|---|---|---|---|---|
| pretraining_value | 0.310120 | 0.464585 | 0.952245 | 26,754 |
| repo_quality | 0.369401 | 0.633371 | 0.890405 | 26,753 |
| coding_standard | 0.352478 | 0.676580 | 0.894324 | 26,754 |
| difficulty | 0.281626 | 0.518015 | 0.867862 | 26,753 |
| educational_value | 0.319848 | 0.493962 | 0.933114 | 26,749 |
| Score | MAE ↓ | RMSE ↓ | Spearman ↑ | Labeled test contexts |
|---|---|---|---|---|
| pretraining_value | 0.304355 | 0.457008 | 0.953680 | 26,754 |
| repo_quality | 0.360555 | 0.623037 | 0.893354 | 26,753 |
| coding_standard | 0.345906 | 0.666004 | 0.896573 | 26,754 |
| difficulty | 0.270646 | 0.502242 | 0.870636 | 26,753 |
| educational_value | 0.312383 | 0.483339 | 0.935696 | 26,749 |
Exact values are included in test-metrics.json and validation-metrics.json on each branch. The larger model has slightly lower test error. These results do not establish an end-to-end inference throughput advantage for either model; timings from cached-feature head evaluation are not encoder inference benchmarks.
The figures below use the same 26,754 repository-held-out test contexts as the evaluation tables, comparing the fully fine-tuned small and base models.
Each line shows the percentage of test contexts in a 0.1-point score bin. All predictions are included, including predictions for contexts with missing teacher targets. Scores remain continuous in [0, 5]; no rounding is used for inference or evaluation. The panels use separate vertical scales for readability.
The second figure compares teacher labels with both models on the same labeled rows per metric. Missing/N/A targets are excluded; genuine zero labels are kept. For this comparison only, predictions are grouped into integer-centered bins: [0, 0.5), [0.5, 1.5), ..., [4.5, 5]. The last bin includes 5. These buckets are a visual summary of continuous scores, not additional model classes.
Aggregate histogram counts and bin definitions · Continuous distributions (SVG) · Teacher comparison (SVG)
These marginal distributions show how scores are spread; per-context agreement is measured by the MAE/RMSE/Spearman results above.
programming, markup, data, and prose categories before splitting.Repository: / File: structure where present. Teacher prompts, teacher scores, AST metrics, and other CPU metadata are not model inputs.The model weights, tokenizers, inference wrapper, evaluation summaries, and checksum-based provenance are published here. Raw training contexts, teacher annotations, optimizer/scheduler/RNG states, intermediate training checkpoints, and per-example test predictions are not included.
Use these models to rank or describe visible code/repository contexts for dataset curation, experimentation, and scoring. Scores are estimates learned from the teacher's rubric. A high score does not verify correctness, security, license compatibility, or repository-wide quality. A documentation-heavy or data-heavy context is still a valid input, but these models do not replace a content-type classifier.
Evaluation is held out by the available repository identity. It does not establish deduplication across repository forks or mirrors, nor accuracy on all programming languages, domains, or input distributions. Language/category-specific evaluation is not reported here. Very long contexts use weighted averaging, which can dilute small but important sections. Functionality-based code quality, execution outcomes, and human preference were not independently measured in this evaluation.
Each export was reloaded through AutoModel.from_pretrained and AutoTokenizer.from_pretrained, then checked numerically against its original trained inference bundle. Verification exercises padding, multiple contexts, special tokens, content-token weighting, and multi-chunk aggregation. See verification.json for the measured maximum score difference and provenance.json for source run identifiers, parameter counts, and source checkpoint/data-manifest SHA-256 fingerprints.
The upstream mmBERT-small and mmBERT-base checkpoints are distributed under the MIT license. This repository uses the MIT license; see LICENSE. Credit for the pretrained backbones belongs to the mmBERT authors and JHU-CLSP. Evaluation and fine-tuning results above apply to the Stackifiers derivatives.
jhu-clsp/mmBERT-base