当前位置:   article > 正文

Harvard transformer NLP 模型 openNMT 简介入门_opennmt结构图

opennmt结构图

项目网址:

OpenNMT - Open-Source Neural Machine Translation

logo:

一,从应用的层面先跑通 Harvard transformer

GitHub - harvardnlp/annotated-transformer: An annotated implementation of the Transformer paper.

  1. git clone https://github.com/harvardnlp/annotated-transformer.git
  2. cd annotated-transformer/

1. 环境搭建

  1. conda create --name ilustrate_transformer_env python=3.9
  2. conda activate ilustrate_transformer_env
  3. pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

问题:TypeError: issubclass() arg 1 must be a class

原因: 这是由python中的后端包之一的兼容性问题引起的问题,包“pydantic”

执行下面命令可以解决

  1. python -m pip install -U pydantic spacy


 

会遇到下载不到数据的问题,因为有个网址废弃了:www.quest......

改成最新版本的torchtext的内容即可:

/home/hipper/anaconda3/envs/ilustrate_transformer_env/lib/python3.9/site-packages/torchtext/datasets/multi30k.py

  1.  13 '''LL::
  2.  14 URL = {
  3.  15     "train": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/training.tar.gz",
  4.  16     "valid": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/validation.tar.gz",
  5.  17     "test": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/mmt16_task1_test.tar.gz",
  6.  18 }
  7.  19
  8.  20 MD5 = {
  9.  21     "train": "20140d013d05dd9a72dfde46478663ba05737ce983f478f960c1123c6671be5e",
  10.  22     "valid": "a7aa20e9ebd5ba5adce7909498b94410996040857154dab029851af3a866da8c",
  11.  23     "test": "0681be16a532912288a91ddd573594fbdd57c0fbb81486eff7c55247e35326c2",
  12.  24 }
  13.  25 '''
  14.  26 # TODO: Update URL to original once the server is back up (see https://github.com/pytorch/text/issues/1756)
  15.  27 URL = {
  16.  28     "train": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/training.tar.gz",
  17.  29     "valid": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/validation.tar.gz",
  18.  30     "test": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/mmt16_task1_test.tar.gz",
  19.  31 }
  20.  32
  21.  33 MD5 = {
  22.  34     "train": "20140d013d05dd9a72dfde46478663ba05737ce983f478f960c1123c6671be5e",
  23.  35     "valid": "a7aa20e9ebd5ba5adce7909498b94410996040857154dab029851af3a866da8c",
  24.  36     "test": "6d1ca1dba99e2c5dd54cae1226ff11c2551e6ce63527ebb072a1f70f72a5cd36",
  25.  37 }

运行:

未完待续 ...

__________________________________________________

参考:

《The Annotated Transformer》翻译——注释和代码实现《Attention Is All You Need》_神洛华的博客-CSDN博客

图解transformer | The Illustrated Transformer_Ann's Blog的博客-CSDN博客

GitHub - harvardnlp/annotated-transformer: An annotated implementation of the Transformer paper.

OpenNMT - Open-Source Neural Machine Translation

flash attention 1,2:

Stanford CRFM

GitHub - Dao-AILab/flash-attention: Fast and memory-efficient exact attention

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/759644
推荐阅读
相关标签
  

闽ICP备14008679号