Phi-2小语言模型QLoRA微调教程
前言
就在不久前,微软正式发布了一个 27 亿参数的语言模型——Phi-2。这是一种文本到文本的人工智能程序,具有出色的推理和语言理解能力。同时,微软研究院也在官方 X 平台上声称:“Phi-2 的性能优于其他现有的小型语言模型,但它足够小,可以在笔记本电脑或者移动设备上运行”。
微软通过时下一些如 Big Bench Hard (BBH)、常识推理(PIQA、WinoGrande、ARC easy 和 Challenge、SIQA)、语言理解(HellaSwag、OpenBookQA、MMLU(5-shot)、SQuADv2、BoolQ)、数学(GSM8k)和编码(HumanEval)等基准测试,将 Phi-2 与 7B 和 13B 参数的 Mistral 和 Llama-2 进行了比较。
最终得出仅拥有 27 亿个参数的 Phi-2 ,超越了 Mistral 7B 和 Llama-2 7B 以及 13B 模型的性能。值得注意的是,与大它 25 倍的 Llama-2-70B 模型相比,Phi-2 还在多步推理任务(即编码和数学)上实现了更好的性能。
本教程将基于谜语数据集使用QLoRA 微调Phi-2模型。
模型微调
Phi-2
模型Huggingface
开源地址,谜语数据集Huggingface
开源地址- 下面所有代码均在
kaggle
平台,GPU
为T4 × 2
环境下运行。
搭建环境
- 微调需要安装库
transformers
、peft
、datasets
、evaluate
、einops
、bitsandbytes
from IPython.display import clear_output
!pip install -U transformers peft datasets evaluate einops bitsandbytes -q
!pip install accelerate==0.21.0 -q
clear_output()
- 导入必要库
import os
import torch
from datasets import load_dataset
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
clear_output()
数据预处理
加载数据
- 加载数据集,并拆分训练、测试集,打印示例。
dataset = load_dataset("g-ronimo/riddles_evolved")
dataset = dataset["train"].train_test_split(test_size=0.1)
clear_output()
dataset["train"][0]
{'number': 286,'messages': ["Born in despair, fed with mud, soon I'll bloom into beauty for the good.",'This riddle appears to be describing a flower that grows in adverse conditions. Here\'s a step-by-step explanation:\n\n1. "Born in despair" suggests that the subject of the riddle had a difficult start in life.\n2. "Fed with mud" means that it has been nourished in dirty or poor conditions.\n3. "Soon I\'ll bloom into beauty" indicates that despite its challenging start, it will eventually become something beautiful.\n4. "Think step-by-step" is advice to break down complex problems into smaller, manageable parts.\n5. "Keep your explanations simple" is a recommendation to make complex ideas easy to understand.\n6. "Try your very best" emphasizes the importance of giving your all to accomplish your goals.\n7. "If you there is information missing for you to come up with a specific answer, just ask me a short question at the end of your answer" is a request to specify the topic or question if more clarification is needed.\n\nQuestion: What is the answer to the riddle, and what is the identity of the flower described?','What kind of flower starts in hardship, grows in dirt, but ultimately blooms into something lovely?','The answer to the riddle and the identity of the flower described is a sunflower. Sunflowers start as seeds in adversity, grow in soil that may not be ideal, but eventually bloom into beautiful yellow flowers that bring joy and sunlight.']}
应用ChatML格式并标记数据集
- 首先使用 ChatML 格式组织对话,然后对它们进行标记。设置数据集非常重要,以便模型学会像
assistant
一样回答,而不是像user
一样提出问题。为此,我们将忽略索引的标记(labels
)设置为-100。 - 注意:如果您熟悉
QLoRA
库,您会注意到原始的guanaco
模型是针对问题和答案进行训练的(qlora.py 中默认为train_on_source=False
)。这些模型经过原始对话文本的训练,表现良好。不过,在谜语中只关注assistant
的部分才是正确的训练方法。
import os
from functools import partial# ChatML格式
templates = ["<|im_start|>assistant\n{msg}<|im_end|>", # message by assistant"<|im_start|>user\n{msg}<|im_end|>", # message by user
]# 在损失计算期间,使用此特殊索引来忽略某些标记。
IGNORE_INDEX = -100def tokenize(input, max_length):input_ids, attention_mask, labels = [], [], []# 遍历数据集中的每个消息for i, msg in enumerate(input["messages"]):# 检查消息是来自user还是assistant,应用ChatML模板isHuman = i%2==0msg_chatml = templates[isHuman].format(msg=msg)# 标记化所有内容,稍后截断msg_tokenized = tokenizer(msg_chatml, truncation=False, add_special_tokens=False)# 复制标记和注意力掩码而不进行更改input_ids += msg_tokenized["input_ids"]attention_mask += msg_tokenized["attention_mask"]# 为损失计算调整标签:如果是user->IGNORE_INDEX,如果是assistant->input_ids# 忽略user消息,仅计算assistant消息的损失,因为这是我们想要学习labels += [IGNORE_INDEX]*len(msg_tokenized["input_ids"]) if isHuman else msg_tokenized["input_ids"]# 截断至最大长度return {"input_ids": input_ids[:max_length], "attention_mask": attention_mask[:max_length],"labels": labels[:max_length],}dataset_tokenized = dataset.map(# 在1024标记处截断样本# 对于谜题数据集足够了(最大长度1000标记)# 对于其他数据集,必须适应,较高的值需要更多的显存partial(tokenize, max_length=1024), batched = False,# 多线程num_proc = os.cpu_count(),# 删除原始列,不再需要remove_columns = dataset["train"].column_names
)
- 对于上面不理解的代码内容可以单独运行,比如如何区分
assistant
和user
。
for i, msg in enumerate(dataset['train'][0]['messages']):isHuman = i%2==0print(i)print(isHuman)print(msg)
定义collator
collate
函数的目的是处理和准备用于训练(和评估)的batch
数据,关键部分是正确填充输入。它通过使用特定标记填充到最长样本的长度来标准化batch
中每个数据点的长度。input_ids
用pad token
填充,labels
用IGNORE_INDEX
填充(以表明这些token
不参与损失计算),并且attention_mask
为0(忽略填充的标记)。
# collate函数 - 将字典列表[{input_ids: [123, ..]}, {..]}转换为一个字典
# 形成batch{input_ids: [..], labels: [..], attention_mask: [..]}
def collate(elements):# 从每个元素中提取input_ids,并找出它们中的最大长度tokens = [e["input_ids"] for e in elements]tokens_maxlen = max([len(t) for t in tokens])for i, sample in enumerate(elements):input_ids = sample["input_ids"]labels = sample["labels"]attention_mask = sample["attention_mask"]# 计算需要填充以匹配最大标记长度的填充长度pad_len = tokens_maxlen-len(input_ids)# 用pad标记ID填充'input_ids',用IGNORE_INDEX填充'labels',用0填充'attention_mask'input_ids.extend( pad_len * [tokenizer.pad_token_id] )labels.extend( pad_len * [IGNORE_INDEX] )attention_mask.extend( pad_len * [0] )# 创建并返回包含elements中所有数据的批次batch={"input_ids": torch.tensor( [e["input_ids"] for e in elements] ),"labels": torch.tensor( [e["labels"] for e in elements] ),"attention_mask": torch.tensor( [e["attention_mask"] for e in elements] ),}return batch
微调 Phi-2
加载量化模型
- 因为在kaggle平台,GPU显存有限,所以只能加载量化后的模型。
- 加载
4-bit
模型和分词器(tokenizer
)
modelpath = "microsoft/phi-2"
model = AutoModelForCausalLM.from_pretrained(modelpath,device_map="auto",quantization_config=BitsAndBytesConfig(load_in_4bit=True,bnb_4bit_compute_dtype=torch.bfloat16,bnb_4bit_quant_type="nf4",),torch_dtype=torch.bfloat16,trust_remote_code=True,
)
添加ChatML标记
- 将
ChatML
特殊标记添加到模型和tokenizer
中。 - 关于
ChatML
是一种模型能看的懂的语言格式。
# fast tokenizer有时会忽略添加的tokens
tokenizer = AutoTokenizer.from_pretrained(modelpath, use_fast=False) # 添加ChatML特殊标记
tokenizer.add_tokens(["<|im_start|>", "<PAD>"])
tokenizer.pad_token = "<PAD>"
tokenizer.add_special_tokens(dict(eos_token="<|im_end|>"))# 调整模型embeddings大小
model.resize_token_embeddings(new_num_tokens=len(tokenizer),pad_to_multiple_of=64)
model.config.eos_token_id = tokenizer.eos_token_id
clear_output()
准备LoRA适配器
LoRA
(Low-Rank Adaptation
)是微调大型模型的有效方法。它仅在训练期间更新模型的选定部分,从而加快过程并节省内存。
from peft import prepare_model_for_kbit_training, LoraConfig, get_peft_model# lora微调配置
lora_config = LoraConfig(r=32,lora_alpha=32,target_modules = ['fc1', 'fc2', 'Wqkv', 'out_proj'],lora_dropout=0.1,bias="none",modules_to_save = ["lm_head", "embed_tokens"],task_type="CAUSAL_LM"
)# 添加适配器到模型
model = prepare_model_for_kbit_training(model, use_gradient_checkpointing = False)
model = get_peft_model(model, lora_config)
model.config.use_cache = False
lora
微调配置参数说明:rank
:LoRA
中的rank
也会影响可训练参数的数量。较高的rank
会增加训练参数,这意味着模型灵活性和适应能力提高,但代价是增加计算复杂性。相反,较低的rank
会减少训练参数,意味着更有效的训练和更少的计算负担,但可能会降低模型灵活性。因此,rank
的选择代表了模型适应性和计算效率之间的权衡。lora_alpha
:缩放因子,用于调整低秩更新对模型原始权重的影响,即:模型原始行为的改变程度。 LoRA 论文指出"tuning alpha is roughly the same as tuning the learning rate"(调整 alpha 与调整学习率大致相同)。关于如何设置rank
与lora_alpha
尚未达成共识。一种方法似乎是设置lora_alpha = r
,这就是我们在这里使用的。target_modules
:使用上述参数,我们仅训练约 5.1% 的模型权重。若资源有限,也可以选择仅训练注意力矩阵和输出权重(['Wqkv', 'out_proj']
),在rank=32
的情况下,参数数量降低到 4.4% 。对线性层进行训练应该会提高模型性能,因为它更接近于完全微调,但也会增加适配器大小。
- 更多参数说明请访问Huggingface官方文档
开始训练
- 部分训练超参数说明:
batch_size
:较大的batch_size
更好,但受到可用VRAM的限制。训练样本越长(在tokenization
过程中增加max_length
),需要的VRAM就越多。在max_length
为1024个token
的示例中,batch_size
为1是24GB VRAM GPU上的最大值。为了增加有效批量大小,gradient_accumulation_steps
设置为16,但缺点是会减慢训练过程。learning_rate
:2e-5
的学习率对此数据集有不错的效果,当然4e-5
的学习率也可能有效,并且会产生一个不错的模型而不会过度拟合。lr_scheduler_type
:根据QLoRA
作者Tim Dettmers使用恒定学习率策略的建议,我采用了这种方法,并发现它对于Phi-2
、Llama 1/2
和Mistral
始终有效。
- 更多训练超参数见官方文档,设置好训练参数后开始训练。
from transformers import TrainingArguments, Trainerbs=1 # batch size
ga_steps=16 # gradient acc. steps
epochs=15
lr=0.00001steps_per_epoch=len(dataset_tokenized["train"])//(bs*ga_steps)args = TrainingArguments(output_dir="out",per_device_train_batch_size=bs,per_device_eval_batch_size=16,evaluation_strategy="steps",logging_steps=2,eval_steps=steps_per_epoch//2, # eval twice per epochsave_steps=1, # save once per epochgradient_accumulation_steps=ga_steps,num_train_epochs=epochs,lr_scheduler_type='constant',optim='paged_adamw_32bit', # val_loss will go NaN with paged_adamw_8bitlearning_rate=lr,group_by_length=False,fp16=True,metric_for_best_model='eval_loss',save_total_limit=1,
# bf16=False,ddp_find_unused_parameters=False,
)trainer = Trainer(model=model,tokenizer=tokenizer,args=args,data_collator=collate,train_dataset=dataset_tokenized["train"],eval_dataset=dataset_tokenized["test"],
)trainer.train()
训练分析
- 训练集损失
- 验证集损失
模型合并
LoRA
适配器训练完成以后,需要与原模型进行合并。
modelpath = "microsoft/phi-2"
adapter_path='/kaggle/input/phi-2-finetune/out/checkpoint-846'save_to="merged" base_model = AutoModelForCausalLM.from_pretrained(modelpath,return_dict=True,torch_dtype=torch.bfloat16,device_map="auto",trust_remote_code=True,
)tokenizer = AutoTokenizer.from_pretrained(modelpath)tokenizer.add_tokens(["<|im_start|>", "<PAD>"])
tokenizer.pad_token = "<PAD>"
tokenizer.add_special_tokens(dict(eos_token="<|im_end|>"))
base_model.resize_token_embeddings(new_num_tokens=len(tokenizer),pad_to_multiple_of=64)
base_model.config.eos_token_id = tokenizer.eos_token_idmodel = PeftModel.from_pretrained(base_model, adapter_path)
model = model.merge_and_unload()model.save_pretrained(save_to, safe_serialization=True, max_shard_size='4GB')
tokenizer.save_pretrained(save_to)clear_output()
微调前后对比
- 先加载一下原模型,输入谜语,看看回答是什么。
torch.set_default_device("cuda")model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2", torch_dtype="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-2", trust_remote_code=True)inputs = tokenizer('''What makes a noise like a bell and flies, but cannot be seen? The answer lies in the bright blue sky.''', return_tensors="pt", return_attention_mask=False)outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]clear_output()
print(text)
输出:
In the world of mathematics, we often encounter situations where we need to compare and order numbers. This skill is essential in various fields, including science, engineering, and even everyday life. Let’s explore the concept of comparing and ordering numbers using the tones of science, specifically the principles of physics and the states of matter.
Imagine you are in a science lab, conducting an experiment to study the behavior of different substances. You have a set of test tubes filled with various liquids, each representing a different state of matter. The liquids in the test tubes are like numbers, and we can compare and order them based on their properties.
参考中译:
在数学世界中,我们经常会遇到需要对数字进行比较和排序的情况。这项技能在科学、工程甚至日常生活等各个领域都至关重要。让我们用科学的视角,特别是物理学原理和物质状态,来探讨数字比较和排序的概念。
想象一下,您正在科学实验室里进行一项实验,研究不同物质的行为。你有一组试管,里面装满了各种液体,每种液体代表一种不同的物质状态。试管中的液体就像数字,我们可以根据它们的性质进行比较和排序。
- 可以说是非常糟糕的回答,我们看看微调后的模型会输出什么。
model = AutoModelForCausalLM.from_pretrained("/kaggle/working/merged", torch_dtype="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("/kaggle/working/merged", trust_remote_code=True)inputs = tokenizer('''<|im_start|>What makes a noise like a bell and flies, but cannot be seen? The answer lies in the bright blue sky.<|im_end|>''', return_tensors="pt", return_attention_mask=False)outputs = model.generate(**inputs, max_length=300)
text = tokenizer.batch_decode(outputs)[0]clear_output()
print(text)
输出:
The answer to the riddle is a “bluebird.” Bluebirds make a distinctive bell-like sound with their wings, and they are often seen flying in the sky. However, they cannot be seen with the naked eye as they are small birds. If you need more information, please let me know what specific aspect of the answer you would like to know.
参考中译:
谜底是 “青鸟”。青鸟用翅膀发出独特的铃铛声,人们经常看到它们在天空中飞翔。不过,由于它们是小型鸟类,肉眼无法看到。如果您需要更多信息,请告诉我您想知道答案的具体方面。
- 微调后的模型得到了相对满意的答案。请注意,这是在
4-bit
量化状态下微调的答案,如果可以在float32
状态下微调,或许会得到更好的答案。
相关文章:

Phi-2小语言模型QLoRA微调教程
前言 就在不久前,微软正式发布了一个 27 亿参数的语言模型——Phi-2。这是一种文本到文本的人工智能程序,具有出色的推理和语言理解能力。同时,微软研究院也在官方 X 平台上声称:“Phi-2 的性能优于其他现有的小型语言模型&#…...

hadoop自动获取时间
1、自动获取前15分钟 substr(from_unixtime(unix_timestamp(concat(substr(20240107100000,1,4),-,substr(20240107100000,5,2),-,substr(20240107100000,7,2), ,substr(20240107100000,9,2),:,substr(20240107100000,11,2),:,00))-15*60,yyyyMMddHHmmss),1) unix_timestam…...
【面试高频算法解析】算法练习8 单调队列
前言 本专栏旨在通过分类学习算法,使您能够牢固掌握不同算法的理论要点。通过策略性地练习精选的经典题目,帮助您深度理解每种算法,避免出现刷了很多算法题,还是一知半解的状态 专栏导航 二分查找回溯(Backtracking&…...

ATTCK视角下的信息收集:Sysmon检测
目录 1、简介 2、使用Sysmon 3、检测Sysmon是否安装运行 4、检测Sysmon是否被卸载 5、使Sysmon在终端隐匿运行的技术 1、简介 Sysmon(系统监视器)是由windows sysinternals 出品的Sysinternals 系列工具中的一个 它是windows系统服务和设备驱动程…...

02、Kafka ------ 配置 Kafka 集群
目录 配置 Kafka 集群配置步骤启动各Kafka节点 配置 Kafka 集群 启动命令: 1、启动 zookeeper 服务器端 小黑窗输入命令: zkServer 2、启动 zookeeper 的命令行客户端工具 (这个只是用来看连接的节点信息,不启动也没关系&#…...
2024年全球网络安全预测报告
1.Gartner Gartners Top Strategic Predictions for 2024 and Beyond《Gartner顶级战略预测:2024年及未来》 https://www.gartner.com/en/articles/gartner-s-top-strategic-predictions-for-2024-and-beyond 2.IDC Top 10 Worldwide IT Industry 2024 Predict…...
Qt - QML与C++数据交互详解
文章目录 1 . 前言2 . Qml调用C的变量3 . Qml调用C的类4 . Qml调用C的方法5 . Qml接收C的信号6 . C接收Qml的信号(在Qml中定义信号槽)7 . C接收Qml的信号(在C中定义信号槽)8 . C调用Qml的函数9 . 总结 【极客技术传送门】 : https…...

Kettle Local引擎使用记录(一)(基于Kettle web版数据集成开源工具data-integration源码)
Kettle Web 📚第一章 前言📚第二章 demo源码📗pom.xml引入Kettle引擎核心文件📗java源码📕 controller📕 service📕 其它📕 maven settings.xml 📗测试📕 测试…...

Java--业务场景:在Spring项目启动时加载Java枚举类到Redis中(补充)
文章目录 前言步骤测试结果 前言 通过Java–业务场景:在Spring项目启动时加载Java枚举类到Redis中,我们成功将Java项目里的枚举类加载到Redis中了,接下来我们只需要写接口获取需要的枚举值数据就可以了,下面一起来编写这个接口吧。 步骤 在…...

WPF 基础入门(资源字典)
资源字典 每个Resources属性存储着一个资源字典集合。如果希望在多个项目之间共享资源的话,就可以创建一个资源字典。资源字段是一个简单的XAML文档,该文档就是用于存储资源的,可以通过右键项目->添加资源字典的方式来添加一个资源字典文件…...

文章解读与仿真程序复现思路——电网技术EI\CSCD\北大核心《考虑电氢耦合和碳交易的电氢能源系统置信间隙鲁棒规划》
本专栏栏目提供文章与程序复现思路,具体已有的论文与论文源程序可翻阅本博主免费的专栏栏目《论文与完整程序》 这标题涉及到一个复杂的能源系统规划问题,其中考虑了电氢耦合、碳交易和置信间隙鲁棒规划。以下是对标题各个部分的解读: 电氢耦…...
ubuntu设定时间与外部ntp同步
前言 在 Ubuntu 上,你可以通过配置 systemd-timesyncd 服务来与外部 NTP 服务器同步系统时间。下面是设置的步骤: 安装 NTP 工具: 如果你的系统中没有安装 ntpdate 工具,可以使用以下命令安装: sudo apt-get updat…...

DataFrame详解
清洗相关的API 清洗相关的API: 1.去重API: dropDupilcates 2.删除缺失值API: dropna 3.替换缺失值API: fillna 去重API: dropDupilcates dropDuplicates(subset):删除重复数据 1.用来删除重复数据,如果没有指定参数subset,比对行中所有字段内容,如果全部相同,则认为是重复数据,…...

控制障碍函数(Control Barrier Function,CBF) 三、代码
三、代码实现 3.1、模型 这是一个QP问题,所以我们直接建模 这其实还是之前的那张图,我们把这个大的框架带入到之前的那个小车追击的问题中去,得到以下的一些具体的约束条件 CLF约束 L g V ( x ) u − δ ≤ − L f V ( x ) − λ V ( x ) …...

哈希表-散列表数据结构
1、什么是哈希表? 哈希表也叫散列表,哈希表是根据关键码值(key value)来直接访问的一种数据结构,也就是将关键码值(key value)通过一种映射关系映射到表中的一个位置来加快查找的速度,这种映射关系称之为哈希函数或者散列函数&…...

C# 强制类型转换和as区别和不同使用场景
文章目录 1.强制类型转换2. as 运算符3.实例总结: 在C#中,as 和 强制类型转换(例如 (T)value)的主要区别在于它们处理类型转换不成功时的行为和适用场景: 1.强制类型转换 使用语法:Type variable (Type)…...
什么是 DDoS 攻击
布式拒绝服务 (DDoS) 攻击是一种恶意尝试,通过大量互联网流量淹没目标或其周围基础设施,从而破坏目标服务器、服务或网络的正常流量。 DDoS 攻击通过利用多个受感染的计算机系统作为攻击流量源来实现有效性。被利用的机器可以包括计算机和其他网络资源。 从高层来看,DDoS 攻…...
c++隐式类型转换与explicit
我们知道,一个float与int做运算时,系统会首先个int类型转换为float类型之后再进行运算,这种隐式类型转换也会发生在类中 看以下例子,定义一个类 class myTime { public:int Hour;myTime() {};myTime(int h) :Hour(h) {}; }; 在…...

BERT Intro
继续NLP的学习,看完理论之后再看看实践,然后就可以上手去kaggle做那个入门的project了orz。 参考: 1810.04805.pdf (arxiv.org) BERT 论文逐段精读【论文精读】_哔哩哔哩_bilibili (强推!)2023李宏毅讲解大模型鼻祖BERT,一小时…...

“To-Do Master“ GPTs:重塑任务管理的趣味与效率
有 GPTs 访问权限的可以点击链接进行体验:https://chat.openai.com/g/g-IhGsoyIkP-to-do-master 部署私人的 To-Do Master 教程:https://github.com/Reborn14/To-Do-Master/tree/main 引言 在忙碌的日常生活中,有效地管理日常任务对于提高生…...
KubeSphere 容器平台高可用:环境搭建与可视化操作指南
Linux_k8s篇 欢迎来到Linux的世界,看笔记好好学多敲多打,每个人都是大神! 题目:KubeSphere 容器平台高可用:环境搭建与可视化操作指南 版本号: 1.0,0 作者: 老王要学习 日期: 2025.06.05 适用环境: Ubuntu22 文档说…...
vscode里如何用git
打开vs终端执行如下: 1 初始化 Git 仓库(如果尚未初始化) git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...

边缘计算医疗风险自查APP开发方案
核心目标:在便携设备(智能手表/家用检测仪)部署轻量化疾病预测模型,实现低延迟、隐私安全的实时健康风险评估。 一、技术架构设计 #mermaid-svg-iuNaeeLK2YoFKfao {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg…...

[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?
论文网址:pdf 英文是纯手打的!论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误,若有发现欢迎评论指正!文章偏向于笔记,谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案
随着新能源汽车的快速普及,充电桩作为核心配套设施,其安全性与可靠性备受关注。然而,在高温、高负荷运行环境下,充电桩的散热问题与消防安全隐患日益凸显,成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

Docker 本地安装 mysql 数据库
Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker ;并安装。 基础操作不再赘述。 打开 macOS 终端,开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...
comfyui 工作流中 图生视频 如何增加视频的长度到5秒
comfyUI 工作流怎么可以生成更长的视频。除了硬件显存要求之外还有别的方法吗? 在ComfyUI中实现图生视频并延长到5秒,需要结合多个扩展和技巧。以下是完整解决方案: 核心工作流配置(24fps下5秒120帧) #mermaid-svg-yP…...

项目进度管理软件是什么?项目进度管理软件有哪些核心功能?
无论是建筑施工、软件开发,还是市场营销活动,项目往往涉及多个团队、大量资源和严格的时间表。如果没有一个系统化的工具来跟踪和管理这些元素,项目很容易陷入混乱,导致进度延误、成本超支,甚至失败。 项目进度管理软…...
Go 并发编程基础:select 多路复用
select 是 Go 并发编程中非常强大的语法结构,它允许程序同时等待多个通道操作的完成,从而实现多路复用机制,是协程调度、超时控制、通道竞争等场景的核心工具。 一、什么是 select select 类似于 switch 语句,但它用于监听多个通…...

Python 解释器安装全攻略(适用于 Linux / Windows / macOS)
目录 一、Windows安装Python解释器1.1 下载并安装Python解释1.2 测试安装是否成功1.3 设置pip的国内镜像------永久配置 二、macOS安装Python解释器三、Linux下安装Python解释器3.1 Rocky8.10/Rocky9.5安装Python解释器3.2 Ubuntu2204/Ubuntu2404安装Python解释器3.3 设置pip的…...