TabImpute / matrixformer /README.md
Tabimpute's picture
Add single-checkpoint MatrixFormer model
9c24f63 verified
|
Raw History Blame Contribute Delete
6.88 kB
metadata
license: apache-2.0
tags:
  - matrix-completion
  - missing-data-imputation
  - tabular
  - pytorch
  - safetensors

MatrixFormer: single-checkpoint model

This is the V57 attempt-25 checkpoint selected during the mixed-prior, single-model training experiment. It is one neural network, not the two-expert observed-error blend and not a replacement claimed to outperform that blend. All models are distributed in the same Hugging Face repository, Tabimpute/TabImpute, with this naming convention:

Name Model Weight location
MatrixFormer This single mixed-prior network matrixformer/
MatrixFormer* Observed-error ensemble of the two specialists Both specialist folders; no separate checkpoint
MatrixFormer-Impute Specialized imputation model matrixformer/impute/
MatrixFormer-RecSys Specialized recommender-system model matrixformer/recsys/

The existing specialist files remain unchanged. The ensemble was previously called MatrixFormer+; historical Python identifiers such as MatrixFormerPlus remain compatibility names, not names for this single checkpoint.

Architecture and interface

The architecture configuration is identical to both released experts:

  • 77,998,496 parameters; 8 layers; embedding width 768; 16 attention heads.
  • Feed-forward width 1,536; 12 learned context tokens; 5,000 output bins.
  • The same alternating row/column attention, rotary embeddings and decoder.
  • All 254 state-dictionary tensors load into the existing MatrixFormer implementation with strict=True, without missing or unexpected keys.

The inference contract is unchanged: impute(matrix) accepts a 2D numerical NumPy matrix with NaN for missing entries and returns a finite float64 matrix of the same shape, preserving observed entries and the input array. A CPU float32 smoke test verifies this contract using the released runtime.

The existing SDK's default from_pretrained() calls are still pinned to the older expert release. They do not select this candidate automatically. Explicit loading with the current runtime is shown below; it uses the same single-expert impute() interface.

import json
import numpy as np
from huggingface_hub import hf_hub_download
from matrixformer import MatrixFormerImpute
from matrixformer._inference import Expert

repo_id = "Tabimpute/TabImpute"
folder = "matrixformer"
config_path = hf_hub_download(repo_id, f"{folder}/config.json")
checkpoint_path = hf_hub_download(repo_id, f"{folder}/best_validation_checkpoint.pth")
with open(config_path) as handle:
    config = json.load(handle)["model"]

expert = Expert(
    checkpoint_path, config, device="cpu", precision="float32",
    max_rows=2000, max_cols=1000,
)
model = MatrixFormerImpute({"impute": expert})
matrix = np.array([[1.0, 2.0, np.nan], [2.0, np.nan, 6.0], [3.0, 6.0, 9.0]])
completed = model.impute(matrix)

Install the runtime from https://github.com/jacobf18/MatrixFormer. Compatibility was checked at commit 0040e7260d951d32b69d4e6da7d9c3f4a262821b. The explicit loader currently uses the runtime's internal Expert class, not a newly registered public MatrixFormer.from_pretrained() API. Pin the Hugging Face commit with the revision argument for reproducible downloads.

The public wrapper performs observed-column normalization. This is not the rating-specific two-way/user-scale normalization used for the RecSys benchmark numbers below. Benchmark protocols also fix chunking, masking, clipping and scoring; loading weights alone does not reproduce those settings.

Files

  • best_validation_checkpoint.pth: original weights and scalar checkpoint metadata, unchanged; load with torch.load(..., weights_only=True).
  • model.safetensors: the identical state dictionary, without training metadata. Load with safetensors.torch.load_file; the current SDK's checkpoint loader expects the .pth file rather than this alternative.
  • config.json: minimal inference architecture configuration. The original training configuration, machine paths and synthetic-bank inventories are intentionally not published here.
  • release.json: artifact hashes, architecture and selection provenance.
  • benchmark_comparisons.csv: full-precision frozen real-benchmark comparisons.

Original checkpoint SHA256: 0d0ecb1c61be86e63a2b959004f858fd9ab80fbc71e934fed439eac0c1039f49.

Training and selection

The single student uses mixed synthetic native-imputation, structured-mask and ratings priors (mixture masses 0.50/0.25/0.25), with teacher supervision during training only. Objectives include Huber teacher-mean supervision, NLL/CDF and query/point losses, with protected full-network updates.

The original run completed 100 training attempts before the user stop: 51 updates were accepted and 49 rejected. The returned checkpoint was selected at attempt 25, after 20 accepted updates in this continuation, by the frozen synthetic-development worst-case criterion. It was not selected using these real benchmark scores. A partial attempt 101 was interrupted during gradient capture and is not part of the saved selected checkpoint.

Real benchmark results

All 2,262 tabular cases, four RecSys datasets and 1,800 LLM fold settings completed their prediction audits. Lower errors and higher R2 are better.

Benchmark Metric MatrixFormer MatrixFormer*
MissBench NRMSE 1.611742 1.579644
UCI NRMSE 1.017006 0.997922
MovieLens100K RMSE / MAE 0.892623 / 0.732962 0.887358 / 0.727878
Netflix small RMSE / MAE 0.866575 / 0.736449 0.861721 / 0.732989
MovieLens1M RMSE / MAE 0.880525 / 0.716641 0.876720 / 0.714240
MovieLens10M RMSE / MAE 0.837558 / 0.680112 0.833401 / 0.678188
MTEB R2 / standardized RMSE 0.748890 / 0.473932 0.750499 / 0.467365
MMLU R2 / standardized RMSE 0.886466 / 0.326714 0.888225 / 0.324476
Merged R2 / standardized RMSE 0.435645 / 0.749228 0.411645 / 0.755859
BenchPress R2 / standardized RMSE 0.315359 / 1.009513 0.303030 / 1.014796

The candidate improves the Merged and BenchPress dataset averages but regresses on 14/18 primary and 222/392 required point-estimate comparisons. It does not match the blend across the required scope. MF/SVD and PMF remain stronger on the large MovieLens datasets. These are descriptive results on previously inspected public benchmarks, not significance tests or evidence of universal superiority.

Independent synthetic confirmation and the originally registered 128-attempt training audit remain incomplete. The checkpoint has not been evaluated on the separate fresh/native-missingness Grzesiak or causal-inference suites. Do not infer categorical-imputation support or silently round outputs into category labels. This release is intended as a research candidate.