招商加盟网站的图应该怎么做网站收缩广告

news/2025/10/6 18:15:47/文章来源:
招商加盟网站的图应该怎么做,网站收缩广告,做做网站已更新,全国中高风险地区最新名单大模型LORA微调总结 大模型微调总结模型加载使用deepspeed不使用deepspeed使用lora加载分词器 数据加载构建source和target构建input_ids和labels标签补齐构建训练器LORA模型推理模型加载多batch推理构建lora微调推理合并模型权重 大模型微调总结 模型加载 使用deepspeed mod… 大模型LORA微调总结 大模型微调总结模型加载使用deepspeed不使用deepspeed使用lora加载分词器 数据加载构建source和target构建input_ids和labels标签补齐构建训练器LORA模型推理模型加载多batch推理构建lora微调推理合并模型权重 大模型微调总结 模型加载 使用deepspeed model transformers.AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path,cache_dirtraining_args.cache_dir,torch_dtypeauto,# if model_args.model_name_or_path.find(falcon) ! -1 else Falsetrust_remote_codeTrue)不使用deepspeed model transformers.AutoModelForCausalLM.from_pretrained(model_args.model_name_or_path,cache_dirtraining_args.cache_dir,device_mapauto,torch_dtypeauto,# if model_args.model_name_or_path.find(falcon) ! -1 else Falsetrust_remote_codeTrue) 使用lora from peft import LoraConfig, get_peft_model LORA_R 32 # LORA_ALPHA 16 LORA_DROPOUT 0.05 TARGET_MODULES [ o_proj,gate_proj, down_proj, up_proj ]config LoraConfig( rLORA_R, # lora_alphaLORA_ALPHA, target_modulesTARGET_MODULES, lora_dropoutLORA_DROPOUT, biasnone, task_typeCAUSAL_LM, #加载配置 model get_peft_model(model, config) #打印训练参数比例 model.print_trainable_parameters()加载分词器 tokenizer transformers.AutoTokenizer.from_pretrained(model_args.model_name_or_path, trust_remote_codeTrue)数据加载 通过Hugging Face的dateset库进行加载数据 使用dateset可以轻松加载数据样例如下所示 from datasets import load_dataset dataset load_dataset(csv, data_filesmy_file.csv) dataset load_dataset(csv, data_files[my_file_1.csv, my_file_2.csv, my_file_3.csv]) dataset load_dataset(csv, data_files{train:[my_train_file_1.csv,my_train_file_2.csv],test: my_test_file.csv})我们可以按下面方式加载数据 def load_dataset_from_own(data_path: Optional[str] None,cache_dir: Optional[str] cache_data) - Dataset:all_file_list [a.json,b.json,c.json]data_files {train: all_file_list}extension all_file_list[0].split(.)[-1]datasets load_dataset(extension,data_filesdata_files,cache_dircache_dir,)[train]return datasets构建source和target 构建prompt PROMPT_DICT {prompt_input: (Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:),prompt_no_input: (Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{instruction}\n\n### Response:), }根据prompt构建source sources [prompt_input.format_map({instruction: ins_data[i], input: input_data[i]}) if input_data[i] ! else prompt_no_input.format_map({instruction: ins_data[i]})for i in range(len_)] #限制长度 sources [i[:data_args.source_length] for i in sources]根据prompt构建targets targets [f{example[:data_args.target_length-1]}{tokenizer.eos_token} for example in output]构建input_ids和labels 输入需要构建的text,输出构建好的ids def _tokenize_fn(strings: Sequence[str], tokenizer: transformers.PreTrainedTokenizer) - Dict:Tokenize a list of strings.tokenized_list [tokenizer(text,return_tensorspt,paddinglongest,max_lengthtokenizer.model_max_length,truncationTrue,)for text in strings]#获得idsinput_ids labels [tokenized.input_ids[0]for tokenized in tokenized_list]#终止符设置ne_pad_token_id IGNORE_INDEX if tokenizer.pad_token_id is None else tokenizer.pad_token_id#统计长度input_ids_lens labels_lens [tokenized.input_ids.ne(ne_pad_token_id).sum().item() for tokenized in tokenized_list]return dict(input_idsinput_ids,labelslabels,input_ids_lensinput_ids_lens,labels_lenslabels_lens,)构建input_ids 和label examples [s t for s, t in zip(sources, targets)] #问题答案、问题 examples_tokenized, sources_tokenized [_tokenize_fn(strings, tokenizer) for strings in (examples, sources)] input_ids examples_tokenized[input_ids] labels copy.deepcopy(input_ids) #构建labels for label, source_len in zip(labels, sources_tokenized[input_ids_lens]):label[:source_len] IGNORE_INDEX标签补齐 在动态batching中我们需要一个data collator完成padding。这里不适用DataCollatorWithPadding来进行补齐操作因为这个函数仅对输入的键包括input_ids, attention_mask, token_type_ids进行补齐不会对labels进行补齐操作。还有在对labels进行补齐操作时使用的是-100而不是分词器的pad_token这么做到的目的是在计算损失函数的时候忽略掉这些padding token。 data_collator DataCollatorForSeq2Seq(tokenizertokenizer, modelmodel, label_pad_token_idIGNORE_INDEX)构建训练器 from transformers import DataCollatorForSeq2Seq, Trainer trainer Trainer(modelmodel,tokenizertokenizer,argstraining_args,train_datasettrain_dataset,eval_datasetNone,data_collatordata_collator) trainer.train() trainer.save_state() trainer.save_model(output_dirtraining_args.output_dir)LORA模型推理 模型加载 base_model_name_or_path internlm-7b lora_model_name_or_path checkpoint-9695model AutoModelForCausalLM.from_pretrained(base_model_name_or_path,torch_dtypeauto,# device_mapauto,# if model_args.model_name_or_path.find(falcon) ! -1 else Falsetrust_remote_codeTrue, ).cuda(0)model PeftModel.from_pretrained(model, model_idlora_model_name_or_path) model.eval() print(ok)tokenizer AutoTokenizer.from_pretrained(base_model_name_or_path, trust_remote_codeTrue, padding_sideleft )多batch推理构建 def batch_generate_data(text_input: List[str], use_train_model: bool True, temp: float 0.7 ):text_input_format [generate_input(i) for i in text_input]batch_inputs tokenizer.batch_encode_plus(text_input_format, paddinglongest, return_tensorspt)batch_inputs[input_ids] batch_inputs[input_ids].cuda()batch_inputs[attention_mask] batch_inputs[attention_mask].cuda()if use_train_model:# with model.disable_adapter():outputs model.generate(**batch_inputs,max_new_tokens256,do_sampleTrue,temperaturetemp,top_p0.8,)else:with model.disable_adapter():outputs model.generate(**batch_inputs,max_new_tokens256,do_sampleTrue,temperaturetemp,top_p0.8,)outputs tokenizer.batch_decode(outputs.cpu()[:, batch_inputs[input_ids].shape[-1] :],skip_special_tokensTrue,)return outputslora微调推理 text_input [工作压力太大怎么办\n] * 32 # lora 训练结果 batch_generate_data(text_input, use_train_modelTrue, temp0.8) # 原来的模型 batch_generate_data(text_input, use_train_modelFalse, temp0.8)合并模型权重 model model.merge_and_unload() model.save_pretrained(internlm-7b-lml) tokenizer.save_pretrained(internlm-7b-lml)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/929587.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

营销单页网站制作建设 互动 网站 模式

看起来你正在使用教程,但是你发布的内容并不完整,这使得你很难看到你的案例发生了什么。在我会仔细检查你的密码。如果看起来正确,请检查日志输出。在日志应该如下所示:[ ... Scrapy log here ... ]2016-09-19 12:09:27 [scrapy.c…

UV使用

安装UV 已有python环境,直接通过pip安装: pip install uv或者通过命令来运行: # windows环境,在powershell窗口执行: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex&…

自己做的网站被举报违反广告法潍坊定制网站搭建

介绍多态性是为不同的基础形式(例如,数据类型或类)利用同一接口的能力。这允许函数在不同时间使用不同类型的实体。对于Python中的面向对象编程,这意味着可以用与属于特定类的特定对象相同的方式来使用它,就好像它是属于不同类的不同对象一样…

卖家如何做阿里巴巴国际网站设计logo网站免费南蒲四特

1.1 工作中心的定义 工作中心是用于生产产品的生产资源,包括机器、人和设备,是各种生产或能力加工单元的总称。工作中心属于能力的范畴即计划的范畴,而不属于固定资产或者设备管理的范畴。一个工作中心可以是一台设备、一组功能相同的…

CT5120 Intro to Natural Lang. Processing Lab # 4. Text Classification

CT5120 Intro to Natural Lang. Processing Lab # 4. Text Classification# 4. Text Classification## 4.0 Learning Objectives * Conduct exploratory data analysis (EDA)* Preprocess text* Feature extraction* T…

合肥光束网站建设网站页面架构怎么写

目录 1 概述 2 数学模型 2.1 问题表述 2.2 DG的最佳位置和容量(解析法) 2.3 使用 GA 进行最佳功率因数确定和 DG 分配 3 仿真结果与讨论 3.1 33 节点测试配电系统的仿真 3.2 69 节点测试配电系统仿真 4 结论 1 概述 为了使系统网损达到最低值&a…

西安网站建设设计的好公司排名做网站的收钱不管了

文章目录 Lookup Join(维表 Join) Lookup Join(维表 Join) Lookup Join 定义(支持 Batch\Streaming):Lookup Join 其实就是维表 Join,比如拿离线数仓来说,常常会有用户画像,设备画像等数据,而对应到实时数仓场景中,这种实时获取外部缓存的 Join 就叫做维表 Join。…

自建网站需要哪些技术网站空间容量

C Primer(第5版) 练习 10.24 练习 10.24 给定一个string,使用bind和check_size在一个int的vector中查找第一个大于string长度的值。。 环境:Linux Ubuntu(云服务器) 工具:vim 代码块 /*****…

网络科技公司网站首页说一说网站建设的含义

送给大家一句话: 世界在旋转,我们跌跌撞撞前进,这就够了 —— 阿贝尔 加缪 vector问题解决 1 前言2 迭代器区间拷贝3 迭代器失效问题4 memcpy拷贝问题 1 前言 我们之前实现了手搓vector,但是当时依然有些问题没有解决&#xff…

动手实验——mybatis generator

前言 边学边做中 mapper的用处是和数据库交互,具体的行为找了一个mapper文件,让chatgpt讲解了一下,如下: 首先是方法表 | 方法 | 功能 | 是否常用 | | -----------------------…

迅速了解GO+ElasticSearch

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

学生管理系统面向对象分析报告

学生管理系统面向对象分析报告 目录1. 案例中哪里体现出了封装性及其好处? 2. 案例中的setter/getter模式与封装性? 3. 案例中某些类的toString()方法? 4. 案例中几个常用方法解析。 5. 案例中的面向对象设计 5.1 尝…

荷兰青少年通过Telegram被招募,涉嫌参与俄罗斯支持的黑客活动

两名17岁荷兰青少年通过Telegram被招募,涉嫌为亲俄黑客从事间谍活动。他们使用Wi-Fi嗅探器在欧盟机构总部和使馆周边进行网络测绘,目前一人被拘留,一人被软禁。案件凸显国家支持黑客利用未成年人作为"可抛弃代…

网站推广策划方案毕业设计免费建立网站有必要吗

一个master可以拥有多个slave,一个slave又可以拥有多个slave,如此下去,形成了强大的多级服务器集群架构 比如,将ip为192.168.1.10的机器作为主服务器,将ip为192.168.1.11的机器作为从服务器 说明:ip可以换为…

网站开发部门工资入什么科目营销一体化营销平台

org.springframework.util.StringUtils 1、字符串判断工具 // 判断字符串是否为 null,或 ""。注意,包含空白符的字符串为非空 boolean isEmpty(Object str) // 判断字符串是否是以指定内容结束。忽略大小写 boolean endsWithIgnoreCase…

Moscow International Workshops 2017. Day 4. Lviv NU Contest, GP of Ukraine

Preface 国庆本以为空的一批结果忙的飞起,好不容易抽时间凑到三个人,结果被 Div2 小登们按在地上摩擦。B. Card Game 签到,暴力枚举约数即可 #include<cstdio> #include<iostream> #include<map>…

网站开发有哪些技术wordpress新建音乐界面

转载自 ClassLoader 详解及用途 ClassLoader主要对类的请求提供服务&#xff0c;当JVM需要某类时&#xff0c;它根据名称向ClassLoader要求这个类&#xff0c;然后由ClassLoader返回这个类的class对象。 1.1 几个相关概念ClassLoader负责载入系统的所有Resources&#xff08;…

提供手机自适应网站土木工程网官网登录

Hadoop 1、 Hadoop的介绍 Hadoop最早起源于Nutch。Nutch的设计目标是构建一个大型的全网搜索引擎&#xff0c;包括网页抓取、索引、查询等功能&#xff0c;但随着抓取网页数量的增加&#xff0c;遇到了严重的可扩展性问题——如何解决数十亿网页的存储和索引问题。2003年、20…

云原生架构的演进与落地:重塑企业 IT 的核心能力 - 实践

云原生架构的演进与落地:重塑企业 IT 的核心能力 - 实践2025-10-06 17:49 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important;…

小代码使用npm包的方法

小代码使用npm包的方法pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", &quo…