惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

MX – 百品博客

百品电台:自动提供反代的电台App - 百品博客 百品导航:轻量客制化导航首页 - 百品博客 OMSI2香港地圖下載整合 - 百品博客 都市天际线2模组:香港路牌包[WE] - 百品博客 一些闲暇的感受 - 百品博客 美式高速公路路牌制作器 - 百品博客 宝塔面板Jupyterhub插件bug修复 - 百品博客 也谈山西大同订婚强奸案 - 百品博客 换一个新Logo - 百品博客
AI部署实践:Colab部署AI模型进行Fine Tuning - 百品博客
MX文章作者勇敢打破裂缝,阳光就会洒满其中。 · 2026-03-17 · via MX – 百品博客

准备

首先进入Google Colab,点选“代码执行程序”,将GPU改为T4,以确保算力足够。

VLLM-Based

然后安装相关环境:

! pip install uv #安装UV以保证安装速度
!uv pip install vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly #安装VLLM

安装ai模型。到Hugging Face Hub上选用模型并部署。这里笔者使用2026年2月刚刚发布的新模型Qwen3.5-0.8B,参数量选择使用0.8B的小模型来加快速度。同时声明类型为float16以适应T4 GPU。

# 为防止出现错误,升级相关库:
!pip install --upgrade grpcio
!pip install --upgrade protobuf
!vllm serve Qwen/Qwen3.5-0.8B --port 8000 --tensor-parallel-size 1 --max-model-len 262144 --dtype float16  #安装Qwen3.5-0.8B

安装时间大概需要30mins+。(但是最终等不及放弃了,接下来将会使用LLaMA演示)

LLaMA Factory

如果使用LLaMA Factory部署将会非常方便。

如果使用LLaMA Factory,则运行文档中提供的代码:

%cd /content/
%rm -rf LLaMA-Factory
!git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
%cd LLaMA-Factory
%ls
!pip install -e .[torch,bitsandbytes]
import torch
try:
  assert torch.cuda.is_available() is True
except AssertionError:
  print("Please set up a GPU before using LLaMA Factory: https://medium.com/mlearning-ai/training-yolov4-on-google-colab-316f8fff99c6")
import json

%cd /content/LLaMA-Factory/

NAME = "Llama-3"
AUTHOR = "LLaMA Factory"

with open("data/identity.json", "r", encoding="utf-8") as f:
  dataset = json.load(f)

for sample in dataset:
  sample["output"] = sample["output"].replace("{{"+ "name" + "}}", NAME).replace("{{"+ "author" + "}}", AUTHOR)

with open("data/identity.json", "w", encoding="utf-8") as f:
  json.dump(dataset, f, indent=2, ensure_ascii=False)

升级相关库,安装Chinese库以供预测:

!pip install --upgrade transformers
!pip install rouge_chinese

部署Board:

%cd /content/LLaMA-Factory/
!GRADIO_SHARE=1 DISABLE_VERSION_CHECK=1 llamafactory-cli webui
# 注意设置取消环境版本检查

执行

得到board地址,打开,调整Fine-tuning参数。设置checkpoint_path = 留空,如果报错,第一次微调时就填”Qwen/Qwen2.5-0.5B”(和Model Path一致)(原本打算使用3.5-0.8B模型,但发现T4的GPU带不动)

https://baipin.pw/wp-content/uploads/2026/03/image-1.png

其余保持不变即可,其中的Training model可以根据自己的喜好选择。Learning rate(控制在训练过程中每次更新权重的幅度), Batch size(每次前向/反向传播过程中使用的训练样本数量), Number of epochs(整个数据集在训练过程中被模型训练的次数)等等都可以自己手动调整来观察训练的结果变化。

然后滑动到页面底部,选择“start”开始Fine-tuning。这个过程大概持续30~40min。

完成之后,点选到Evaluate & Predict选项卡查看模型效果,之后可以再选择其余的Finetuning method,以体验不同Finetuning模式下的差异。最后可以自己到Chat选项卡体验成品效果,和自己训练的模型对话。

保存模型

在Colab中运行如下代码以保存工作目录下的模型及日志:

!zip -r my_folder.zip /content/LLaMA-Factory/saves  # 结尾为要压缩的目标文件夹
from google.colab import files
files.download("my_folder.zip")

或者只保留日志文件:

!cd /content/LLaMA-Factory/saves && find . -type f \( -name "*.json" -o -name "*.jonl" -o -name "*.txt" -o -name "*.yaml" -o -name "*.bin" -o -name "*.png" \) | zip -@ ../elected_files.zip