Industrial-grade implementation of seq2seq algorithm based on Pytorch, integrated beam search algorithm.
Project description
seq2seq
Industrial-grade implementation of seq2seq algorithm based on Pytorch, integrated beam search algorithm.
seq2seq is based on other excellent open source projects, this project has the following highlights:
- easy to train, predict and deploy;
- lightweight implementation;
- multitasking support (including dialogue generation and machine translation).
Model description
- Encoder: Bidirectional GRU
- Decoder: GRU with Attention Mechanism
- Attention: Neural Machine Translation by Jointly Learning to Align and Translate
Install
seq2seq is dependent on PyTorch. Two ways to install:
Install seq2seq from Pypi:
pip install seq2seq-pytorch
Install seq2seq from the Github source:
git clone https://github.com/Chiang97912/seq2seq.git
cd seq2seq
python setup.py install
Usage
Train
from seq2seq.model import Seq2Seq
sources = ['...']
targets = ['...']
model = Seq2Seq('seq2seq-model', embed_size=256, hidden_size=512, lang4src='en', lang4tgt='en', device='cuda:0')
model.fit(sources, targets, epochs=20, batch_size=64)
Test
from seq2seq.model import Seq2Seq
model = Seq2Seq('seq2seq-model')
outputs = model.generate('...', beam_size=3, method='greedy')
print(outputs)
Dependencies
python
version 3.6pyTorch
version 1.9.0torchtext
version 0.3.1numpy
version 1.19.5nltk
version 3.5jieba
version 0.42.1
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
seq2seq-pytorch-0.1.1.tar.gz
(6.9 kB
view hashes)
Built Distribution
Close
Hashes for seq2seq_pytorch-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b632d800be1a8e83e7601cc0013b8a86ef2c81319b40f1577685fd7b9945a4a |
|
MD5 | ae18bcc38b25cee7d467fd08115513df |
|
BLAKE2b-256 | 11ceff0e3f5ddcb7a52a9394f1f929094dd363d3a88f7ffce8685e983c70efd3 |