---
title: ASA
canonical_url: "https://www.modelscope.cn/datasets/zhourun/ASA"
md_url: "https://www.modelscope.cn/datasets/zhourun/ASA.md"
repository: zhourun/ASA
chinese_name: "ASA-MoV 激活操控工具调用"
last_updated: 2026-07-08
license: "Apache License 2.0"
storage_size: "380 MB"
downloads: 508
stars: 1
---

# ASA

> ASA - zhourun 在 ModelScope 开源的数据集。ASA-MoV: Activation Steering for LLM tool calling — code, trained probes, hidden-state datasets, and full BFCL results

zhourun/ASA 是 ModelScope 魔搭社区上的数据集，存储大小 380 MB，采用 Apache License 2.0 许可。

- **Repository**: zhourun/ASA
- **License**: Apache License 2.0
- **Storage size**: 380 MB
- **Downloads**: 508
- **Stars**: 1
- **Last updated**: 2026-07-08

Source: https://www.modelscope.cn/datasets/zhourun/ASA

---

## 一、目录结构

```
ASA/
├── code/                       # 核心源代码
│   ├── bfcl_asa/              # 主实现：BFCL benchmark + ASA hooks
│   │   ├── pipeline_v4.py            # 核心 inference pipeline（最终版）
│   │   ├── state_level/              # 多轮 state-level 模块
│   │   ├── run_state_cascade_asa_v9.py   # 多轮 ASA（最终版 v9）
│   │   ├── run_single_asa_v4.py          # 单轮 ASA（最终版 v4）
│   │   ├── run_live_asa_v4.py            # Live ASA（最终版 v4）
│   │   ├── train_state_level_assets.py   # 多轮探针训练
│   │   ├── train_assets_single.py        # 单轮探针训练
│   │   ├── train_assets_live.py          # Live 探针训练
│   │   ├── collect_*_state_dataset.py    # hidden state 数据收集脚本
│   │   ├── run_baseline_*.py             # 对照实验脚本（Probe&Prefill、Tool-identity）
│   │   └── compile_*.py                  # 报告生成
│   ├── common/                # 通用工具（data utils, eval utils, MOV vectors）
│   ├── qwen25/                # Qwen2.5 系列（预实验代码）
│   ├── llama3/                # Llama-3 系列（消融）
│   └── visualization/         # H1/H2/H3 可视化脚本（PCA, Logit Lens, 跨模型）
│
├── assets/                    # 训练好的探针 + 方向向量（核心产物）
│   ├── multi_turn_assets.pkl              # 多轮 (rescue, hurt, stop) probes + 177 vectors
│   ├── multi_turn_assets_v2.pkl, v3.pkl   # 多轮迭代版本
│   ├── multi_turn_assets_v4_golden.pkl    # v4 golden 版本（论文复现）
│   ├── single_turn_assets.pkl             # 单轮 rescue probe + 15 vectors
│   └── live_assets.pkl                    # Live rescue probe + 12 vectors
│
├── training_records/          # 收集到的 hidden state 数据集（最贵的部分，~360M）
│   ├── multi_turn_train_records.pkl              # 多轮 raw（104M）
│   ├── multi_turn_train_records_augmented.pkl    # 多轮 + negative augmentation（104M）
│   ├── single_turn_train_records.pkl             # 单轮（49M）
│   └── live_train_records.pkl                    # Live（98M）
│   每条记录包含：sample_id / category / step_bucket / L20/L24/L28 三层 4096-dim 隐藏向量
│
├── results/                   # 实验结果 pkl
│   ├── multi_turn/                        # state_cascade_results_v3..v13.pkl
│   ├── single_turn/                       # single_baseline.pkl, single_asa_v1..v4.pkl
│   ├── live/                              # live_baseline.pkl, live_asa_v1..v4.pkl
│   └── baseline_comparison/               # P&P / Tool-identity 对照实验完整结果
│
├── reports/                   # Paper-ready 报告与汇总
│   ├── baseline_comparison_full_results.md   # 三大子集详细指标对照表
│   ├── bfcl_paper_report.md                  # 投稿用主报告
│   ├── multiturn_report.md                   # 多轮单独报告
│   ├── BFCL_MultiTurn_Model_Comparison.md   # 跨模型对比
│   ├── ASA_Results_Summary.md                # 早期 summary
│   ├── BFCL_V4_FULL_SETUP.md                # 复现指南
│   ├── Project_README.md                     # 原始项目 README
│   └── bfcl_full_report.{txt,json}, bfcl_per_sample.json
│
├── custom_data/               # 自定义数据集（非公开）
│   ├── final_agent_data_v3.json              # 训练用 instruction-output 对（含 search、code、math 域）
│   ├── final_agent_data_v3_rest.json         # 剩余 split
│   ├── mov_calib_indices_v1.json             # MOV 校准集索引
│   ├── mov_calib_subset_v1.json              # MOV 校准子集
│   └── mov_vectors_qwen2.5-1.5b_L18.npz      # Qwen2.5-1.5B L18 方向向量
│
└── requirements.txt           # Python 依赖
```

总大小约 **380 MB**。

---

## 二、核心方法（ASA）

### 2.1 方向向量

对每个域（domain）/类别（category）/步骤 bucket：
```
v_domain = mean(h_success) - mean(h_failure)   # 域内/类别内
v_global = mean(h_success_all) - mean(h_failure_all)   # 全局
```

最终注入向量（单轮/直播）：
```
v_inject = normalize(0.6 * v_domain + 0.4 * v_global)
```

多轮（v9）采用 hierarchical fallback：`(kind, category, bucket, layer) → (kind, *, *, layer)`。

### 2.2 注入机制

通过 PyTorch forward hook，在层 L20/L24/L28（权重 0.6/1.0/0.6）的最后一个 token 上：
```
h' = h + alpha * weight * v_inject
||delta|| 被 cap 在 norm_cap × ||h|| 之内（norm_cap=0.20）
```

### 2.3 触发条件

- **多轮 v9**：三个 probe（rescue_p, hurt_p, stop_p）联合判定，自适应 alpha + hurt/stop guards
- **单轮 v4 / 直播 v4**：仅在 format_invalid / empty 时触发，escalating retry α=[7,12,18]

---

## 三、关键实验结果

| 方法 | Multi-Turn | Single-Turn | Live |
|------|:---:|:---:|:---:|
| Baseline (no injection) | 32.5% | 89.0% | 74.3% |
| Probe&Prefill (τ=0.50) | 33.8% (+1.3pp) | 89.0% (+0.0pp) | 76.4% (+2.0pp) |
| Tool-identity steering | 29.4% (-3.1pp) | 90.5% (+1.5pp) | 73.6% (-0.7pp) |
| **ASA (ours)** | **38.8% (+6.2pp)** | **94.0% (+5.0pp)** | **77.0% (+2.7pp)** |

详细指标见 `reports/baseline_comparison_full_results.md`。

---

## 四、快速复现

```bash
# 1) 安装依赖
pip install -r requirements.txt

# 2) 多轮 ASA v9（用打包好的探针）
python code/bfcl_asa/run_state_cascade_asa_v9.py \
    --gpu 0 --max_per_cat 80 --test_per_cat 40

# 3) 单轮 ASA v4
python code/bfcl_asa/run_single_asa_v4.py --gpu 0

# 4) Live ASA v4
python code/bfcl_asa/run_live_asa_v4.py --gpu 0

# 5) 对照实验
python code/bfcl_asa/run_baseline_probe_prefill.py --gpu 0
python code/bfcl_asa/run_baseline_tool_identity.py --gpu 1
```

模型路径默认为 `/data/models/Qwen3-8B`，需自行配置。

依赖外部 BFCL 仓库：`/root/gorilla_bfcl/berkeley-function-call-leaderboard`（公开，从 GitHub 获取）。

---

## 五、引用

如使用本仓库的代码或数据，请引用 ASA-MoV 工作（论文 in preparation）。
