docs: 更新实验验证章节并添加相关图表
更新了实验验证章节的内容,包括硬件配置、LoRA微调参数、计算资源占用和训练指标变化的详细描述。新增了三张图表(monitor.png、training_metrics.png、after_train.png)以直观展示训练过程中的系统资源占用、训练指标变化和微调后的效果。这些修改增强了实验部分的完整性和可读性。
This commit is contained in:
parent
e87d721f47
commit
55784b3775
@ -12,7 +12,8 @@
|
||||
|
||||
实验采用的主要硬件配置如下:
|
||||
\begin{itemize}
|
||||
\item CPU:Intel Core i7-12700K(12核24线程)
|
||||
\item 笔记本型号:Lenovo Legion R7000P 2021H
|
||||
\item CPU:AMD Ryzen 7 5800H
|
||||
\item GPU:NVIDIA GeForce RTX 3060 Laptop GPU(6GB显存)
|
||||
\item 内存:16GB DDR4
|
||||
\item 存储:2TB NVMe SSD
|
||||
@ -79,6 +80,7 @@
|
||||
|
||||
本实验采用LoRA(Low-Rank Adaptation)技术进行参数高效微调,主要配置参数如下:
|
||||
\begin{itemize}
|
||||
\item 量化精度:4bit
|
||||
\item LoRA秩(r):64,控制低秩矩阵的维度
|
||||
\item LoRA缩放因子(alpha):16,控制LoRA更新的幅度
|
||||
\item 学习率:2e-4,采用余弦学习率调度策略
|
||||
@ -95,18 +97,47 @@
|
||||
|
||||
\subsubsection{计算资源占用}
|
||||
|
||||
......
|
||||
图\ref{fig:monitor}展示了模型训练过程中的系统资源占用情况。在6GB显存的RTX 3060 GPU上,QLoRA微调仅占用4.1GB显存,这种高效的资源利用率得益于QLoRA的低秩适应技术,仅需更新少量参数即可实现模型性能的显著提升,充分体现了本框架在资源受限环境下的优化能力。
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\includegraphics[width=0.8\textwidth]{pic/monitor.png}
|
||||
\caption{模型训练过程中的系统资源监控}
|
||||
\label{fig:monitor}
|
||||
\end{figure}
|
||||
|
||||
\subsubsection{训练指标变化}
|
||||
|
||||
微调过程中,主要训练指标的变化趋势如下:
|
||||
......
|
||||
微调过程中,主要训练指标的变化趋势如图\ref{fig:training_metrics}所示。从图中可以观察到以下几个关键特征:
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\includegraphics[width=0.8\textwidth]{pic/training_metrics.png}
|
||||
\caption{模型微调过程中的训练指标变化趋势}
|
||||
\label{fig:training_metrics}
|
||||
\end{figure}
|
||||
|
||||
\begin{itemize}
|
||||
\item \textbf{梯度范数(Gradient Norm)}:训练初期,梯度范数在0.5到1.5之间波动,表明参数更新幅度较大。随着训练步数的增加,梯度范数逐渐减小,并在约4000步后稳定在0.1到0.5之间,这与损失函数的下降趋势一致,表明模型正在趋于收敛,参数更新的步伐减缓。
|
||||
|
||||
\item \textbf{损失函数(Loss)}:训练初期,损失值从约2.4迅速下降。在约1000步时降至0.5以下,随后继续缓慢下降。在大约5000步后,损失值稳定在接近于零的水平,表明模型在训练集上已经取得了很好的性能,基本收敛。
|
||||
|
||||
\item \textbf{学习率(Learning Rate)}:学习率采用线性衰减策略,从初始值约0.0002(或2e-4)随着训练步数的增加而稳定地线性降低,直至训练结束时接近于零。这种策略有助于在训练初期快速探索解空间,并在后期精细调整参数以促进模型稳定收敛。
|
||||
|
||||
\item \textbf{训练效率}:整个微调过程耗时约5.5小时,平均每步训练时间约3秒,展现了本框架在资源受限环境下的高效性。特别是在训练后期,尽管学习率降低,模型仍能持续优化,损失值稳步下降,表明LoRA微调方法的有效性。
|
||||
\end{itemize}
|
||||
|
||||
通过分析训练指标变化可以看出,本框架采用的LoRA微调策略在有限计算资源下实现了高效训练,损失函数的平稳下降和最终收敛表明模型成功适应了目标文档内容,为后续的效果验证奠定了基础。
|
||||
|
||||
\subsection{微调效果验证}
|
||||
|
||||
.....
|
||||
|
||||
|
||||
经过微调后的模型能够对相关内容做出准确回答,图\ref{fig:after_train}展示了训练后的效果。
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\includegraphics[width=0.8\textwidth]{pic/after_train.png}
|
||||
\caption{模型微调后的效果}
|
||||
\label{fig:after_train}
|
||||
\end{figure}
|
||||
|
||||
综上所述,实验结果验证了本框架的有效性。通过文档驱动的自适应微调,成功将通用大语言模型定向优化为具备企业特定代码生成能力的专用模型,在保持模型通用能力的同时,显著提升了其在特定领域的表现,为企业级软件开发的智能化与高效化提供了有力支持。
|
||||
|
BIN
paper/latex/pic/after_train.png
Normal file
BIN
paper/latex/pic/after_train.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
BIN
paper/latex/pic/monitor.png
Normal file
BIN
paper/latex/pic/monitor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
paper/latex/pic/training_metrics.png
Normal file
BIN
paper/latex/pic/training_metrics.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
34
paper/object/plot_training_data.py
Normal file
34
paper/object/plot_training_data.py
Normal file
@ -0,0 +1,34 @@
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# 读取CSV文件
|
||||
data = pd.read_csv('training_data.csv')
|
||||
|
||||
# 创建图表
|
||||
plt.figure(figsize=(12, 9))
|
||||
|
||||
# 绘制梯度范数变化曲线
|
||||
plt.subplot(3, 1, 1) # 修改为 3行1列的第1个
|
||||
plt.plot(data['Step'], data['grad_norm'], label='Gradient Norm')
|
||||
plt.xlabel('Step')
|
||||
plt.ylabel('Gradient Norm')
|
||||
plt.legend()
|
||||
|
||||
# 绘制损失值变化曲线
|
||||
plt.subplot(3, 1, 2) # 修改为 3行1列的第2个
|
||||
plt.plot(data['Step'], data['loss'], label='Loss', color='orange')
|
||||
plt.xlabel('Step')
|
||||
plt.ylabel('Loss')
|
||||
plt.legend()
|
||||
|
||||
# 绘制学习率变化曲线
|
||||
plt.subplot(3, 1, 3) # 修改为 3行1列的第3个
|
||||
plt.plot(data['Step'], data['learning_rate'], label='Learning Rate', color='green')
|
||||
plt.xlabel('Step')
|
||||
plt.ylabel('Learning Rate')
|
||||
plt.legend()
|
||||
|
||||
# 调整布局并保存图片
|
||||
plt.tight_layout()
|
||||
plt.savefig('training_metrics.png')
|
||||
plt.show()
|
1001
paper/object/training_data.csv
Normal file
1001
paper/object/training_data.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user