A machine learning project to predict how to complete a sentence
The prediction is done using an encoder-decoder model. The recurrent layer is a bidirectional GRU (Gated Recurrent Unit) in the encoder, and a normal GRU (of twice the size) in the decoder layer.
Loosely based on the Gmail smart compose function, and the Google AI blogs describing it (see references).
The following predictions were made by the model, and can be repeated by running the visualize script.
Input | Predicted sentence | |
---|---|---|
0 | Can you let me know | know if this works |
1 | thanks fo | r your email . |
2 | Sorry for the late | reply . |
3 | After careful consideration | we have decided |
4 | I would apprec | id we can find a solution soon . |
5 | I know that is a lot to take in | , so let me know if anything i ve said doesn t make sense . |
6 | Sorry it s been so long since my | last email . |
7 | Please keep | me posted . |
8 | Just a quic | k reminder that |
9 | i m sorry | hope we had a chance to chat at the convention . |
10 | I m afraid we | need to cancel our meeting . |
11 | What are y | me posted . |
12 | What exac | ly do you think ? |
13 | I hope you | had a great trip . |
14 | Could you please expl | ain what you are available |
15 | Sorry I couldn t be | of more help . |
The file structure can be found below. To run some predictions:
Install the requirements:
$ pip install -r requirements.txt
Set custom sentences in src\visualization\visualize.py
and run the visualization
$ python src/visualization/visualize.py
├── LICENSE
├── Makefile <- Makefile with commands like `make data` or `make train`
├── README.md <- The top-level README for developers using this project.
├── data
│ ├── external <- Data from third party sources.
│ ├── interim <- Intermediate data that has been transformed.
│ ├── processed <- The final, canonical data sets for modeling.
│ └── raw <- The original, immutable data dump.
│
├── docs <- A default Sphinx project; see sphinx-doc.org for details
│
├── models <- Trained and serialized models, model predictions, or model summaries
│
├── notebooks <- Jupyter notebooks. Naming convention is a number (for ordering),
│ the creator's initials, and a short `-` delimited description, e.g.
│ `1.0-jqp-initial-data-exploration`.
│
├── references <- Data dictionaries, manuals, and all other explanatory materials.
│
├── reports <- Generated analysis as HTML, PDF, LaTeX, etc.
│ └── figures <- Generated graphics and figures to be used in reporting
│
├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
│ generated with `pip freeze > requirements.txt`
│
├── setup.py <- makes project pip installable (pip install -e .) so src can be imported
├── src <- Source code for use in this project.
│ ├── __init__.py <- Makes src a Python module
│ │
│ ├── data <- Scripts to download or generate data
│ │ └── make_dataset.py
│ │
│ ├── features <- Scripts to turn raw data into features for modeling
│ │ └── build_features.py
│ │
│ ├── models <- Scripts to train models and then use trained models to make
│ │ │ predictions
│ │ ├── predict_model.py
│ │ └── train_model.py
│ │
│ └── visualization <- Scripts to create exploratory and results oriented visualizations
│ └── visualize.py
│
└── tox.ini <- tox file with settings for running tox; see tox.testrun.org
Project based on the cookiecutter data science project template. #cookiecutterdatascience