Skip to content

Commit eadcf9d

Browse files
authored
Merge pull request #321 from Kylie-dot-s/fix/docs-only
Fix/docs only
2 parents 666246c + 984a17b commit eadcf9d

19 files changed

+713
-537
lines changed

docs/config.md

Lines changed: 182 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,11 @@
3131
| Parameter | Type | Default | Required | Description |
3232
|-----------|------|---------|----------|-------------|
3333
| source | str | "hugging_face" | Yes | 数据源类型,可选值:['hugging_face', 'local'] |
34-
| format | str | "json" | Yes | 数据格式,可选值:['json', 'jsonl', 'plaintext', 'listjson'] |
35-
| field | object | - | Yes | 字段映射配置 |
34+
| format | str | "json" | Yes | 数据格式,可选值:['json', 'jsonl', 'plaintext', 'listjson', 'image', 'multi_turn_dialog'] |
3635
| hf_config | object | - | No | HuggingFace 特定配置 |
37-
38-
#### DatasetField 配置 (dataset.field)
39-
40-
字段映射配置:
41-
42-
| Parameter | Type | Default | Required | Description |
43-
|-----------|------|---------|----------|-------------|
44-
| id | str | "" | Depends | ID 字段名,多级用 '.' 分隔 |
45-
| prompt | str | "" | Depends | prompt 字段名,多级用 '.' 分隔 |
46-
| content | str | "" | Yes | 内容字段名,多级用 '.' 分隔 |
47-
| context | str | "" | Depends | 上下文字段名,多级用 '.' 分隔 |
48-
| image | str | "" | Depends | 图像字段名,多级用 '.' 分隔 |
36+
| s3_config | object | - | No | S3 存储配置 |
37+
| sql_config | object | - | No | SQL 数据库配置 |
38+
| excel_config | object | - | No | Excel 文件配置 |
4939

5040
#### DatasetHFConfig 配置 (dataset.hf_config)
5141

@@ -62,9 +52,6 @@ HuggingFace 特定配置:
6252

6353
| Parameter | Type | Default | Required | Description |
6454
|-----------|------|---------|----------|-------------|
65-
| eval_group | str | "" | Yes | 评估模型组 |
66-
| rule_list | list | [] | Depends | 规则函数列表 |
67-
| prompt_list | list | [] | Depends | prompt 列表 |
6855
| start_index | int | 0 | No | 开始检查的数据索引 |
6956
| end_index | int | -1 | No | 结束检查的数据索引 |
7057
| max_workers | int | 1 | No | 最大并发工作线程数 |
@@ -78,41 +65,71 @@ HuggingFace 特定配置:
7865

7966
| Parameter | Type | Default | Required | Description |
8067
|------------|------|---------|----------|-------------|
81-
| bad | bool | false | No | 是否保存错误结果 |
68+
| bad | bool | true | No | 是否保存错误结果 |
8269
| good | bool | false | No | 是否保存正确结果 |
8370
| all_labels | bool | false | No | 是否保存所有标签 |
8471
| raw | bool | false | No | 是否保存原始数据 |
8572

8673
### Evaluator 配置 (evaluator)
8774

88-
评估器相关配置:
75+
评估器配置采用数组形式,支持多个评估管道(EvalPipline):
76+
77+
| Parameter | Type | Default | Required | Description |
78+
|-----------|------|---------|----------|-------------|
79+
| evaluator | array | [] | Yes | 评估管道数组 |
80+
81+
#### EvalPipline 配置 (evaluator[])
82+
83+
每个评估管道包含字段映射和评估器列表:
8984

9085
| Parameter | Type | Default | Required | Description |
9186
|-----------|------|---------|----------|-------------|
92-
| rule_config | object | {} | Depends | 规则配置 |
93-
| llm_config | object | {} | Depends | LLM 配置 |
87+
| fields | object | {} | Yes | 字段映射配置,将数据字段映射到评估器需要的字段 |
88+
| evals | array | [] | Yes | 评估器列表 |
89+
90+
**fields 字段映射说明**
91+
92+
| 映射字段 | Description |
93+
|----------|-------------|
94+
| id | 数据 ID 字段名 |
95+
| prompt | prompt/问题字段名 |
96+
| content | 内容字段名(必需) |
97+
| context | 上下文字段名 |
98+
| image | 图像字段名 |
99+
| reference | 参考答案字段名 |
94100

95-
#### EvaluatorRuleArgs 配置 (evaluator.rule_config.[rule_name])
101+
#### EvalPiplineConfig 配置 (evaluator[].evals[])
96102

97-
规则配置:
103+
单个评估器配置:
104+
105+
| Parameter | Type | Default | Required | Description |
106+
|-----------|------|---------|----------|-------------|
107+
| name | str | - | Yes | 评估器名称(Rule 或 LLM 类名) |
108+
| config | object | null | No | 评估器配置参数 |
109+
110+
#### Rule 评估器配置 (config)
111+
112+
规则类评估器的配置参数:
98113

99114
| Parameter | Type | Default | Required | Description |
100115
|-----------|------|---------|----------|-------------|
101116
| threshold | float | null | No | 规则决策阈值 |
102117
| pattern | str | null | No | 匹配模式字符串 |
103118
| key_list | list | null | No | 匹配关键词列表 |
104-
| refer_path | list | null | No | 参考文件路径或小模型路径 |
119+
| refer_path | list | null | No | 参考文件路径或模型路径 |
120+
| parameters | object | null | No | 其他自定义参数 |
105121

106-
#### EvaluatorLLMArgs 配置 (evaluator.llm_config.[llm_name])
122+
#### LLM 评估器配置 (config)
107123

108-
LLM 配置
124+
LLM 类评估器的配置参数
109125

110126
| Parameter | Type | Default | Required | Description |
111127
|-----------|------|---------|----------|-------------|
112128
| model | str | null | No | 使用的模型名称 |
113-
| key | str | null | No | API 密钥 |
114-
| api_url | str | null | No | API URL |
129+
| key | str | null | Yes | API 密钥 |
130+
| api_url | str | null | Yes | API URL |
115131
| parameters | object | null | No | LLM 调参配置 |
132+
| embedding_config | object | null | No | Embedding 模型配置 |
116133

117134
##### LLM Parameters 配置
118135

@@ -128,70 +145,138 @@ LLM 调参配置:
128145

129146
## 配置文件示例
130147

148+
### 基础示例(仅使用规则评估器)
149+
131150
```json
132151
{
133152
"task_name": "dingo",
134-
"input_path": "test/data/test_local_json.json",
153+
"input_path": "test/data/test_local_jsonl.jsonl",
135154
"output_path": "outputs/",
136155
"log_level": "WARNING",
137156
"use_browser": false,
138157

139158
"dataset": {
140-
"source": "hugging_face",
141-
"format": "json",
142-
"field": {
143-
"id": "",
144-
"prompt": "",
145-
"content": "",
146-
"context": "",
147-
"image": ""
148-
},
149-
"hf_config": {
150-
"huggingface_split": "",
151-
"huggingface_config_name": null
152-
}
159+
"source": "local",
160+
"format": "jsonl"
153161
},
154162

155163
"executor": {
156-
"eval_group": "",
157-
"rule_list": [],
158-
"prompt_list": [],
159164
"start_index": 0,
160165
"end_index": -1,
161166
"max_workers": 1,
162167
"batch_size": 1,
163-
"multi_turn_mode": null,
164168
"result_save": {
165-
"bad": false,
166-
"good": false,
167-
"raw": false
169+
"bad": true,
170+
"good": false
168171
}
169172
},
170173

171-
"evaluator": {
172-
"rule_config": {
173-
"rule_name": {
174-
"threshold": 0.5,
175-
"pattern": ".*",
176-
"key_list": ["key1", "key2"],
177-
"refer_path": ["path/to/reference"]
178-
}
179-
},
180-
"llm_config": {
181-
"openai": {
182-
"model": "gpt-3.5-turbo",
183-
"key": "your-api-key",
184-
"api_url": "https://api.openai.com/v1/chat/completions",
185-
"parameters": {
186-
"temperature": 1,
187-
"top_p": 1,
188-
"max_tokens": 4000,
189-
"presence_penalty": 0,
190-
"frequency_penalty": 0
191-
}
192-
}
174+
"evaluator": [
175+
{
176+
"fields": {"content": "content"},
177+
"evals": [
178+
{"name": "RuleColonEnd"},
179+
{"name": "RuleAbnormalChar"}
180+
]
193181
}
194-
}
182+
]
183+
}
184+
```
185+
186+
### 使用 LLM 评估器
187+
188+
```json
189+
{
190+
"task_name": "llm_evaluation",
191+
"input_path": "test/data/test_local_jsonl.jsonl",
192+
"output_path": "outputs/",
193+
194+
"dataset": {
195+
"source": "local",
196+
"format": "jsonl"
197+
},
198+
199+
"executor": {
200+
"result_save": {
201+
"bad": true,
202+
"good": true
203+
}
204+
},
205+
206+
"evaluator": [
207+
{
208+
"fields": {"content": "content"},
209+
"evals": [
210+
{"name": "LLMTextQualityV4", "config": {
211+
"model": "deepseek-chat",
212+
"key": "your-api-key",
213+
"api_url": "https://api.deepseek.com/v1"
214+
}}
215+
]
216+
}
217+
]
218+
}
219+
```
220+
221+
### 混合使用规则和 LLM 评估器
222+
223+
```json
224+
{
225+
"task_name": "mixed_evaluation",
226+
"input_path": "test/data/test_local_jsonl.jsonl",
227+
228+
"dataset": {
229+
"source": "local",
230+
"format": "jsonl"
231+
},
232+
233+
"executor": {
234+
"max_workers": 4,
235+
"batch_size": 10,
236+
"result_save": {
237+
"bad": true,
238+
"good": true
239+
}
240+
},
241+
242+
"evaluator": [
243+
{
244+
"fields": {"content": "content"},
245+
"evals": [
246+
{"name": "RuleColonEnd"},
247+
{"name": "RuleAbnormalChar"},
248+
{"name": "LLMTextQualityV4", "config": {
249+
"model": "deepseek-chat",
250+
"key": "your-api-key",
251+
"api_url": "https://api.deepseek.com/v1"
252+
}}
253+
]
254+
}
255+
]
256+
}
257+
```
258+
259+
### 多字段评估示例
260+
261+
```json
262+
{
263+
"task_name": "multi_field_evaluation",
264+
"input_path": "path/to/your/data.jsonl",
265+
"dataset": {
266+
"source": "local",
267+
"format": "jsonl"
268+
},
269+
"evaluator": [
270+
{
271+
"fields": {"prompt": "question", "content": "answer", "context": "context"},
272+
"evals": [
273+
{"name": "LLMHallucination", "config": {
274+
"key": "your-api-key",
275+
"api_url": "https://api.openai.com/v1"
276+
}}
277+
]
278+
}
279+
]
195280
}
196281
```
197282

@@ -204,20 +289,34 @@ dingo --input config.json
204289

205290
### SDK 方式
206291
```python
207-
from dingo import InputArgs, run
208-
209-
# 从文件加载配置
210-
config = InputArgs.parse_file("config.json")
211-
run(config)
292+
from dingo.config import InputArgs
293+
from dingo.exec import Executor
212294

213-
# 或从字典创建配置
214-
config_dict = {
295+
# 从字典创建配置
296+
input_data = {
215297
"task_name": "my_task",
216-
"input_path": "data.json",
217-
# ... 其他配置
298+
"input_path": "data.jsonl",
299+
"dataset": {
300+
"source": "local",
301+
"format": "jsonl"
302+
},
303+
"executor": {
304+
"result_save": {"bad": True, "good": True}
305+
},
306+
"evaluator": [
307+
{
308+
"fields": {"content": "content"},
309+
"evals": [
310+
{"name": "RuleColonEnd"}
311+
]
312+
}
313+
]
218314
}
219-
config = InputArgs(**config_dict)
220-
run(config)
315+
316+
input_args = InputArgs(**input_data)
317+
executor = Executor.exec_map["local"](input_args)
318+
result = executor.execute()
319+
print(result)
221320
```
222321

223322
## 多轮对话模式

0 commit comments

Comments
 (0)