Esme set out to find how AI could be used to generate a pie recipe.
Today, Machine Learning (ML) is a readily available tool available for SME’s to use; from Amazon’s SageMaker to Google’s Machine Learning AI HUB, any company with an organised dataset and a little IT know-how can leverage the power of these models to gain insight into their business.
The insight gained from ML can offer businesses a competitive advantage over their competitors. As the saying goes “knowledge is power, and time is money” - a business that can gain knowledge while saving time, could really increase chances of succeeding where others fail.
We teamed up with one of our customers to show how AI could be used. Part of the exercise was to see if and how AI could bridge the gap between computers and the real world, by using it to create new recipes and products that can be brought to market.
Founder, Joanna Hunter, became excited at the possibility of saving time and creating new pie recipes with AI. Joanna was intrigued to see if AI could produce a recipe that would taste any good, and so were we!
A lot of new technology is being labelled as being “AI” but in many ways it is not. It is easier if we think of current AI as Machine Learning or Machine Intelligence.
Machine Learning (ML) stems from a computer being taught about a task and the computer being able to learn said task. There are many ways to teach a computer or machine (too many to list here). However, to help understand how we landed on the end result of an AI pie, we’ll go into a brief explanation of Supervised and Unsupervised Machine Learning.
Supervised Machine Learning algorithms are trained by a human using “training data sets”. The training data will contain examples of labelled or categorised inputs and outputs. In short, a human will tell the model what is and what isn’t accepted.
Despite being clever in its ability to provide an insight into data, Supervised ML does not come to the conclusion or desired result without being told what the end result should look like.
Unsupervised Machine Learning algorithms use a dataset that contains solely inputs. The Machine Learning algorithms will then find a pattern or structure in the data - data which has no labelling or classification. Unlike supervised ML, unsupervised ML does not learn from human input; instead, it looks for common patterns in the data and then uses this to check against each new piece of data.
As part of our investigation, we wanted to see how unsupervised machine learning algorithms, which is as close to AI as we can get, could be used to create a recipe without being explicitly told what to make or how to make it.
In order to achieve this, we decided to use an advanced text generating model from the Open AI GPT-2, which is composed of publicly available, synthetic text.
GPT-2 is essentially an unsupervised machine learning algorithm language model developed by the capped-profit, Elon Musk founded AI research company, Open AI. Open AI aims to promote and develop friendly Artificial Intelligence in a way which aims to benefit humanity as a whole.
Our aim was to use this model to see if it could produce useful insights into product development.
GPT-2 is a large language model, released by Open AI; the model was trained to predict the next word in 40GB of Internet text, based off an initial set of seed text.
Open AI have released a research model based on a 345M (million) character model. As part of our pie project, we provided this model with 1million characters of UK pie recipes and instructional data, which totalled to roughly 1.5GB of data.
From the very first set of outputted data it was clear that GPT-2 is capable of delivering useable results in a relatively short time frame.
Below is a brief excerpt from our initial set of outputted results, constructed entirely by the model with no training on what a recipe should look like. Whilst, at a first glance, the recipe looks viable, we get that you don’t have to be an expert to know that putting a tomato, prawn and parmesan through a ricer to make a sticky paste will probably not win Masterchef!
From our first-generation output:
Filo-topped fish pie
100g butter, 1 onion, 1 fennel bulb, 1 garlic clove, finely chopped, 1 tbsp tomato purée, 1 tbsp honey, 400g can chopped tomato, 450g can mixed fish, 200g cooked prawns, 100g parmesan,
Heat 25g of the butter in a pan until foaming. Add the onion and fennel, and cook gently for about 10 mins until very tender. Stir in the garlic, cook for 1 min, then add the tomato purée and cook for 1 min more. Tip in the honey, heat and simmer for a few mins until the liquid has reduced by half. Add the tomatoes and simmer for a few mins more until the sauce has thickened and reduced a little. Remove the heat from the pan. Add the fish, prawns and any juices, then stir in the sauce. Heat oven to 180C/160C fan/gas 4. Tip the mixture into a large rectangular dish. Pass through a ricer to leave a sticky paste, then carefully pour over the fish. Bake for 50 mins.
Each time we asked the machine learning algorithm to generate recipes; we would receive around 30 generated recipes. Some of these recipes showed signs of knowledge; for example, on one attempt the machine created a gluten free pie with gluten free filling. Whilst this sounds simple, the machine actually understood that a gluten-free pie requires a gluten free filling - results which we think could come close to passing the Winograd Schema AI test.
For a human to create a gluten free pie, they’d have to learn what gluten is and understand what ingredients are constituted as gluten free. This level of understanding is not easily achieved unless you have experience and interest in gluten free products. In a similar way, the machine was able to gather knowledge of gluten free recipes from our seed data and translate this into the creation of a new, gluten free pie.
Having seen the ability of AI in the world of pie creation, it is apparent that the advantages available to businesses, in general, are impressive.
While some of the initial recipes from our GPT-2 powered AI pie maker contained a host of weird and wonderful suggestions, the recipes produced after the adjusting of some of our GPT-2 parameters, we hit the sweet spot and obtained a set of recipes of perfect, pie-worthy, results.
All of the recipes were shared with Piglets Pantry who refined and narrowed them down to:
The final decision, some would argue the most important one, of recipe selection lay with a human and the aptly named Chief Food Lover, Joanna Hunter of Piglets Pantry.
The AI created a unique twist on a vegetarian pie by introducing spiralised vegetables - something Piglets Pantry had never thought of using before! Here a little creative licence was required as the AI or Unsupervised ML is labelling the spinach and tomato as “Salad”.
Veggie spiral pie with spiced tomato sauce & chopped salad
1 tbsp cumin seeds, 1 tbsp coriander seeds, 2 tbsp olive or rapeseed oil, 1 large onion, 250g carrots, 500g spinach, 280g peppers, 5 fresh tomatoes, 250g frozen leaf spinach, 250g vegetable shortcrust pastry, 300g courgette, 2 egg yolks, 1 tsp each ground cumin, 2 tbsp dried mango, 100g hot red pepper (chopped), 1½ kg floury potato, 100g butter, 200g frozen peas,
For the spinach, tip the spinach into a saucepan with 1 tbsp of the oil, then cook until wilted. Leave to cool, then squeeze out as much liquid as possible. Tip into a large heatproof bowl, then stir in the cumin, coriander seeds, olive oil, half the spinach and 250g cooked spinach. Season well, then set aside. For the potato, boil or simmer for 6-8 mins until tender. Drain, then tip back into pan. Fry in the remaining oil until golden. Stir in the chopped pepper, then leave to cool. Roll out half the pastry to a shape about 5cm/2in larger
Joanna explained to us that many of her pie sales fall under the vegetarian or vegan category due to the increase in people opting for plant-based pie fillings and not poultry. Based in Sussex, Jo has become a key player of innovation within the community, therefore using spiralised vegetables within her pie fillings has enabled her to offer up a vast array of vegetable options which suit the increasing demand for meat-free delicacies.
Confident that we had succeeded in demonstrating the ability for AI to create a pie recipe, we feel Piglets Pantry has gained a new perspective about the ways in which they can approach product development.
The proof of AI in business is in the “Pie” and it tastes good!