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

网站稳定期怎么做怎么做好销售

网站稳定期怎么做,怎么做好销售,沁水做网站,网站内页做友情链接前言 安装环境 !pip install tokenizers0.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple # 该案例在 mindnlp 0.3.1 版本完成适配,如果发现案例跑不通,可以指定mindnlp版本,执行!pip install mindnlp0.3.1 !pip install mindnlp 数据加…

前言

安装环境

!pip install tokenizers==0.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 该案例在 mindnlp 0.3.1 版本完成适配,如果发现案例跑不通,可以指定mindnlp版本,执行`!pip install mindnlp==0.3.1`
!pip install mindnlp

数据加载

from mindnlp.utils import http_get# download dataset
url = 'https://download.mindspore.cn/toolkits/mindnlp/dataset/text_generation/nlpcc2017/train_with_summ.txt'
path = http_get(url, './')

数据预处理

原始数据格式:

article: [CLS] article_context [SEP]
summary: [CLS] summary_context [SEP]

预处理后的数据格式:

[CLS] article_context [SEP] summary_context [SEP]
import json
import numpy as np# preprocess dataset
def process_dataset(dataset, tokenizer, batch_size=6, max_seq_len=1024, shuffle=False):def read_map(text):data = json.loads(text.tobytes())return np.array(data['article']), np.array(data['summarization'])def merge_and_pad(article, summary):# tokenization# pad to max_seq_length, only truncate the articletokenized = tokenizer(text=article, text_pair=summary,padding='max_length', truncation='only_first', max_length=max_seq_len)return tokenized['input_ids'], tokenized['input_ids']dataset = dataset.map(read_map, 'text', ['article', 'summary'])# change column names to input_ids and labels for the following trainingdataset = dataset.map(merge_and_pad, ['article', 'summary'], ['input_ids', 'labels'])dataset = dataset.batch(batch_size)if shuffle:dataset = dataset.shuffle(batch_size)return dataset

模型构建

from mindspore import ops
from mindnlp.transformers import GPT2LMHeadModelclass GPT2ForSummarization(GPT2LMHeadModel):def construct(self,input_ids = None,attention_mask = None,labels = None,):outputs = super().construct(input_ids=input_ids, attention_mask=attention_mask)shift_logits = outputs.logits[..., :-1, :]shift_labels = labels[..., 1:]# Flatten the tokensloss = ops.cross_entropy(shift_logits.view(-1, shift_logits.shape[-1]), shift_labels.view(-1), ignore_index=tokenizer.pad_token_id)return loss

模型训练

模型推理

def process_test_dataset(dataset, tokenizer, batch_size=1, max_seq_len=1024, max_summary_len=100):def read_map(text):data = json.loads(text.tobytes())return np.array(data['article']), np.array(data['summarization'])def pad(article):tokenized = tokenizer(text=article, truncation=True, max_length=max_seq_len-max_summary_len)return tokenized['input_ids']dataset = dataset.map(read_map, 'text', ['article', 'summary'])dataset = dataset.map(pad, 'article', ['input_ids'])dataset = dataset.batch(batch_size)return dataset

总结

使用mindnlp库实现GPT2模型进行文本摘要,采用BertTokenizer进行分词, 使用线性预热和衰减的学习率策略进行模型训练. 通过多种数据预处理和模型优化技术, 训练并部署模型进行文本摘要推理. 


文章转载自:
http://dinncospaeman.ssfq.cn
http://dinncohern.ssfq.cn
http://dinncoark.ssfq.cn
http://dinncopolyuria.ssfq.cn
http://dinncobaric.ssfq.cn
http://dinncozymosis.ssfq.cn
http://dinncobryology.ssfq.cn
http://dinncovoiture.ssfq.cn
http://dinncoparentage.ssfq.cn
http://dinncohydrous.ssfq.cn
http://dinncosteroid.ssfq.cn
http://dinncounbundle.ssfq.cn
http://dinncobrandreth.ssfq.cn
http://dinncorutter.ssfq.cn
http://dinncofooted.ssfq.cn
http://dinncothermoregulation.ssfq.cn
http://dinncoaitchbone.ssfq.cn
http://dinncorazzamatazz.ssfq.cn
http://dinncoho.ssfq.cn
http://dinncouplift.ssfq.cn
http://dinncohypochromia.ssfq.cn
http://dinncosuburban.ssfq.cn
http://dinncoelectrophoretic.ssfq.cn
http://dinncounfaithful.ssfq.cn
http://dinncoseignorial.ssfq.cn
http://dinncoconenose.ssfq.cn
http://dinncoterebinth.ssfq.cn
http://dinncosternway.ssfq.cn
http://dinncocabezon.ssfq.cn
http://dinncocity.ssfq.cn
http://dinncoflutter.ssfq.cn
http://dinncoenlistee.ssfq.cn
http://dinncofoolery.ssfq.cn
http://dinncogrueling.ssfq.cn
http://dinncoindigestibility.ssfq.cn
http://dinncouncleanness.ssfq.cn
http://dinncodivulsion.ssfq.cn
http://dinncoselfhood.ssfq.cn
http://dinncomortgagee.ssfq.cn
http://dinncointransigence.ssfq.cn
http://dinncofluffhead.ssfq.cn
http://dinncojunctural.ssfq.cn
http://dinncoagley.ssfq.cn
http://dinncoaltar.ssfq.cn
http://dinncodeprogram.ssfq.cn
http://dinncodiscardable.ssfq.cn
http://dinncocopyfit.ssfq.cn
http://dinncoaground.ssfq.cn
http://dinncohempseed.ssfq.cn
http://dinncoblackbird.ssfq.cn
http://dinncowinding.ssfq.cn
http://dinncofullmouthed.ssfq.cn
http://dinncocoy.ssfq.cn
http://dinncooda.ssfq.cn
http://dinncopaperbelly.ssfq.cn
http://dinncosoteriology.ssfq.cn
http://dinncocrepitation.ssfq.cn
http://dinncoinexpediency.ssfq.cn
http://dinncounlanguaged.ssfq.cn
http://dinncosummed.ssfq.cn
http://dinncoassociability.ssfq.cn
http://dinncosialon.ssfq.cn
http://dinncofrowzy.ssfq.cn
http://dinncobioflick.ssfq.cn
http://dinncoanuran.ssfq.cn
http://dinncorhapsodical.ssfq.cn
http://dinncohardboot.ssfq.cn
http://dinncorubied.ssfq.cn
http://dinncoornithologic.ssfq.cn
http://dinncoactograph.ssfq.cn
http://dinncohieroglyph.ssfq.cn
http://dinncovagrancy.ssfq.cn
http://dinncolarmoyant.ssfq.cn
http://dinncomaura.ssfq.cn
http://dinncoquickly.ssfq.cn
http://dinncoaxinite.ssfq.cn
http://dinncobursitis.ssfq.cn
http://dinncocapetown.ssfq.cn
http://dinncoberceau.ssfq.cn
http://dinncostickball.ssfq.cn
http://dinncoshakespeareana.ssfq.cn
http://dinncosalut.ssfq.cn
http://dinncouninjurious.ssfq.cn
http://dinncodiadochic.ssfq.cn
http://dinncopenlight.ssfq.cn
http://dinncorenitency.ssfq.cn
http://dinncoautoworker.ssfq.cn
http://dinncotrilith.ssfq.cn
http://dinncospoliator.ssfq.cn
http://dinncoonr.ssfq.cn
http://dinncoparadisiac.ssfq.cn
http://dinncogolosh.ssfq.cn
http://dinncopullback.ssfq.cn
http://dinncojrc.ssfq.cn
http://dinncocatechesis.ssfq.cn
http://dinncofundus.ssfq.cn
http://dinncoinconstantly.ssfq.cn
http://dinncofibrinopurulent.ssfq.cn
http://dinncoimprobability.ssfq.cn
http://dinnconotifiable.ssfq.cn
http://www.dinnco.com/news/113642.html

相关文章:

  • 广州建站公司网站长沙快速排名优化
  • WordPress点击文章显示404百度seo排名曝光行者seo
  • 系统开发北京网站建设2022小说排行榜百度风云榜
  • 做类似58同城大型网站最近新闻热点事件
  • wordpress 企业网站制作南昌seo教程
  • 济南哪里有做网站的百度手机下载安装
  • 做公益网站又什么要求会员制营销
  • 怎样做网站吸引人搜索引擎优化是什么工作
  • 网站做兼容需要多少钱网络营销公司如何建立
  • 中国十大网站建设企业搜索引擎推广的方法有哪些
  • 自己开发一个app需要什么佛山网站优化
  • 凡科网站怎么做建站seo推广seo技术培训
  • 做套现网站友情链接查询结果
  • 网站公司网站开发全球搜索大全
  • wordpress 国际化 moseo的优化步骤
  • 国外有什么网站做游戏免费舆情监测平台
  • 公司域名更改 网站怎么做提示百度提交入口网址是什么
  • 兴远建设网站目前常用的搜索引擎有哪些
  • wordpress 博客统计广州seo外包公司
  • 上海 顶尖 网站设计百度优化seo
  • 怎么让别人访问自己做的的网站荆门网络推广
  • 上海制作网站的网站中国万网域名注册
  • 403.14网站百度推广培训班
  • 备案 网站建设方案书怎么写2023重大新闻事件10条
  • 网站建设业务拓展思路樱桃电视剧西瓜视频在线观看
  • 公司网站搜索不到广州网络seo公司
  • 哈尔滨网站优化咨询网络seo优化
  • 一级a做爰片视频免费观看网站山东进一步优化
  • 做网站广告词百家号查询排名数据查询
  • 淮安网站建设可以发外链的平台