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', 'image', 'multi_turn_dialog'] |
34+ | format | str | "json" | Yes | 数据格式,可选值:[ 'json', 'jsonl', 'plaintext', 'listjson'] |
35+ | field | object | - | Yes | 字段映射配置 |
3536| hf_config | object | - | No | HuggingFace 特定配置 |
36- | s3_config | object | - | No | S3 存储配置 |
37- | sql_config | object | - | No | SQL 数据库配置 |
38- | excel_config | object | - | No | Excel 文件配置 |
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 | 图像字段名,多级用 '.' 分隔 |
3949
4050#### DatasetHFConfig 配置 (dataset.hf_config)
4151
@@ -52,6 +62,9 @@ HuggingFace 特定配置:
5262
5363| Parameter | Type | Default | Required | Description |
5464| -----------| ------| ---------| ----------| -------------|
65+ | eval_group | str | "" | Yes | 评估模型组 |
66+ | rule_list | list | [ ] | Depends | 规则函数列表 |
67+ | prompt_list | list | [ ] | Depends | prompt 列表 |
5568| start_index | int | 0 | No | 开始检查的数据索引 |
5669| end_index | int | -1 | No | 结束检查的数据索引 |
5770| max_workers | int | 1 | No | 最大并发工作线程数 |
@@ -65,71 +78,41 @@ HuggingFace 特定配置:
6578
6679| Parameter | Type | Default | Required | Description |
6780| ------------| ------| ---------| ----------| -------------|
68- | bad | bool | true | No | 是否保存错误结果 |
81+ | bad | bool | false | No | 是否保存错误结果 |
6982| good | bool | false | No | 是否保存正确结果 |
7083| all_labels | bool | false | No | 是否保存所有标签 |
7184| raw | bool | false | No | 是否保存原始数据 |
7285
7386### Evaluator 配置 (evaluator)
7487
75- 评估器配置采用数组形式,支持多个评估管道(EvalPipline):
76-
77- | Parameter | Type | Default | Required | Description |
78- | -----------| ------| ---------| ----------| -------------|
79- | evaluator | array | [ ] | Yes | 评估管道数组 |
80-
81- #### EvalPipline 配置 (evaluator[ ] )
82-
83- 每个评估管道包含字段映射和评估器列表:
88+ 评估器相关配置:
8489
8590| Parameter | Type | Default | Required | Description |
8691| -----------| ------| ---------| ----------| -------------|
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 | 参考答案字段名 |
92+ | rule_config | object | {} | Depends | 规则配置 |
93+ | llm_config | object | {} | Depends | LLM 配置 |
10094
101- #### EvalPiplineConfig 配置 (evaluator[ ] .evals [ ] )
95+ #### EvaluatorRuleArgs 配置 (evaluator.rule_config. [ rule_name ] )
10296
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- 规则类评估器的配置参数:
97+ 规则配置:
11398
11499| Parameter | Type | Default | Required | Description |
115100| -----------| ------| ---------| ----------| -------------|
116101| threshold | float | null | No | 规则决策阈值 |
117102| pattern | str | null | No | 匹配模式字符串 |
118103| key_list | list | null | No | 匹配关键词列表 |
119- | refer_path | list | null | No | 参考文件路径或模型路径 |
120- | parameters | object | null | No | 其他自定义参数 |
104+ | refer_path | list | null | No | 参考文件路径或小模型路径 |
121105
122- #### LLM 评估器配置 (config )
106+ #### EvaluatorLLMArgs 配置 (evaluator.llm_config. [ llm_name ] )
123107
124- LLM 类评估器的配置参数 :
108+ LLM 配置 :
125109
126110| Parameter | Type | Default | Required | Description |
127111| -----------| ------| ---------| ----------| -------------|
128112| model | str | null | No | 使用的模型名称 |
129- | key | str | null | Yes | API 密钥 |
130- | api_url | str | null | Yes | API URL |
113+ | key | str | null | No | API 密钥 |
114+ | api_url | str | null | No | API URL |
131115| parameters | object | null | No | LLM 调参配置 |
132- | embedding_config | object | null | No | Embedding 模型配置 |
133116
134117##### LLM Parameters 配置
135118
@@ -145,138 +128,70 @@ LLM 调参配置:
145128
146129## 配置文件示例
147130
148- ### 基础示例(仅使用规则评估器)
149-
150131``` json
151132{
152133 "task_name" : " dingo" ,
153- "input_path" : " test/data/test_local_jsonl.jsonl " ,
134+ "input_path" : " test/data/test_local_json.json " ,
154135 "output_path" : " outputs/" ,
155136 "log_level" : " WARNING" ,
156137 "use_browser" : false ,
157138
158139 "dataset" : {
159- "source" : " local" ,
160- "format" : " jsonl"
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+ }
161153 },
162154
163155 "executor" : {
156+ "eval_group" : " " ,
157+ "rule_list" : [],
158+ "prompt_list" : [],
164159 "start_index" : 0 ,
165160 "end_index" : -1 ,
166161 "max_workers" : 1 ,
167162 "batch_size" : 1 ,
163+ "multi_turn_mode" : null ,
168164 "result_save" : {
169- "bad" : true ,
170- "good" : false
165+ "bad" : false ,
166+ "good" : false ,
167+ "raw" : false
171168 }
172169 },
173170
174- "evaluator" : [
175- {
176- "fields" : {"content" : " content" },
177- "evals" : [
178- {"name" : " RuleColonEnd" },
179- {"name" : " RuleAbnormalChar" }
180- ]
181- }
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- ]
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+ }
278193 }
279- ]
194+ }
280195}
281196```
282197
@@ -289,34 +204,20 @@ dingo --input config.json
289204
290205### SDK 方式
291206``` python
292- from dingo.config import InputArgs
293- from dingo.exec import Executor
207+ from dingo import InputArgs, run
208+
209+ # 从文件加载配置
210+ config = InputArgs.parse_file(" config.json" )
211+ run(config)
294212
295- # 从字典创建配置
296- input_data = {
213+ # 或从字典创建配置
214+ config_dict = {
297215 " task_name" : " my_task" ,
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- ]
216+ " input_path" : " data.json" ,
217+ # ... 其他配置
314218}
315-
316- input_args = InputArgs(** input_data)
317- executor = Executor.exec_map[" local" ](input_args)
318- result = executor.execute()
319- print (result)
219+ config = InputArgs(** config_dict)
220+ run(config)
320221```
321222
322223## 多轮对话模式
0 commit comments