docs(data_process): 在 __init__ 补充模块职责速查与分层说明
This commit is contained in:
@@ -1,13 +1,43 @@
|
|||||||
"""数据处理模块。
|
"""数据处理模块:从原始文件接入到生成标准训练数据的全流程。
|
||||||
|
|
||||||
本模块已重构为多个子模块以提高可维护性:
|
整体分层
|
||||||
|
--------
|
||||||
|
- ``algorithms/`` 纯算法层(无副作用:不访问 DB / 文件系统 / 网络)。
|
||||||
|
解析、格式检测、质量评分、去重、数据集切分、结构化预处理。
|
||||||
|
API、后台任务与测试共同复用。
|
||||||
|
- ``store/`` 持久层(PostgreSQL)。按 Mixin 拆分:
|
||||||
|
tasks / source_files / preview / generation / results / datasets。
|
||||||
|
构造时不连库、不迁移;部署方须显式执行 002 迁移(见 schema_cli)。
|
||||||
|
- 其余顶层文件 围绕上述两层的“服务 / 适配器”模块,由 endpoints 编排。
|
||||||
|
|
||||||
- store/: 数据持久层,拆分自原 store.py (2869行 → 8个文件)
|
顶层模块速查
|
||||||
- algorithms/: 算法和解析器,拆分自原 algorithms.py (3330行 → 11个文件)
|
------------
|
||||||
|
constants.py 共享常量(MAX_QA_PAIRS_PER_ITEM、MODEL_GENERATION_BATCH_SIZE)。
|
||||||
|
storage.py 原始源文件的本地对象存储(受控暂存于 storage/data-process)。
|
||||||
|
office_preview.py Word/Excel 原文件的安全受限预览(仅返回绘制所需的结构化数据)。
|
||||||
|
document_chunking.py 基于 Docling / LlamaIndex 的文档切分。
|
||||||
|
dataset_format.py Alpaca/ShareGPT/DPO/CPT 数据集格式校验(训练提交前预检)。
|
||||||
|
generation.py 大模型生成适配器,把预览内容转为标准 instruction/output 记录。
|
||||||
|
schema_cli.py data_process 运行表的显式检查 / 安装命令(运维工具,应用启动不自动调用)。
|
||||||
|
|
||||||
|
调用关系
|
||||||
|
--------
|
||||||
|
``app/api/v1/endpoints/data_process.py`` 是编排入口,组合调用以上模块与两个子包;
|
||||||
|
``dataset_format.py`` 另被 ``db/platform_store.py`` 用于训练预检。
|
||||||
|
|
||||||
|
典型链路
|
||||||
|
--------
|
||||||
|
上传源文件 → storage 暂存 → algorithms.parse_text_content 解析
|
||||||
|
→ office_preview / document_chunking 处理 → store 落库预览
|
||||||
|
→ generation 调模型生成 → store 写 results → dataset_format 校验后发布。
|
||||||
|
|
||||||
|
导入约定
|
||||||
|
--------
|
||||||
|
为避免循环导入,本 ``__init__`` 不统一再导出;请按需从子模块直接导入:
|
||||||
|
|
||||||
使用方式:
|
|
||||||
from app.modules.data_process.store import DataProcessStore
|
from app.modules.data_process.store import DataProcessStore
|
||||||
from app.modules.data_process.algorithms import estimate_token_count
|
from app.modules.data_process.algorithms import estimate_token_count
|
||||||
|
from app.modules.data_process.generation import generate_model_records
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# 注意:为了避免循环导入,不在此处导入所有内容
|
# 注意:为了避免循环导入,不在此处导入所有内容
|
||||||
|
|||||||
Reference in New Issue
Block a user