rtlee9 / recipe-summarization

Sequence to sequence recipe summarization
MIT License
136 stars 75 forks source link

Recipe summarization

This repo implements a sequence-to-sequence encoder-decoder using Keras to summarize recipe instructions by predicting a recipe title. This code is based on Siraj Raval's How to Make a Text Summarizer; it won the coding challenge for that week's video, and was featured in the following week's video.

youtube

This repo has been updated since then, so please check out tag v1.0.0 to view the version associated with the coding challenge. Lastly, note that this repo is not being actively maintained -- I will do my best to respond to any issues opened but make no guarantees.

New: If you're looking to serve your trained model and make its predictions accessible to others, I'd recommend looking into ServeIt, an open source library that lets you serve model predictions from a RESTful API using your favorite Python ML library in as little as one line of code. This repository includes an example recipe summarizer server in src/server.py for your reference.

Data

I scraped 125,000 recipes from various websites for training (additional details can be found here). Each recipe consists of:

The model was fitted on the recipe ingredients, instructions and title. Ingredients were concatenated in their original order to the instructions. Recipe images were not used for this model.

Training

This model was trained for ~6 hours on an nVidia Tesla K80. Training consisted of several training iterations, in which I successively decremented the learning rate and incremented the ratio of flip augmentations.

Sampled outputs

Below are a few cherry-picked in-sample predictions from the model:

Example 1:

Example 2:

Example 3:

Usage (Python 3.6)

Next steps

Aside from tuning hyperparameters, there are a number of ways to potentially improve this model:

Buy me a coffee

Please consider buying me a coffee if you like my work:

Buy Me A Coffee