Files
YG_FT/backend/app/modules/data_process/__init__.py

47 lines
2.4 KiB
Python
Raw Normal View History

"""数据处理模块:从原始文件接入到生成标准训练数据的全流程。
整体分层
--------
- ``algorithms/`` 纯算法层无副作用不访问 DB / 文件系统 / 网络
解析格式检测质量评分去重数据集切分结构化预处理
API后台任务与测试共同复用
- ``store/`` 持久层PostgreSQL Mixin 拆分
tasks / source_files / preview / generation / results / datasets
构造时不连库不迁移部署方须显式执行 002 迁移 schema_cli
- 其余顶层文件 围绕上述两层的服务 / 适配器模块 endpoints 编排
顶层模块速查
------------
constants.py 共享常量MAX_QA_PAIRS_PER_ITEMMODEL_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.algorithms import estimate_token_count
from app.modules.data_process.generation import generate_model_records
"""
# 注意:为了避免循环导入,不在此处导入所有内容
# 请直接从子模块导入所需功能
__all__ = ["store", "algorithms"]