> ## Documentation Index
> Fetch the complete documentation index at: https://ultrarag.openbmb.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Benchmark

## `get_data`

**签名**

```python theme={null}
@app.tool(output="benchmark->q_ls,gt_ls")
def get_data(benchmark: Dict[str, Any]) -> Dict[str, List[Any]]
```

**功能**

* 多格式加载：支持从本地加载 `.jsonl`、`.json` 或 `.parquet` 格式的评测数据集。
* 动态字段映射：利用 `key_map` 将原始数据中的不同列名（如 `question`, `answer`）统一映射为标准化输出键（通常为 `q_ls` 和 `gt_ls`）。
* 数据预处理：内置支持随机打乱（`shuffle`）与数量截断（`limit`）。
* Demo 里用来接收用户输入，将其视作一条数据（`q_ls`）。

**输出格式（JSON）**

```json theme={null}
{
  "q_ls": ["Question 1", "Question 2"],
  "gt_ls": [["Answer A1", "Answer A2"], ["Answer B"]]
}
```

***

## 参数配置

```yaml servers/benchmark/parameter.yaml icon="https://mintcdn.com/ultrarag/T7GffHzZitf6TThi/images/yaml.svg?fit=max&auto=format&n=T7GffHzZitf6TThi&q=85&s=69b41e79144bc908039c2ee3abbb1c3b" theme={null}
benchmark:
  name: nq
  path: data/sample_nq_10.jsonl
  key_map:
    q_ls: question
    gt_ls: golden_answers
  shuffle: false
  seed: 42
  limit: -1
```

参数说明：

| 参数        | 类型      | 说明                                    |                                            |
| --------- | ------- | ------------------------------------- | ------------------------------------------ |
| `name`    | str     | 评测集名称，仅用于日志与标识（示例：`nq`）               |                                            |
| `path`    | str     | 数据文件路径，支持 `.jsonl`、`.json`、`.parquet` |                                            |
| `key_map` | dict    | 字段映射表，将原始字段映射为工具输出键                   |                                            |
|           | `q_ls`  | str                                   | 映射为 问题列表 的原始字段名（如文件中的 question 列）          |
|           | `gt_ls` | str                                   | 映射为 标准答案列表 的原始字段名（如文件中的 golden\_answers 列） |
| `shuffle` | bool    | 是否打乱样本顺序（默认 `false`）                  |                                            |
| `seed`    | int     | 随机种子（`shuffle=true` 时生效）              |                                            |
| `limit`   | int     | 采样数据条数上限。默认为 -1（加载全部），正整数表示截取前 N 条    |                                            |
