Bolmo-1B Code / Legal Detector β€” LoRA + evidence-head weights

An independent research fine-tune of Ai2's Bolmo-1B. The trained system scores C/C++ functions for vulnerabilities and terms-of-service sentences for potentially unfair terms, with supporting source-region scores. Its detection path does not autoregressively generate explanations.

Release scope: trained LoRA adapter weights, trained detector/evidence-head weights, validation-fitted deployment calibration, measured metrics, and minimal artifact-loading infrastructure. The application, head implementation, training code, preprocessing, collection pipelines, and dataset-generation scripts remain private. This repository is not a standalone end-to-end detector. The scores below require the adapter, head, and original preprocessing together; attaching this adapter to a text-generation pipeline does not reproduce them.

Held-out results

Metric C/C++ vulnerability classification Unfair ToS sentence classification
Test examples 1,024 1,022
Positive examples 47 105
Positive prevalence 4.590% 10.274%
AUROC 0.8946 0.9658
Average precision 0.7656 0.8034
F1 0.6869 0.7544
Precision 0.6538 0.6992
Recall 0.7234 0.8190
False-positive rate 0.0184 0.0403
Brier score 0.02769 0.03883
ECE, 10 bins 0.01995 0.02673
Decision threshold 0.595927 0.315978
TP / FP / FN / TN 34 / 18 / 13 / 959 86 / 37 / 19 / 880

These are results on sampled evaluation subsets, not full benchmark or leaderboard scores. Full-precision measurements and counts are in metrics.json. Calibration and decision thresholds were fitted/selected on validation only; the test set was not used to fit them. ECE is specific to the reported 10-bin estimator and sample prevalence.

Evidence localization

On 37 positive test functions with matched fix-derived line annotations, top-1 / top-3 / top-10 hit rates were 35.14% / 48.65% / 81.08%; mean reciprocal rank was 0.4794. Top-10 mean annotated-line recall was 62.62%. A hit means at least one annotated line appears among the ranked regions. These annotations are weak, derived from fixes; unannotated lines remain unknown. No verified gold-byte-span F1 is available, and evidence probabilities are uncalibrated. Legal supervision is sentence-level; no legal fine-grained localization result is reported.

Data and evaluation protocol

  • Code: sampled C/C++ records from the LineVul / BigVul data distribution. All official CSVs were regrouped into deterministic SHA-256 commit-based 80/10/10 partitions before sampling. This is a commit holdout, not an unseen-project holdout.
  • Legal: the UNFAIR-ToS task from LexGLUE, reduced to a binary potentially-unfair sentence label, using official splits.
  • Exact-text and group checks were applied after sampling. Final counts: 3,686 train / 1,022 validation / 2,046 test. Training code examples were balanced by class; test prevalence was not balanced.
  • Evaluated documents were at most 2,048 UTF-8 bytes. No cross-file or whole-contract capability is established.

The data and preprocessing scripts are not redistributed here. The training-data fingerprint is recorded in metrics.json for provenance, not as a claim of public reproducibility.

Training and artifacts

Base: allenai/Bolmo-1B, pinned to 247323b0d35908cf3378f6c10c633c8bde7ecb4a. LoRA rank 4, alpha 8, attention projection targets q_proj, k_proj, v_proj, o_proj; 1,048,576 adapter parameters. A small detection/evidence head was trained jointly. The completed run used float32, seed 42, and 1,639 optimizer steps across four curriculum phases. Byte windows: 1,024 bytes, stride 768. Best checkpoint selected on validation; document logits are Platt-calibrated per domain.

File Purpose
adapter_model.safetensors, adapter_config.json Standard PEFT LoRA weights/config; base weights are not redistributed
detector_head.safetensors Trained head state only; no architecture implementation
deploy_config.json Pinned base, dimensions, limits, calibration coefficients and thresholds
metrics.json Evaluation counts, full-precision metrics, split protocol and limitations
load_adapter.py, requirements.txt Minimal loading/calibration infrastructure; no detection pipeline
artifact_manifest.json SHA-256 hashes of the released artifacts

The saved original system reproduced logits exactly on a four-document reload probe (maximum absolute difference 0.0). Release packaging separately checks tensor round trips and metric confusion counts. This does not establish reproducibility without the private pipeline.

Loading infrastructure

Requires Python >=3.11 and CUDA; float32 model memory must fit the selected GPU. The base uses pinned custom model code and xLSTM kernels. Install requirements.txt, then:

from load_adapter import load_artifacts, calibrate_document_logit
model, tokenizer, head_state, cfg = load_artifacts(revision="<immutable Hub commit SHA>")
# raw_logit must come from the original detection pipeline, not LM output logits.
# probability, flagged = calibrate_document_logit(raw_logit, "CODE", cfg)

The loader attaches the adapter and loads head tensors/config. It intentionally does not implement source preprocessing, byte pooling, head construction, or source-span inference. There is no public inference API, hosted demo, or turnkey detector in this release.

Limits and intended use

Research and portfolio artifact for human-reviewed vulnerability/contract-language triage. The legal task predicts dataset annotations about potentially unfair clauses; it does not establish enforceability or provide legal advice. No Solidity, Ethereum, Trojan, prompt-injection, assembly, exploit execution, or bounty-earning result is claimed. It does not produce logical explanations or guarantee that a document is safe. No controlled throughput, latency, inference-memory measurement, or superiority over a generative LLM is claimed.

Licensing and attribution

Bolmo is developed by Ai2 and released under Apache 2.0, as documented on its model card. Base weights are obtained from Ai2 and retain their original terms. This upload does not grant an additional license to LoganCar's new release artifacts; no open-source license is selected for them. Upstream dataset and dependency terms still apply. Public availability is not a statement that the private application or training pipelines are open source.

Downloads last month
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for LoganCar/bolmo-1b-code-legal-detector-lora

Finetuned
allenai/Bolmo-1B
Adapter
(1)
this model