attention_is_all_you_need

我要开发同款
匿名用户2021年11月17日
211阅读

技术信息

授权协议
BSD-3-Clause License

作品详情

Trasformer-AttetioIsAllYouNeed

Chaier-basedPythoimplemetatioofTrasformer,aattetio-basedseq2seqmodelwithoutcovolutioadrecurrece.Ifyouwattoseethearchitecture,pleaseseeet.py.

See"AttetioIsAllYouNeed",AshishVaswai,NoamShazeer,NikiParmar,JakobUszkoreit,LlioJoes,AidaN.Gomez,LukaszKaiser,IlliaPolosukhi,arxiv,2017.

Thisrepositoryispartlyderivedfrommycovolutioalseq2seqrepo,whichisalsoderivedfromChaier'sofficialseq2seqexample.

RequiremetPytho3.6.0+Chaier2.0.0+umpy1.12.1+cupy1.0.0+(ifusiggpu)ltkprogressbar(Youcaistallallthroughpip)adtheirdepedeciesPrepareDataset

Youcauseayparallelcorpus.Forexample,ru

shdowload_wmt.sh

whichdowloadsaddecompressestraiigdatasetaddevelopmetdatasetfromWMT/europalitoyourcurretdirectory.Thesefilesadtheirpathsaresetitraiigscripttrai.pyasdefault.

HowtoRuPYTHONIOENCODING=utf-8pytho-utrai.py-g=0-iDATA_DIR-oSAVE_DIR

Durigtraiig,logsforloss,perplexity,wordaccuracyadtimearepritedatacertaiiterval,iadditiotovalidatiotests(perplexityadBLEUforgeeratio)everyhalfepoch.Adalso,geeratiotestisperformedadpritedforcheckigtraiigprogress.

Argumets

Someofthemisasfollows:

-g:yourgpuid.Ifcpu,set-1.-iDATA_DIR,-sSOURCE,-tTARGET,-svalidSVALID,-tvalidTVALID:DATA_DIRdirectoryeedstoicludeapairoftraiigdatasetSOURCEadTARGETwithapairofvalidatiodatasetSVALIDadTVALID.Eachpairshouldbeparallellcorpuswithlie-by-liesetecealigmet.-oSAVE_DIR:JSONlogreportfileadamodelsapshotwillbesavediSAVE_DIRdirectory(ifitdoesotexist,itwillbeautomaticallymade).-e:maxepochsoftraiigcorpus.-b:miibatchsize.-u:sizeofuitsadwordembeddigs.-l:umberoflayersiboththeecoderadthedecoder.--source-vocab:maxsizeofvocabularysetofsourcelaguage--target-vocab:maxsizeofvocabularysetoftargetlaguage

Pleaseseetheothersbypythotrai.py-h.

Note

Thisrepositorydoesotaimforcompletevalidatioofresultsithepaper,soIhaveoteagerlycofirmedvalidityofperformace.But,Iexpectmyimplemetatioisalmostcompatiblewithamodeldescribedithepaper.SomediffereceswhereIamawareareasfollows:

Optimizatio/traiigstrategy.Detailediformatioaboutbatchsize,parameteriitializatio,etc.isuclearithepaper.Additioally,thelearigrateproposedithepapermayworkolywithalargebatchsize(e.g.4000)fordeeplayerets.Ichagedwarmup_stepto32000from4000,thoughthereisroomforimprovemet.Ialsochagedreluitoleakyreluifeedforwardetlayersforeasygradietpropagatio.Vocabularyset,dataset,preprocessigadevaluatio.Thisrepousesacommoword-basedtokeizatio,althoughthepaperusesbyte-pairecodig.Sizeoftokesetalsodiffers.Evaluatio(validatio)islittleufairadicompatiblewithoeithepaper,e.g.,evevalidatiosetreplacesukowwordstoasigle"uk"toke.BeamsearchisuusediBLEUcalculatio.Modelsize.Thesettigofamodelithisrepoisoeof"basemodel"ithepaper,althoughyoucamodifysomeliesforusig"bigmodel".Thiscodefollowssomesettigsuseditesor2tesorrepository,whichicludesaTrasformermodel.Forexample,positioalecodiguseditherepositoryseemstodifferfromoeithepaper.Thiscodefollowstheformeroe.

功能介绍

Transformer - Attention Is All You Need Chainer-based Python implementation of Transformer, an at...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论