liaogx_/tabstar
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

TabSTAR on Ascend NPU

TabSTAR: A Foundation Tabular Model With Semantically Target-Aware Representations (arXiv:2505.18125, MIT © Alan Arazi et al.) — deployed on Ascend 910 NPU with torch_npu.

alana89/TabSTAR is a tabular foundation model designed for transfer learning on tabulated data that contains free-text columns. It unfreezes a pretrained text encoder (intfloat/e5-small-v2) and takes target tokens as input so the model can learn task-specific embeddings. Its architecture is free of dataset-specific parameters:

  • Text encoder — intfloat/e5-small-v2 (BERT, hidden 384), unfrozen, takes the verbalized feature strings (Predictive Feature: <col>\nFeature Value: <value>) plus target tokens (Target Feature: <label>\nFeature Value: <class>).
  • NumericalFusion — per-column scalar embedder + a 2-layer Transformer fusion block that merges each text embedding with its numeric embedding.
  • InteractionEncoder — 6-layer Transformer encoder (d_model 384, 6 heads) over the feature sequence.
  • PredictionHead — MLP on the target-token positions → class logits (or a single regression value).

Runtime: torch_npu + FastAPI serving (/v1/classify, /v1/regress). vLLM-Ascend 0.18 is not applicable: the registry has no non-autoregressive tabular-LLM entry and the model is a custom TabStarModel (model_type tabstar), so inference runs the base model weights directly on the NPU.

Environment

ComponentVersion
Ascend910 (64GB HBM), CANN 8.5.1
torch / torch_npu2.9.0 / 2.9.0.post1
transformers4.57.6
tabstar1.1.16 (vendored, 2 NPU patches)
Python3.11.14

Files

  • inference.py — TabSTAR engine (loads base weights on NPU, zero-shot predict)
  • server.py — FastAPI service (/health, /v1/classify, /v1/regress)
  • start_serve.sh — one-shot launch (npu:1:8040)
  • download_model.py — idempotent weight download (hf-mirror + sha256 check)
  • npu_smoke.py / test_server.py / verify_npu_vs_cpu.py — validation
  • tabstar/ — vendored tabstar package with NPU patches (patches/tabstar_ascend_npu.patch)

Quick start

pip install -r requirements.txt            # peft skrub joblib ...
python3 download_model.py                  # weights -> /data/.cache/models
bash start_serve.sh                        # npu:1:8040
python3 test_server.py                     # classify + regress smoke tests
python3 verify_npu_vs_cpu.py               # NPU vs CPU numerical agreement

The service exposes two zero-shot endpoints. Each request carries a small labeled training table (to fit the semantic verbalizer / scalers) plus an unlabeled test table:

curl -s localhost:8040/v1/classify -H 'Content-Type: application/json' \
  -d '{"dataset":"imdb","test_size":0.1}'
# convenience demo using the official imdb.csv quickstart

or send raw tables:

{
  "train": [{"review": "A hilarious comedy", "rating": 7.2, "label": "comedy"}, ...],
  "target": "label",
  "test": [{"review": "A touching drama", "rating": 6.8}, ...]
}

Adaptation notes (NPU)

Two small patches to the vendored tabstar package (see patches/tabstar_ascend_npu.patch):

  1. arch/arch.py — force attn_implementation="eager" for the E5-BERT text encoder (aclnnFlashAttentionScore is historically unstable on torch_npu for this model).
  2. preprocessing/feat_types.py — treat pandas str dtype (pandas≥3.0) as a textual feature in is_numerical_feature (upstream expects object dtype and raises).

The rest of the model (eager Transformer blocks, linear/ReLU/softmax heads, scalers) is native NPU-friendly and runs unmodified.

Test case

Official quickstart demo — IMDB movie table (Genre_is_Drama, text + numeric columns), zero-shot (no fine-tuning):

MetricValue
Classification accuracy (80 rows)0.975
NPU vs CPU probability max_abs_diff2.3e-3
NPU vs CPU cosine0.999999881
NPU vs CPU label agreement1.000
NPU latency~26 ms/row
CPU latency~302 ms/row (~11.4× faster on NPU)
Serving HTTP (80 rows)p50 ≈ 683 ms
Process HBM~1.15 GB (npu:1)

License & provenance

Weights: alana89/TabSTAR (cc-by-4.0), pulled via hf-mirror.com. Code: MIT © Alan Arazi et al. (package tabstar 1.1.16, vendored with 2 NPU patches).