模型名称: SAP/sap-rpt-1-oss
模型链接: HuggingFace
模型描述: RPT (Row-Column Prediction Transformer) 是一种基于表格上下文学习(Tabular In-Context Learning)的模型,通过二维注意力机制同时捕捉行间和列间的关系,在无需微调的情况下对表格数据进行分类和回归预测。
模型架构: TwoDimensionalAttention (12层) + RoBERTa-style Transformer,隐藏层维度 768
参数规模: 172M (base 配置)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.7.0 | PyTorch 框架 |
| torch-npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.52.4 | HuggingFace 模型库 |
| sap-rpt-oss | 1.0.1 | SAP RPT 模型实现 |
| sentence-transformers | latest | 文本特征 embedding |
| scikit-learn | >= 1.6.1 | 数据集及评估 |
| pandas | >= 2.2.3 | 数据处理 |
| pyarrow | >= 20.0.0 | 数据IO |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu torch transformers sap-rpt-oss sentence-transformers scikit-learn pandas pyarrow# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace
huggingface-cli download SAP/sap-rpt-1-oss --local-dir ./weights方式二:ModelScope(HuggingFace 下载慢时使用)
python3 -c "from modelscope import snapshot_download; snapshot_download('SAP/sap-rpt-1-oss', cache_dir='./weights')"# 设置 NPU 设备
export ASCEND_RT_VISIBLE_DEVICES=0
# 运行推理脚本(分类 + 回归测试)
python3 inference.py --model-path ./weights| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --context-size | int | 120 | 上下文样本数 |
| --task | str | both | 任务类型: classification / regression / both |
[模型] SAP RPT-1-OSS
[设备] Ascend910 (npu:0)
[输入] Iris 数据集 (4 特征, 3 类别)
[上下文] 120 样本, [查询] 30 样本
[准确率] 83.33% (25/30)
[状态] SUCCESS[模型] SAP RPT-1-OSS
[设备] Ascend910 (npu:0)
[输入] Wine 数据集 (13 特征, 预测 alcohol 含量)
[上下文] 100 样本, [查询] 78 样本
[MSE] 0.4430, [MAE] 0.5788
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./weights --task classification输出:
============================================================
测试1: 分类任务 (Iris 数据集)
============================================================
Context: 120 samples, Query: 30 samples
Features: ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']
Classes: ['setosa', 'versicolor', 'virginica']
分类准确率: 83.33% (25/30)
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./weights --task regression输出:
============================================================
测试2: 回归任务 (Wine 数据集)
============================================================
Context: 100 samples, Query: 78 samples
回归 MSE: 0.4430, MAE: 0.5788
[状态] SUCCESS


测试数据: sklearn Iris (分类), Wine (回归)
评测指标:
| 指标 | 结果 | Baseline (论文) | 差异 |
|---|---|---|---|
| 分类准确率 (Iris) | 83.33% | ~96% (with more context) | 上下文较少 |
| 回归 MSE (Wine) | 0.4430 | N/A | - |
评测命令:
python3 inference.py --model-path ./weights --task bothSAP/sap-rpt-1-oss 在 HuggingFace 上为 gated 模型,需要申请访问权限。可使用 ModelScope 镜像下载。sentence-transformers/all-MiniLM-L6-v2,当前在 CPU 上运行。模型 forward 在 NPU 上执行。torch.where 警告: 在 embedding 层使用 torch.where 时可能出现 allow_internal_format 警告,不影响推理结果。