Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pavanchhatpar/copynet-tf
CopyNet (Copy Mechanism in Seq2Seq) implementation with TensorFlow 2
https://github.com/pavanchhatpar/copynet-tf
copy-mechanism copynet seq2seq tensorflow-tutorial tensorflow2 tf-keras
Last synced: 3 months ago
JSON representation
CopyNet (Copy Mechanism in Seq2Seq) implementation with TensorFlow 2
- Host: GitHub
- URL: https://github.com/pavanchhatpar/copynet-tf
- Owner: pavanchhatpar
- Created: 2020-04-30T11:52:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-21T21:18:49.000Z (about 2 years ago)
- Last Synced: 2024-09-27T21:21:52.810Z (3 months ago)
- Topics: copy-mechanism, copynet, seq2seq, tensorflow-tutorial, tensorflow2, tf-keras
- Language: Python
- Size: 105 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CopyNet implementation with TensorFlow 2
- Incorporating Copying Mechanism in Sequence-to-Sequence Learning
- Uses `TensorFlow 2.0` and above APIs with `tf.keras` too
- Adapted from AllenNLP's PyTorch implementation, their blog referenced
below was very helpful to understand the math from an implementation
perspective![Python package](https://github.com/pavanchhatpar/copynet-tf/workflows/Python%20package/badge.svg)
![Upload Python Package](https://github.com/pavanchhatpar/copynet-tf/workflows/Upload%20Python%20Package/badge.svg)## Install package
### Using pip
```bash
pip install copynet-tf
```### Compile from source
```bash
python -m pip install --upgrade pip
pip install setuptools wheel
python setup.py sdist bdist_wheel
```## Examples
### Abstract usage
```python
...
import MyEncoder
from copynet_tf import GRUDecoder...
class MyModel(tf.keras.Model):
...
def call(self, X, y, training):
source_token_ids, source2target_ids = X
target_token_ids, target2source_ids = yenc_output, enc_final_output, mask = self.encoder(X, y, training)
output_dict = self.decoder(
source_token_ids, source2target_ids, mask,
target_token_ids, target2source_ids, training)
return output_dict...
```
### Concrete examples
Find concrete examples inside [examples](./examples) folder of the repo## References
- Incorporating Copying Mechanism in Sequence-to-Sequence Learning: ([paper](https://arxiv.org/abs/1603.06393))
- AllenNLP implementation: ([blog](https://medium.com/@epwalsh10/incorporating-a-copy-mechanism-into-sequence-to-sequence-models-40917280b89d)) ([code](https://github.com/epwalsh/nlp-models))
- BLEU score metric: ([code](https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py))