You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Print-safe ColSmol adapters for page retrieval (RU documents)

Small adapters on top of the pinned base vidore/colSmol-256M (c79b633e17e060cc109b11aa2bf92a1517d3bd6f) that make late-interaction page retrieval work on Russian scanned forms where printed fields and handwritten entries live on the same page. Each page is one document; queries are short text values from a field (an INN, a MAC address, a surname, a date).

The plain vision-LoRA recipe improves handwriting a lot but breaks the printed control (printed Hit@10 0.667 β†’ 0.604, printed MRR 0.356 β†’ 0.236). Both adapters here fix that, in two different ways.

Adapter Tensors What was trained Selection hand MRR@10 Selection print MRR@10 Selection print Hit@10
zero-shot base β€” β€” 0.2106 0.3563 0.6667
printfix_dense (default) 2 Dense projection head only 0.3675 0.3533 0.6667
printfix_anchor 146 vision LoRA + Dense head, printed-page anchor loss 0.4462 0.3081 0.6667
plain LoRA (not shipped) 146 vision LoRA + Dense head, no regularisation 0.4406 0.2359 0.6042

Why it happens: the LoRA sits on the vision encoder only, so page embeddings drift while text queries (including printed ones) stay fixed. printfix_dense never touches the encoder, and printfix_anchor penalises cosine drift of printed pages away from their zero-shot embeddings during training.

Locked-v3 result (preregistered, single run)

printfix_dense was evaluated once on a frozen 50-page / 22-query set that was never used for training or selection, under a rule registered before the run (overall β‰₯ 14/22, handwriting β‰₯ 5/10, printed β‰₯ 8/12, and per-kind non-inferiority against a fresh same-runtime zero-shot):

System overall Hit@10 handwriting (10) printed (12) overall MRR@10
fresh zero-shot 17/22 6/10 11/12 0.4706
printfix_dense 19/22 8/10 11/12 0.6542

verdict.passed = true. The printed block is not just preserved β€” its MRR rose from 0.5544 to 0.6708 on that set. The full verdict, both systems and every per-query rank are in the adapter's sidecar JSON (adapters/printfix_dense.json β†’ locked_v3).

Training

  • data: 789 training pairs (405 handwritten + 384 printed) over 96 pages; selection 178 pairs over 24 pages, page-disjoint from training;
  • loss: multi-positive InfoNCE over 1 positive + 4 sampled negatives, temperature 1.0, seed 13, AdamW, lr 1e-4, weight decay 0.01, 3 epochs. Only the adapter's own tensors are trainable; the base stays frozen;
  • printfix_anchor adds 2.0 Γ— mean(1 βˆ’ cos(page_embedding, zero_shot_embedding)) for printed-control training steps, with the zero-shot embeddings cached for all 96 training pages;
  • every run is reproducible from the sidecar JSONs: they record data SHA256s, hyper-parameters, the training report hash and the source checkpoint hash.

Usage

pip install -r requirements.txt

# index a folder of page scans (CPU or --device cuda:0)
python colsmol_adapter_cli.py index scans/*.png --index-dir index/

# search by a field value
python colsmol_adapter_cli.py search "4500033696!" --index-dir index/ --top-k 5
python colsmol_adapter_cli.py search "ΠœΠ•Π–Π ΠΠ™ΠžΠΠΠΠ― Π˜ΠΠ‘ΠŸΠ•ΠšΠ¦Π˜Π―" --index-dir index/ --json

# the other adapter, or the stock base
python colsmol_adapter_cli.py index scans/*.png --index-dir index-anchor/ --adapter printfix_anchor
python colsmol_adapter_cli.py index scans/*.png --index-dir index-stock/ --no-adapter

The CLI stores per-page multi-vector embeddings (fp16, index.pt) plus a manifest (index.json) that records the base revision and the adapter SHA256. An index built with an adapter cannot be searched without it, or with a different adapter β€” the CLI stops with an explicit error instead of silently mixing representations. Re-running index on the same directory only adds pages that are not there yet.

Typical cost on CPU (single core-bound process, ColSmol-256M): about 6–13 s per page for indexing, tens of milliseconds per query for up to a few thousand pages; store roughly 0.23 MiB per page (fp16, ~945 vectors Γ— 128 dims).

Files

File Contents
colsmol_adapter_cli.py self-contained index/search CLI
adapters/printfix_dense.safetensors + .json default adapter (2 tensors) and its provenance/verdict
adapters/printfix_anchor.safetensors + .json LoRA-anchored adapter (146 tensors) and its provenance
requirements.txt torch, sentence-transformers, peft, safetensors, Pillow
LICENSE MIT for the adapters (base model keeps its own license)

Limitations

  • The locked evaluation is small: 50 pages, 22 queries, one registered run. Treat the numbers as evidence, not as a guarantee.
  • Domain: Russian scanned bank/administrative forms with a mix of printed and handwritten fields. Other languages, layouts and photo captures were not measured.
  • Documents are whole pages, not field crops; a query is matched against the entire page, so very small fields on dense pages are the hard case.
  • The adapters assume the pinned base revision. A different base checkpoint is rejected.
  • printfix_anchor brings printed Hit@10 back to the zero-shot level but its printed MRR stays below zero-shot (0.308 vs 0.356); if printed quality is the priority, use printfix_dense.

License

Adapters: MIT (see LICENSE). The base vidore/colSmol-256M keeps its own license (SmolVLM-256M backbone Apache-2.0, ColSmol adapters MIT β€” permissive, but read the model card). Training data was internal annotated scans; only aggregated metrics and hashes are published here, no page images.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Adiutant/colsmol-printfix-lora