Fast, accurate OCR with correctness assessment.
docs: add KIE fine-tuning data format to LlamaFactory and ms-swift tutorials
huangfw36ed33cdb26f
diff --git a/docs/llamafactory_minicpm_ocr_french.md b/docs/llamafactory_minicpm_ocr_french.mdindex 8a26a52..8cbb315 100644--- a/docs/llamafactory_minicpm_ocr_french.md+++ b/docs/llamafactory_minicpm_ocr_french.md@@ -284,3 +284,38 @@ Text Recognition:# Fine-tuned modelde mon domicile du 3 Rue Gambetta, 57000 METZ, en date du 28 février```++## 扩展:关键信息提取(KIE)微调++以上训练配置同样适用于 KIE 场景,只需替换训练数据。KIE 任务的 JSONL 格式与文本识别格式相同,区别仅在 prompt 和 assistant 输出:++**数据格式示例**++```json+{+ "messages": [+ {+ "role": "user",+ "content": "<image>\nExtract the \"店名\", \"金额\". Format the output as a JSON object with keys: \"店名\", \"金额\". If an item is not in the image, use \"###\"."+ },+ {+ "role": "assistant",+ "content": "{\"店名\": \"某超市\", \"金额\": \"32.50\"}"+ }+ ],+ "images": [+ "/path/to/receipt.jpg"+ ]+}+```++prompt 固定格式为:++```+Extract the "字段1", "字段2". Format the output as a JSON object with keys: "字段1", "字段2". If an item is not in the image, use "###".+```++- 两处字段列表必须完全一致,字段名用英文双引号包裹。+- 图片中不存在的字段,assistant 输出 `"###"` 作为占位值。+- 训练配置与文本识别任务完全相同,无需修改任何训练参数。+- 评测建议使用字段级 exact match 或 F1,而非 CER/WER。diff --git a/docs/llamafactory_minicpm_ocr_french_en.md b/docs/llamafactory_minicpm_ocr_french_en.mdindex 1491576..ae9395c 100644--- a/docs/llamafactory_minicpm_ocr_french_en.md+++ b/docs/llamafactory_minicpm_ocr_french_en.md@@ -270,3 +270,38 @@ Text Recognition:# Fine-tuned modelde mon domicile du 3 Rue Gambetta, 57000 METZ, en date du 28 février```++## Extension: Fine-tuning for Key Information Extraction (KIE)++The same training configuration works for KIE tasks. The only change is the training data. The JSONL format is identical to the text-recognition format; only the prompt and assistant output differ:++**Data format reference**++```json+{+ "messages": [+ {+ "role": "user",+ "content": "<image>\nExtract the \"store_name\", \"amount\". Format the output as a JSON object with keys: \"store_name\", \"amount\". If an item is not in the image, use \"###\"."+ },+ {+ "role": "assistant",+ "content": "{\"store_name\": \"SuperMart\", \"amount\": \"32.50\"}"+ }+ ],+ "images": [+ "/path/to/receipt.jpg"+ ]+}+```++The prompt template is:++```+Extract the "field1", "field2". Format the output as a JSON object with keys: "field1", "field2". If an item is not in the image, use "###".+```++- Both field lists must be identical; each field name is wrapped in English double quotes.+- Missing fields are represented by `"###"` in the assistant output.+- All training parameters remain unchanged.+- Evaluate with field-level exact match or F1 rather than CER/WER.diff --git a/docs/swift_minicpm_ocr_french.md b/docs/swift_minicpm_ocr_french.mdindex 61de4b3..852bd09 100644--- a/docs/swift_minicpm_ocr_french.md+++ b/docs/swift_minicpm_ocr_french.md@@ -237,3 +237,38 @@ Text Recognition:# Fine-tuned modelde mon domicile du 3 Rue Gambetta, 57000 METZ, en date du 28 février```++## 扩展:关键信息提取(KIE)微调++以上训练配置同样适用于 KIE 场景,只需替换训练数据。ms-swift 模板会在图像占位符后补换行,因此 JSONL 中使用 `<image>` 紧跟 prompt,不加 `\n`:++**数据格式示例**++```json+{+ "messages": [+ {+ "role": "user",+ "content": "<image>Extract the \"店名\", \"金额\". Format the output as a JSON object with keys: \"店名\", \"金额\". If an item is not in the image, use \"###\"."+ },+ {+ "role": "assistant",+ "content": "{\"店名\": \"某超市\", \"金额\": \"32.50\"}"+ }+ ],+ "images": [+ "/path/to/receipt.jpg"+ ]+}+```++prompt 固定格式为:++```+Extract the "字段1", "字段2". Format the output as a JSON object with keys: "字段1", "字段2". If an item is not in the image, use "###".+```++- 两处字段列表必须完全一致,字段名用英文双引号包裹。+- 图片中不存在的字段,assistant 输出 `"###"` 作为占位值。+- 训练配置与文本识别任务完全相同,无需修改任何训练参数。+- 评测建议使用字段级 exact match 或 F1,而非 CER/WER。diff --git a/docs/swift_minicpm_ocr_french_en.md b/docs/swift_minicpm_ocr_french_en.mdindex b330214..34a7686 100644--- a/docs/swift_minicpm_ocr_french_en.md+++ b/docs/swift_minicpm_ocr_french_en.md@@ -237,3 +237,38 @@ Text Recognition:# Fine-tuned modelde mon domicile du 3 Rue Gambetta, 57000 METZ, en date du 28 février```++## Extension: Fine-tuning for Key Information Extraction (KIE)++The same training configuration works for KIE tasks. The only change is the training data. The ms-swift template inserts a newline after the image placeholder automatically, so the JSONL uses `<image>` immediately followed by the prompt, without `\n`:++**Data format reference**++```json+{+ "messages": [+ {+ "role": "user",+ "content": "<image>Extract the \"store_name\", \"amount\". Format the output as a JSON object with keys: \"store_name\", \"amount\". If an item is not in the image, use \"###\"."+ },+ {+ "role": "assistant",+ "content": "{\"store_name\": \"SuperMart\", \"amount\": \"32.50\"}"+ }+ ],+ "images": [+ "/path/to/receipt.jpg"+ ]+}+```++The prompt template is:++```+Extract the "field1", "field2". Format the output as a JSON object with keys: "field1", "field2". If an item is not in the image, use "###".+```++- Both field lists must be identical; each field name is wrapped in English double quotes.+- Missing fields are represented by `"###"` in the assistant output.+- All training parameters remain unchanged.+- Evaluate with field-level exact match or F1 rather than CER/WER.