Harvard transformer NLP 模型 openNMT 简介入门

项目网址:

OpenNMT - Open-Source Neural Machine Translation

logo:

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

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

​

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

​
  1. 环境搭建

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

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

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

执行下面命令可以解决

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

python 复制代码
 13 '''LL::
 14 URL = {
 15     "train": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/training.tar.gz",
 16     "valid": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/validation.tar.gz",
 17     "test": r"http://www.quest.dcs.shef.ac.uk/wmt16_files_mmt/mmt16_task1_test.tar.gz",
 18 }
 19
 20 MD5 = {
 21     "train": "20140d013d05dd9a72dfde46478663ba05737ce983f478f960c1123c6671be5e",
 22     "valid": "a7aa20e9ebd5ba5adce7909498b94410996040857154dab029851af3a866da8c",
 23     "test": "0681be16a532912288a91ddd573594fbdd57c0fbb81486eff7c55247e35326c2",
 24 }
 25 '''
 26 # TODO: Update URL to original once the server is back up (see https://github.com/pytorch/text/issues/1756)
 27 URL = {
 28     "train": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/training.tar.gz",
 29     "valid": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/validation.tar.gz",
 30     "test": r"https://raw.githubusercontent.com/neychev/small_DL_repo/master/datasets/Multi30k/mmt16_task1_test.tar.gz",
 31 }
 32
 33 MD5 = {
 34     "train": "20140d013d05dd9a72dfde46478663ba05737ce983f478f960c1123c6671be5e",
 35     "valid": "a7aa20e9ebd5ba5adce7909498b94410996040857154dab029851af3a866da8c",
 36     "test": "6d1ca1dba99e2c5dd54cae1226ff11c2551e6ce63527ebb072a1f70f72a5cd36",
 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

相关推荐
醒了就刷牙20 小时前
transformer用作分类任务
深度学习·分类·transformer
靴子学长1 天前
基于字节大模型的论文翻译(含免费源码)
人工智能·深度学习·nlp
deephub3 天前
LEC: 基于Transformer中间层隐藏状态的高效特征提取与内容安全分类方法
人工智能·深度学习·transformer·大语言模型·特征提取
宝贝儿好3 天前
【NLP】第七章:Transformer原理及实操
人工智能·深度学习·自然语言处理·transformer
Struart_R3 天前
CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer 论文解读
人工智能·深度学习·计算机视觉·transformer·视频生成
AI程序猿人3 天前
三种Transformer模型中的注意力机制介绍及Pytorch实现:从自注意力到因果自注意力
人工智能·pytorch·深度学习·自然语言处理·大模型·transformer·llms
lalahappy4 天前
Swin transformer 论文阅读记录 & 代码分析
论文阅读·深度学习·transformer
赵钰老师4 天前
遥感影像目标检测:从CNN(Faster-RCNN)到Transformer(DETR
pytorch·python·深度学习·目标检测·机器学习·cnn·transformer
通信仿真实验室4 天前
BERT模型入门(1)BERT的基本概念
人工智能·深度学习·自然语言处理·bert·transformer
西西弗Sisyphus4 天前
使用Gradio编写大模型ollama客户端 -界面版
lora·大模型·transformer·qwen2-vl