Skip to content

Commit 8bf0093

Browse files
authored
Merge pull request #296 from Kylie-dot-s/fix/docs-and-examples-cleanup
Fix/docs and examples cleanup
2 parents 3a078c3 + 97a6613 commit 8bf0093

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+548
-323
lines changed

dingo/model/llm/hhh/llm_text_3h.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LLMText3H(BaseOpenAI):
1313
def build_messages(cls, input_data):
1414
question = input_data.prompt
1515
response = input_data.content
16-
prompt_content = cls.prompt.content % (question, response)
16+
prompt_content = cls.prompt % (question, response)
1717

1818
messages = [{"role": "user", "content": prompt_content}]
1919

@@ -38,15 +38,21 @@ def process_response(cls, response: str) -> EvalDetail:
3838

3939
result = EvalDetail(metric=cls.__name__)
4040

41+
# Get the quality dimension name from class name
42+
# e.g., LLMText3HHelpful -> HELPFUL
43+
class_prefix = "LLMText3H"
44+
if cls.__name__.startswith(class_prefix):
45+
quality_name = cls.__name__[len(class_prefix):].upper()
46+
else:
47+
quality_name = cls.__name__.upper()
48+
4149
# eval_status
4250
if response_model.score == 1:
43-
tmp_name = cls.prompt.__name__[8:].upper()
44-
result.label = [f"{QualityLabel.QUALITY_GOOD}.{tmp_name}"]
51+
result.label = [f"{QualityLabel.QUALITY_GOOD}.{quality_name}"]
4552
result.reason = [response_model.reason] if response_model.reason else ["Response meets quality criteria"]
4653
else:
4754
result.status = True
48-
tmp_name = "NOT_" + cls.prompt.__name__[8:].upper()
49-
result.label = [f"QUALITY_BAD.{tmp_name}"]
55+
result.label = [f"QUALITY_BAD.NOT_{quality_name}"]
5056
result.reason = [response_model.reason] if response_model.reason else ["Response fails quality criteria"]
5157

5258
return result

docs/artimuse.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RuleImageArtimuse 基于 ArtiMuse 在线服务对输入图片进行美学质量
2424

2525
## 核心方法
2626

27-
### `eval(cls, input_data: Data) -> ModelRes`
27+
### `eval(cls, input_data: Data) -> EvalDetail`
2828

2929
这是规则的主要评估方法,接收包含图像 URL 的 `Data` 对象,返回评估结果。
3030

@@ -50,20 +50,19 @@ RuleImageArtimuse 基于 ArtiMuse 在线服务对输入图片进行美学质量
5050

5151
#### 返回值
5252

53-
返回 `ModelRes` 对象,包含以下属性:
53+
返回 `EvalDetail` 对象,包含以下属性:
5454

55-
- `eval_status`: 布尔值,表示图像质量是否不合格(低于阈值
56-
- `type`: 评估结果类型("Artimuse_Succeeded" 或 "Artimuse_Fail")
57-
- `name`: 评估结果名称("BadImage" 或 "GoodImage" 或 "Exception"
55+
- `metric`: 指标名称("RuleImageArtimuse"
56+
- `status`: 布尔值,表示图像质量是否不合格(低于阈值)(True=不合格, False=合格)
57+
- `label`: 质量标签列表(如 ["Artimuse_Succeeded.BadImage"]["QUALITY_GOOD"]
5858
- `reason`: 包含详细评估信息或异常信息的数组(字符串化 JSON)
5959

6060
## 异常处理
6161

62-
当评估过程中发生异常时,返回的 `ModelRes` 对象将包含:
62+
当评估过程中发生异常时,返回的 `EvalDetail` 对象将包含:
6363

64-
- `eval_status`: `False`
65-
- `type`: `"Artimuse_Fail"`
66-
- `name`: `"Exception"`
64+
- `status`: `False`
65+
- `label`: `["Artimuse_Fail.Exception"]`
6766
- `reason`: 包含异常信息的数组
6867

6968
## 使用示例

docs/ats_resume_guide.md

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ ATS 工具套件用于:
1616

1717
分析简历与 JD 的匹配度,输出加权匹配分数和详细分析报告。
1818

19+
**核心功能:**
20+
- 语义匹配(不仅是字符串匹配)
21+
- 同义词自动识别(如 k8s → Kubernetes)
22+
- 负向约束识别(Excluded 技能警告)
23+
- 基于证据的匹配(引用简历原文)
24+
1925
**输入字段:**
2026
| 字段 | 类型 | 必需 | 说明 |
2127
|------|------|------|------|
@@ -26,8 +32,17 @@ ATS 工具套件用于:
2632
| 字段 | 类型 | 说明 |
2733
|------|------|------|
2834
| `score` | float | 匹配分数 (0.0-1.0) |
29-
| `error_status` | bool | 是否低于阈值 (默认 0.6) |
30-
| `reason` | List[str] | 详细分析报告 |
35+
| `status` | bool | 是否低于阈值 (True=低于,False=通过) |
36+
| `reason` | List[str] | 详细分析报告(文本格式) |
37+
38+
**内置同义词映射 (SYNONYM_MAP):**
39+
```
40+
k8s → Kubernetes, js → JavaScript, ts → TypeScript
41+
py → Python, tf → TensorFlow, pt → PyTorch
42+
nodejs → Node.js, postgres → PostgreSQL
43+
aws → Amazon Web Services, gcp → Google Cloud Platform
44+
ml → Machine Learning, dl → Deep Learning, nlp → NLP
45+
```
3146

3247
### 2. LLMResumeOptimizer(简历优化器)
3348

@@ -80,6 +95,8 @@ jd = """
8095
match_data = Data(data_id='test_1', content=resume, prompt=jd)
8196
match_result = LLMKeywordMatcher.eval(match_data)
8297
print(f"匹配分数: {match_result.score}")
98+
print(f"是否通过: {'通过' if not match_result.status else '未通过'}")
99+
print(f"分析报告: {match_result.reason[0]}")
83100

84101
# Step 2: 简历优化
85102
optimize_data = Data(
@@ -89,18 +106,23 @@ optimize_data = Data(
89106
context='{"match_details": {"missing": [{"skill": "Docker", "importance": "Required"}]}}'
90107
)
91108
opt_result = LLMResumeOptimizer.eval(optimize_data)
92-
print(f"优化结果: {opt_result.reason[0]}")
109+
print(f"优化摘要: {opt_result.reason[0]}")
110+
print(f"完整结果: {opt_result.optimized_content}")
93111
```
94112

95113
## 📊 匹配分数计算
96114

97-
### 权重分配
115+
### 权重公式
116+
117+
```
118+
score = (Required_Matched × 2 + Nice_Matched × 1) / (Required_Total × 2 + Nice_Total × 1)
119+
```
98120

99121
| 类别 | 权重 | 说明 |
100122
|------|------|------|
101-
| Required (必需) | 0.7 | 缺失会显著降低分数 |
102-
| Nice-to-have (加分) | 0.3 | 缺失影响较小 |
103-
| Excluded (排除) | -0.1 | 存在会扣分 |
123+
| Required (必需) | ×2 | 缺失会显著降低分数 |
124+
| Nice-to-have (加分) | ×1 | 缺失影响较小 |
125+
| Excluded (排除) | 不计分 | 仅生成警告,不影响分数 |
104126

105127
### 阈值配置
106128

@@ -156,16 +178,31 @@ Nice-to-have (Missing): Kubernetes
156178

157179
### ResumeOptimizer 输出
158180

159-
结果同样存放在 `result.reason[0]` 中,JSON 格式:
181+
**`reason[0]`**: 人类可读的摘要文本
182+
**`optimized_content`**: 完整的 JSON 优化结果
160183

161184
```python
162185
# 访问方式
163186
result = LLMResumeOptimizer.eval(data)
164-
import json
165-
output = json.loads(result.reason[0])
187+
188+
# 摘要文本
189+
print(result.reason[0])
190+
191+
# 完整 JSON 结果
192+
opt = result.optimized_content
193+
print(opt.get('optimization_summary'))
194+
print(opt.get('section_changes'))
166195
```
167196

168197
**`reason[0]` 内容示例:**
198+
```
199+
Overall: 优化了专业技能板块
200+
Keywords Added: Docker
201+
Associative: Kubernetes (了解概念)
202+
Sections Modified: 专业技能
203+
```
204+
205+
**`optimized_content` 结构:**
169206
```json
170207
{
171208
"optimization_summary": {

docs/document_ocr.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ Dingo 提供了一种基于LLM的文档OCR解析质量评估工具,可帮助
2222
dingo/
2323
├── model/
2424
│ ├── llm/
25-
│ │ └── vlm_document_parsing.py # 评估器实现
26-
│ └── prompt/
27-
│ └── prompt_mineru_recognize.py # 评估提示词
25+
│ │ └── llm_document_parsing_ocr.py # 评估器实现(含内嵌Prompt)
2826
│── examples/
2927
│ └── document_parser/
3028
│ └── document_parsing_quality_ocr.py # 单条评估示例
@@ -75,11 +73,11 @@ input_data = {
7573
#### 输出结果格式
7674

7775
```python
78-
# result 是 ModelRes 对象,包含以下字段:
79-
result.type # 错误问题一级标签: prompt中定义的一级错误大类
80-
result.name # 错误问题二级标签: 一级错误大类对应的详细错误标签 List[str]
81-
result.eval_status # 错误状态: False 或 True
82-
result.reason # 评估原因: List[str]
76+
# result 是 EvalDetail 对象,包含以下字段:
77+
result.metric # 指标名称: "LLMMinerURecognizeQuality"
78+
result.label # 错误标签列表: ["error_category1.error_category2.error_label1.error_label2"]
79+
result.status # 错误状态: False (默认值)
80+
result.reason # 评估原因: List[str],包含完整的JSON分析结果
8381
```
8482

8583

docs/document_parsing_quality_guide.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# VLMDocumentParsingQuality 文档解析评估工具 使用文档
1+
# VLMDocumentParsing 文档解析评估工具 使用文档
22

33
Dingo 提供了一种基于VLM的文档解析质量评估与可视化工具,可帮助您:
44
- 评估文档解析模型输出质量
55
- 生成模型质量报告
66

77
## 工具介绍
88

9-
### VLMDocumentParsingQuality:文档解析评估工具
9+
### VLMDocumentParsing:文档解析评估工具
1010

1111
#### 功能说明
1212
该工具用于评估文档解析模型效果,具体功能包括:
@@ -22,9 +22,8 @@ Dingo 提供了一种基于VLM的文档解析质量评估与可视化工具,
2222
dingo/
2323
├── model/
2424
│ ├── llm/
25-
│ │ └── vlm_document_parsing.py # 评估器实现
26-
│ └── prompt/
27-
│ └── prompt_document_parsing.py # 评估提示词
25+
│ │ └── mineru/
26+
│ │ └── vlm_document_parsing.py # 评估器实现(含内嵌Prompt)
2827
│── examples/
2928
│ └── document_parser/
3029
│ └── vlm_document_parser_quality.py # 单条评估示例
@@ -64,7 +63,7 @@ input_data = {
6463
},
6564
"evaluator": {
6665
"llm_config": {
67-
"VLMDocumentParsingQuality": {
66+
"VLMDocumentParsing": {
6867
"key": "",
6968
"api_url": "",
7069
}
@@ -76,11 +75,11 @@ input_data = {
7675
#### 输出结果格式
7776

7877
```python
79-
# result 是 ModelRes 对象,包含以下字段:
80-
result.type # 错误问题一级标签: prompt中定义的一级错误大类
81-
result.name # 错误问题二级标签: 一级错误大类对应的详细错误标签 List[str]
82-
result.eval_status # 错误状态: False 或 True
83-
result.reason # 评估原因: List[str]
78+
# result 是 EvalDetail 对象,包含以下字段:
79+
result.metric # 指标名称: "VLMDocumentParsing"
80+
result.label # 错误标签列表: ["公式相关问题.行内公式漏检", "表格相关问题.单元格内容错误"]
81+
result.status # 错误状态: False (默认值,该类不设置)
82+
result.reason # 评估原因: List[str],包含完整的JSON分析结果
8483
```
8584

8685

@@ -114,7 +113,7 @@ if __name__ == '__main__':
114113
},
115114
"evaluator": {
116115
"llm_config": {
117-
"VLMDocumentParsingQuality": {
116+
"VLMDocumentParsing": {
118117
"key": "",
119118
"api_url": "",
120119
}

docs/factcheck_guide.md

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,10 @@ data = Data(
6464
# 执行评估
6565
result = LLMFactCheckPublic.eval(data)
6666

67-
# 查看结果
68-
print(f"Factual ratio: {result.score:.2%}")
69-
print(f"Reason: {result.reason}")
70-
print("\nDetailed results:")
71-
for claim in result.raw_resp["results"]:
72-
print(f"\nClaim: {claim.claim}")
73-
print(f"Answer: {claim.answer}")
74-
print(f"Reasoning: {claim.reasoning}")
67+
# 查看结果 (返回 EvalDetail 对象)
68+
print(f"是否通过: {'通过' if not result.status else '未通过'}")
69+
print(f"标签: {result.label}")
70+
print(f"详细原因: {result.reason[0]}")
7571
```
7672

7773
### 场景二:评估数据集
@@ -143,13 +139,10 @@ rag_data = {
143139
data = Data(**rag_data)
144140
result = LLMFactCheckPublic.eval(data)
145141

146-
# 分析结果
147-
print(f"Factual consistency: {result.score:.2%}")
148-
for claim in result.raw_resp["results"]:
149-
if claim.answer != "true":
150-
print(f"\nPotential hallucination:")
151-
print(f"Claim: {claim.claim}")
152-
print(f"Evidence: {claim.reasoning}")
142+
# 分析结果 (返回 EvalDetail 对象)
143+
print(f"是否通过: {'通过' if not result.status else '未通过'}")
144+
print(f"标签: {result.label}")
145+
print(f"详细原因: {result.reason[0]}")
153146
```
154147

155148
### 场景四:多轮对话监控
@@ -173,9 +166,10 @@ for turn in conversation:
173166
data = Data(**turn)
174167
result = LLMFactCheckPublic.eval(data)
175168
print(f"\nTurn {turn['data_id']}:")
176-
print(f"Factual ratio: {result.score:.2%}")
177-
if result.score < LLMFactCheckPublic.threshold:
169+
print(f"是否通过: {'通过' if not result.status else '未通过'}")
170+
if result.status:
178171
print("Warning: Potential misinformation detected!")
172+
print(f"详情: {result.reason[0]}")
179173
```
180174

181175
## 最佳实践
@@ -241,30 +235,16 @@ dingo/
241235
### 评估结果格式
242236

243237
```python
244-
ModelRes(
245-
score=0.85, # 事实性得分
246-
threshold=0.8, # 判断阈值
247-
reason=["Found 10 claims: 8 true, 1 false, 1 unsure..."],
248-
raw_resp={
249-
"claims": ["claim1", "claim2", ...],
250-
"results": [
251-
FactCheckResult(
252-
claim="...",
253-
answer="true",
254-
reasoning="...",
255-
supporting_evidence=[...]
256-
),
257-
...
258-
],
259-
"metrics": {
260-
"factual_ratio": 0.85,
261-
"true_count": 8,
262-
"false_count": 1,
263-
"unsure_count": 1,
264-
"total_claims": 10
265-
}
266-
}
238+
# LLMFactCheckPublic 返回 EvalDetail 对象
239+
EvalDetail(
240+
metric="LLMFactCheckPublic", # 指标名称
241+
status=False, # 是否未通过 (False=通过, True=未通过)
242+
label=["QUALITY_GOOD.FACTUALITY_CHECK_PASSED"], # 质量标签
243+
reason=["Found 10 claims: 8 true, 1 false, 1 unsure. Factual ratio: 80.00%"]
267244
)
245+
246+
# reason[0] 包含完整的评估摘要,格式示例:
247+
# "Found 10 claims: 8 true, 1 false, 1 unsure. Factual ratio: 80.00%"
268248
```
269249

270250
## 参考资料

0 commit comments

Comments
 (0)