Code Monkey home page Code Monkey logo

transformertranslation's Introduction

A Transformer Framework Based Translation Task

一个基于Transformer网络结构的文本翻译模型

论文Attention Is All You Need 基于PyTorch的实现

1. 环境准备

  • Python==3.x
  • PyTorch==1.5.0
  • torchtext==0.6.0
  • pip install de_core_news_sm-3.0.0.tar.gz
  • pip install en_core_web_sm-3.0.0.tar.gz

2. 使用方法

2.1 训练

直接执行如下命令即可进行模型训练:

python train.py

训练过程:

Epoch: 2, Train loss: 5.685, Train acc: 0.240947
Epoch: 2, Train loss: 5.668, Train acc: 0.241493
Epoch: 2, Train loss: 5.714, Train acc: 0.224682
Epoch: 2, Train loss: 5.660, Train acc: 0.235888
Epoch: 2, Train loss: 5.584, Train acc: 0.242052
Epoch: 2, Train loss: 5.611, Train acc: 0.243428

学习率变化:

2.2 预测(inference)

直接运行如下命令即可:

python translate.py

示例结果:

德语Eine Gruppe von Menschen steht vor einem Iglu.
翻译A group of people standing in fraon of an igloo .
英语A group of people are facing an igloo.
=========
德语Ein Mann in einem blauen Hemd steht auf einer Leiter und putzt ein Fenster.
翻译A man in a blue shirt is standing on a ladder cleaning a window.
英语A man in a blue shirt is standing on a ladder cleaning a window.

3. 结果

bleu评测结果

val test_2016_flickr

transformertranslation's People

Contributors

moon-hotel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.