docs(paper): 添加系统架构图并更新实现章节

在实现章节中移除了冗余的子章节,并引入系统架构图以更清晰地展示三层架构设计。同时,在main.tex中添加了tikz库以支持架构图的绘制。
This commit is contained in:
carry 2025-04-29 17:43:26 +08:00
parent c273bb3399
commit 7d6444c6c8
3 changed files with 60 additions and 9 deletions

View File

@ -3,7 +3,6 @@
\section{关键技术实现}
\subsection{系统架构设计}
\subsubsection{整体架构设计}
本系统采用经典的三层架构设计,分为表现层、业务逻辑层和数据访问层。
在表现层中基于Gradio框架构建了一个用户友好的Web界面包含7个功能模块模型管理、模型推理、模型微调、数据集生成、数据集管理、提示词模板管理和系统设置。该界面采用响应式设计支持流式输出和灵活的参数配置以满足不同用户的交互需求。
@ -12,16 +11,9 @@
数据访问层主要负责数据的存储与管理。系统使用SQLite存储系统配置同时采用TinyDB内存数据库管理数据集支持JSON格式的数据导入和导出。通过这种分层设计各层之间明确分工不仅提升了系统的可扩展性和可维护性还为后续的功能扩展奠定了基础。
\subsubsection{模块划分与交互流程}
系统根据功能需求划分为多个模块,各模块之间通过清晰的交互流程协同工作,确保系统的高效运行。
\input{figures/system_architecture.tex}
模型管理模块 是系统的核心之一负责加载、卸载和配置大语言模型。用户可以通过该模块选择并管理不同的模型而模型推理模块则负责处理用户输入并生成模型响应。此外模型训练模块支持执行LoRA微调训练流程帮助用户优化模型性能。
数据集生成模块 的设计重点在于灵活性和效率。它支持多种文档格式输入优先支持Markdown提供可视化模板编辑和变量配置功能同时支持多轮次并发生成。为了保证生成结果的可靠性模块还内置了自动验证和转换机制。在技术实现上使用LangChain PromptTemplate处理模板采用异步调用提高生成效率并通过原子操作保证数据一致性。此外模块还提供了进度反馈和错误处理机制进一步提升用户体验。
数据管理模块 涵盖了数据集生成、存储以及提示词模板管理等功能。数据集生成功能用于创建和预处理训练数据数据集存储则通过TinyDB实现内存数据库管理确保数据的高效存取。提示词模板管理模块负责维护对话模板和系统提示为模型推理提供必要的上下文支持。
系统交互流程 从用户发起请求开始用户通过Gradio界面与系统交互。前端模块接收用户请求后调用对应的业务逻辑模块进行处理。业务逻辑模块根据需要访问数据存储层获取或保存数据并将处理结果返回给前端展示。整个流程清晰且高效确保用户能够快速获得所需的结果。
\subsection{数据库设计与实现}

View File

@ -0,0 +1,56 @@
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=1.5cm, auto,
block/.style={rectangle, draw, fill=white, text width=12cm, text centered, rounded corners, minimum height=1.2cm, font=\small},
layer/.style={rectangle, draw, fill=white, text width=12cm, text centered, rounded corners, minimum height=4cm, font=\small},
module/.style={rectangle, draw, fill=white, text width=3cm, text centered, rounded corners, minimum height=1cm, font=\small},
arrow/.style={thick,->,>=stealth},
title/.style={font=\bfseries\small}
]
% 定义三层架构
\node[layer, fill=blue!10, text height=5cm] (presentation) at (0,0) {};
\node[title, above=0.1cm of presentation.north west, anchor=west] {表现层};
\node[layer, fill=green!10, below=0.5cm of presentation] (business) {};
\node[title, above=0.1cm of business.north west, anchor=west] {业务逻辑层};
\node[layer, fill=orange!10, below=0.5cm of business] (data) {};
\node[title, above=0.1cm of data.north west, anchor=west] {数据访问层模块};
% 表现层模块
\node[module, fill=blue!20] (ui1) at (-3.5, 1.5) {模型管理};
\node[module, fill=blue!20] (ui2) at (0, 1.5) {模型推理};
\node[module, fill=blue!20] (ui3) at (3.5, 1.5) {模型微调};
\node[module, fill=blue!20] (ui4) at (-3.5, 0) {数据集生成};
\node[module, fill=blue!20] (ui5) at (0, 0) {数据集管理};
\node[module, fill=blue!20] (ui6) at (3.5, 0) {提示词模板管理};
\node[module, fill=blue!20] (ui7) at (0, -1.5) {系统设置};
% 业务逻辑层模块
\node[module, fill=green!20] (bl1) at (-3.5, -4.5) {模型训练模块\\(Unsloth/TRL)};
\node[module, fill=green!20] (bl2) at (0, -4.5) {模型推理模块\\(流式生成)};
\node[module, fill=green!20] (bl3) at (3.5, -4.5) {数据集生成模块\\(LangChain)};
\node[module, fill=green!20] (bl4) at (-2, -6) {数据处理模块};
\node[module, fill=green!20] (bl5) at (2, -6) {配置管理模块};
% 数据访问层模块
\node[module, fill=orange!20] (dl1) at (-3.5, -10) {SQLite\\(系统配置)};
\node[module, fill=orange!20] (dl2) at (0, -10) {TinyDB\\(数据集管理)};
\node[module, fill=orange!20] (dl3) at (3.5, -10) {JSON文件\\(导入/导出)};
% 层间连接
\draw[arrow] (presentation.south) -- (business.north) node[midway, right] {函数调用};
\draw[arrow] (business.south) -- (data.north) node[midway, right] {数据操作};
% 添加Gradio框架标注
\node[above=0.1cm of presentation.north east, anchor=east, font=\small\itshape] {基于Gradio框架};
% 添加说明
\node[below=0.2cm of data.south, text width=12cm, text centered, font=\footnotesize]
{系统采用三层架构设计,实现了功能模块间的解耦与分层,提高了系统的可扩展性和可维护性};
\end{tikzpicture}
\caption{系统三层架构设计图}
\label{fig:system-architecture}
\end{figure}

View File

@ -48,6 +48,9 @@
\usepackage{makecell}%表格竖线连续
\usepackage{tikz}%绘制架构图
\usetikzlibrary{arrows.meta,positioning,shapes,fit,backgrounds,calc}
\def\I{\vrule width1.2pt}
%!\I 就可以代替| 来画表格了