当前位置: 首页 > news >正文

重庆网站设计开发培训学校网络科技公司属于什么行业

重庆网站设计开发培训学校,网络科技公司属于什么行业,国家企业信用公示信息系统查询,vi设计基本要素1. 背景介绍 虽然现在大模型微调的文章很多#xff0c;但纸上得来终觉浅#xff0c;大模型微调的体感还是需要自己亲自上手实操过#xff0c;才能有一些自己的感悟和直觉。这次我们选择使用llama_factory来微调chatglm-4-9B大模型。 之前微调我们是用两块3090GPU显卡…1. 背景介绍   虽然现在大模型微调的文章很多但纸上得来终觉浅大模型微调的体感还是需要自己亲自上手实操过才能有一些自己的感悟和直觉。这次我们选择使用llama_factory来微调chatglm-4-9B大模型。 之前微调我们是用两块3090GPU显卡但这次我们要全参微调chatglm-4-9B模型模型大小为18G显然两块3090卡48G显存支撑不了因此采用A800的4张卡来训练。一般来说全参微调的显存需求约为模型大小的20倍。按照惯例先上配置信息方便对齐环境配置。 2. LLaMa Factory部署 本文参考【1, 23】进行实践。 2.1 安装conda并创建虚拟环境 conda create -n llama_factory python3.10 -y  conda activate llama_factory 安装依赖包版本推荐 torch 2.4.0 torchvision 0.19.0 nvidia-cublas-cu12 12.1.3.1 nvidia-cuda-cupti-cu12 12.1.105 nvidia-cuda-nvrtc-cu12 12.1.105 nvidia-cuda-runtime-cu12 12.1.105 transformers 4.46.1 datasets 3.1.0 accelerate 1.1.0 peft 0.13.2 trl 0.12.0 deepspeed 0.15.3 2.2 安装LLaMa Factory 下载并安装LLaMa factory git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git cd LLaMA-Factory  pip install -e .[torch,metrics] 运行测试 llamafactory-cli help 3. Chatglm-4-9B全参微调 3.1 下载chatglm-4-9B大模型参数 基于modelscope下载模型采用命令行下载方式 pip install modelscope 下载完整模型 modelscope download --model ZhipuAI/glm-4-9b-chat 3.2 训练配置 3.2.1 full_sft配置 chatglm_full_sft.yaml ### model model_name_or_path: path/to/models/glm-4-9b-chat #改成你自己的路径 trust_remote_code: true### method stage: sft do_train: true finetuning_type: full freeze_vision_tower: true # choices: [true, false] train_mm_proj_only: false # choices: [true, false] deepspeed: examples/deepspeed/ds_z3_config.json # choices: [ds_z0_config.json, ds_z2_config.json, ds_z3_config.json]### dataset dataset: identity,alpaca_en_demo template: glm4 #选择对应模版 cutoff_len: 2048 max_samples: 1000 overwrite_cache: true preprocessing_num_workers: 16### output output_dir: saves/chatglm_4-9b/full/sft #定义微调模型参数存储路径 logging_steps: 10 save_steps: 500 plot_loss: true overwrite_output_dir: true### train per_device_train_batch_size: 1 gradient_accumulation_steps: 2 learning_rate: 1.0e-5 num_train_epochs: 30.0 lr_scheduler_type: cosine warmup_ratio: 0.1 bf16: true ddp_timeout: 180000000### eval val_size: 0.1 per_device_eval_batch_size: 1 eval_strategy: steps eval_steps: 500 3.2.2 deepspeed配置 主要区别在zero_optimization的配置层面。ZeRO 通过将模型的参数梯度和 Optimizer State划分到不同进程来消除冗余的内存占用。ZeRO 有三个不同级别分别对应对 Model States 不同程度的分割 (Paritition)- ZeRO-0禁用所有分片ZeRO-1分割Optimizer States- ZeRO-2分割Optimizer States与Gradients- ZeRO-3分割Optimizer States、Gradients与Parameters【4】。 ds_z3_config.json  {train_batch_size: auto,train_micro_batch_size_per_gpu: auto,gradient_accumulation_steps: auto,gradient_clipping: auto,zero_allow_untested_optimizer: true,fp16: {enabled: auto,loss_scale: 0,loss_scale_window: 1000,initial_scale_power: 16,hysteresis: 2,min_loss_scale: 1},bf16: {enabled: auto},zero_optimization: {stage: 3,overlap_comm: true,contiguous_gradients: true,sub_group_size: 1e9,reduce_bucket_size: auto,stage3_prefetch_bucket_size: auto,stage3_param_persistence_threshold: auto,stage3_max_live_parameters: 1e9,stage3_max_reuse_distance: 1e9,stage3_gather_16bit_weights_on_model_save: true} } 3.2.3 template配置 src/llamafactory/data/template.py glm4 _register_template(nameglm4,format_userStringFormatter(slots[|user|\n{{content}}|assistant|]),format_assistantStringFormatter(slots[\n{{content}}]),format_systemStringFormatter(slots[|system|\n{{content}}]),format_functionFunctionFormatter(slots[{{content}}], tool_formatglm4),format_observationStringFormatter(slots[|observation|\n{{content}}|assistant|]),format_toolsToolFormatter(tool_formatglm4),format_prefixEmptyFormatter(slots[[gMASK]sop]),stop_words[|user|, |observation|],efficient_eosTrue, ) 3.3 数据集 数据集路径/LLaMA-Factory/data 如果使用自己的数据集需要更新data/dataset_info.json 也就是首先将自己的数据集xxx.json放到data下然后注册到data/dataset_info.json 数据集格式可以参考data目录下的数据集比如alpaca_zh_demo.json 3.4 模型微调 9B模型至少需要4张卡全参微调的显存占用会暴涨原始参数大小的20倍左右。卡的数量一般选择2的n次方。 CUDA_VISIBLE_DEVICES0,1,4,5 HF_ENDPOINThttps://hf-mirror.com llamafactory-cli train examples/train_full/chatglm_full_sft.yaml 可以看到保存的checkpoint-500的内容 5. 参考材料 【1】https://github.com/hiyouga/LLaMA-Factory 【2】LLaMA Factory GLM4 微调最佳实践 【3】使用llama factory对语言模型微调 【4】大模型训练方法ZeRO及其三级模式介绍
http://www.dnsts.com.cn/news/142301.html

相关文章:

  • 网站开发运营维护方案建议文档做代理需要交钱吗
  • 手机上可以做网站网站集群建设合同
  • 广州网站建设流程图网站建设houxiaoer
  • 社交网站建设平台wordpress seo联接插件
  • 2021年php凉透了泉州关键词优化报价
  • 网站建设中山优化张掖市住房和城乡建设厅网站
  • 企业网站的特点360网站拦截做
  • asp.net做网站实例网站开发岗位分析
  • 400电话网络推广商城网站广州营销推广网站
  • 高端网站建设公司报价定边网站建设
  • 呼市做无痛人流z首大网站深圳市福田建设股份有限公司网站
  • 织梦图片网站源码排名优化方法
  • 宁波网站优化如何微信开放平台登录
  • 昆明微网站搭建哪家好手机软件怎么做
  • wordpress仿站容易被收录不网站开发可能遇到的问题
  • 做的网站空白了国外对于网站开发
  • 网站地图样式网页制作素材照片和文案
  • 营销类网站设计 要点学校网站代码
  • 中国建设银行官网站e路护航下载可信赖的赣州网站建设
  • seo企业网站优化做照片有那些网站
  • 有哪些网站可以做电子邀请函软件工程就业方向及薪资待遇
  • html建设网站app软件免费下载安装最新版
  • 进入网站wordpress配置广州网站建设 致茂
  • 单位网站建设要多少钱宿州网站制作建设
  • 上海嘉定网站.net网站与php网站
  • dede手机网站跳转网页浏览器下载安装
  • 公司网站非响应式模板装饰设计用什么软件
  • wordpress 音乐插件优化服务公司
  • 信息技术九年级上册网站咋做建立网站的相关信息
  • 企业网站要更新文章吗注册网站建设开发