Text Classification
Transformers
Safetensors
Laya
x402
agentic-commerce
calibrated-decisions
rlcd
system-one
crypto
base
solana
Instructions to use Priceman614/x402-demand with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Priceman614/x402-demand with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Priceman614/x402-demand")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Priceman614/x402-demand", device_map="auto") - Laya
How to use Priceman614/x402-demand with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download code/recalibrate.py from Priceman614/x402-demand: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/Priceman614/x402-demand/resolve/main/code/recalibrate.py
- Command line
-
hf download hf://Priceman614/x402-demand/code/recalibrate.py
-
curl -L -o recalibrate.py https://huggingface.co/Priceman614/x402-demand/resolve/main/code/recalibrate.py
1.93 kB
| """Post-hoc isotonic recalibration for a checkpoint (used by the paid API, not the Laya format). | |
| Laya checkpoints carry one temperature per question type, which cannot fix the shape of the | |
| miscalibration we measured (over-confident at the top only). The API applies this monotone | |
| map after the model, so AUC is unchanged by construction; only the probabilities move. | |
| Fitted on calibration hosts (never trained on), scored on the held-out test set. | |
| Output: <ckpt>/isotonic_paid7d.json ({"x": [...], "y": [...]} for np.interp). | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| import pandas as pd | |
| import torch | |
| from sklearn.isotonic import IsotonicRegression | |
| from common import SPLITS, metrics, split | |
| from evaluate import load_ckpt, score | |
| from train_laya import CALIB_HOSTS | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--ckpt", type=Path, required=True) | |
| args = ap.parse_args() | |
| device = torch.device("cuda") | |
| model, tok, cfg = load_ckpt(args.ckpt, device) | |
| variant = cfg["x402_variant"] | |
| df = pd.read_parquet("data/rows.parquet") | |
| cal = df[df.anchor_idx.isin(SPLITS[7]["train_anchors"]) & df.host_bucket.isin(CALIB_HOSTS) & (df.paid_7d >= 0)] | |
| _, _, te = split(df, 7) | |
| p_cal = score(model, tok, cfg, cal, variant, "paid_7d", device) | |
| p_te = np.load(args.ckpt / "test_pred_paid7d.npy") | |
| iso = IsotonicRegression(out_of_bounds="clip", y_min=0.001, y_max=0.999).fit(p_cal, cal.paid_7d) | |
| p_iso = iso.predict(p_te) | |
| y = te.paid_7d.to_numpy() | |
| before, after = metrics(y, p_te), metrics(y, p_iso) | |
| print("test before:", before) | |
| print("test after :", after) | |
| out = {"fit_on": f"{len(cal):,} calibration-host rows", "x": iso.X_thresholds_.round(5).tolist(), | |
| "y": iso.y_thresholds_.round(5).tolist(), "test_before": before, "test_after": after} | |
| (args.ckpt / "isotonic_paid7d.json").write_text(json.dumps(out, indent=1)) | |
| np.save(args.ckpt / "test_pred_paid7d_isotonic.npy", p_iso) | |