Every wine merchant should have an AI Wine Sommelier

Create an AI enhanced wine recommendation engine, with RDFox

Felicity Mulford
Jul 22, 2020 · 9 min read

Wine Sommeliers at upmarket restaurants provide in-depth knowledge on flavour, notes and the perfect food pairing. Online wine merchants could provide a similar service to their customers with new AI technology. Imagine an online AI Wine Sommelier to help you pick out the perfect bottle…

Searching for a great bottle of wine online should be fairly straightforward, but it can be disappointing when the ones you love are out of stock, or simply out of your budget. In these situations, the ‘next best’ wines are recommended, but flavours can range widely, even within a region or grape variety. This can leave the customer disappointed if the alternative recommendations don’t quite meet their expectations.

As a result, buying wine often feels like a gamble. The 1–5 star rating system doesn’t tell us anything about the properties of the wine, and reviews are subjective.

This article will show how wine recommendations can be based on flavours, notes, food pairings and cost using RDFox, a high-performance knowledge graph and semantic reasoning engine. It will also show how this approach enables customers to select new wines without compromising on flavour, or having to hire an in-house sommelier.


Knowledge graphs overcome the flexibility and speed limitations of relational databases, by allowing data points to be encoded as richly connected entities. Data is stored in triples, which contain nodes (data points) and edges (relationships).

This image is a graph representation of the wine Lupi e Sirene Riserva 2013. The representation demonstrates the various characteristics of the wine, including: flavour votes, pairings, ratings and region.

RDFox console image showing the characteristics of a bottle of Lupi e Sirene Riserva 2013

The data

Vivino Website information

As Vivino’s website allows any wine critic to cast their vote, there is not a uniform number of votes for each wine. To be able to find a wine similar in flavour, notes or pairings, to your favourite bottle, we can calculate the ‘normalised’ flavour votes and rankings using the data from Vivino’s website. This will allow direct comparisons of the wine’s characteristics based on user ratings and can be done in RDFox thanks to its reasoning capabilities.

Reasoning is the ability to calculate the logical consequences of applying a set of rules to a set of facts. Rules offer a convenient and expressive way to process, manipulate and create new data and bring the logical layer closer to the data.

In RDFox rules are expressed in Datalog, a declarative and formal logic-based programming language. Rules represent ‘if, then’ statements, where the formula to the left of the :- operator is the rule head (the ‘then’ part) and the formula to the right is the rule body (the ‘if’ part).

Using rules to calculate the total number of votes

Using rules to calculate the normalised flavour vote

For example, the normalised flavour vote for ‘Oaky’ flavour is 0.386, for ‘blackFruit’ is 0.159 and for ‘earthy’ is 0.136.

Finding similar flavour wine by clustering wines on flavour ranking

To do this we use a rule which will create a new relationship (edge) between the bottles of wine which share similar flavours. The following graph representation shows the result of the similarity rule. As you can see, the Sanct Valentin Pinot Grigio and the Toscana Batar 2016 have very similar ‘citrus’ and ‘treeFruit’ normalised flavour ratings. This similarity results in 4 edges between the wines, because of the symmetry.

Once the rules have been executed for all wines within the knowledge graph, finding wines based on their similarities would be simple and quick for the user.

The following image provides an example of a graph of similarities between the wines:

Searching for alternative wines

RDFox uses SPARQL, the standard query language for RDF triplestores. SPARQL provides a similar function to SQL for relational databases, but for graph databases, by enabling information within the RDF triplestore to be queried. Queries retrieve and model data stored within RDFox.

This can be done through the RDFox console, a code editor e.g. visual studio code, or alternatively through web applications. Web applications can be built and attached to the RDFox console, allowing users to interact with the knowledge graph without having to write SPARQL queries. This has significant benefits for businesses, like online wine merchants, whose customers would want to easily access information on the website. For this example however, we will show the SPARQL queries in the RDFox console.

The following console image demonstrates a query search for wines which share similar notes to a bottle of Podere 2013. RDFox provides 4 answers, with varying levels of similarity.

For example, the Avvoltore 2013 is similar to the Podere 2013 due to its oakiness, but the Saint Émilion is similar due to the ageing.

In a similar way we can ask for wines that are similar to the Podere 2013 in one particular way. For example, if a wine enthusiast loves ‘black fruit’ flavour, then we can request wines with a similar ‘black fruits’ score.

We can venture deeper into the dataset by finding similar wines, categorised by flavour and also by pairings. For example, if we wanted an alternative to the Ceretto Barolo 2013, which shares some similar flavours and goes with pasta, we could be recommended the Toscana Batar 2016 or the Salice Salentino 2012.

Additionally, as wine merchants often include cost within their search parameters, customers could use their AI Wine Sommelier to find wines which have similar flavours, notes and food pairings, but at a lower cost. This would allow customers to save money on wine whilst not compromising on the flavours they love.

Managing the wine database

A significant benefit to using RDFox, is its ability to add or remove data incrementally. If a new wine bottle is added or stock is discontinued, unlike other graph databases, RDFox can incrementally add or remove recommendation data, allowing for real-time updates. Thus, the maintenance of the search interface and the data is simple. New triples, such as votes for flavours, notes and pairings — can be added directly into the database. Rules will then automatically derive conclusions on top of this data, such as which wine is similar to which other wine. See a further article on rules here.

The ability of RDFox to provide flexibility without compromising on performance, is significant in comparison to alternative database or knowledge graph solutions. This feature is great for the wine merchants as RDFox allows their website to respond in real-time to both stock counts and consumer’s needs and can be used within an AI Assistant or Faceted Search.

Additionally, wine merchants may hold discounts on certain wines. RDFox can be used to calculate these discounts. For example, if there is a discount of 29% on the Chassagne-Montrachet, we can use rules to calculate the discounted price. The discounted price is then stored in the knowledge graph as a new node, ‘discountedPrice’, 38.979.

RDFox’s ability to carry out incremental reasoning also means that if the discount changes, or the full price changes, then so does the sale price. Updates are processed incrementally within RDFox, so there is no need for batch updates or the creation of whole streaming infrastructure.

Rule Example

[?wine, :discountedPrice, ?dp] :-[?wine, :fullPrice, ?fp],[?wine, :discount, ?discount],BIND(?fp * (1-?discount/100) AS ?dp) .

For more in-depth examples of rules and how to write them you can find a selection of articles on ‘RDFox and Reasoning’ listed here.

In Summary:

Wine merchants could use RDFox to provide an AI wine Sommelier experience for their customers on their websites. This would improve the user-experience and have knock on effects for customer satisfaction and return rates, whilst empowering wine enthusiasts to find the perfect bottle.

If you would like to see a demonstration of how RDFox could be used to build your AI Wine Sommelier, get in touch at info@oxfordsemantic.tech

To try RDFox yourself, click here to request an evaluation license.

Team and Resources

Oxford Semantic Technologies

A high performance knowledge graph and semantic reasoning engine

Oxford Semantic Technologies

Oxford Semantic Technologies develop RDFox, the first market-ready high-performance knowledge graph designed from ground up with semantic reasoning in mind. Founded in 2017 as a spin-out of the University of Oxford with a mission to bring cutting-edge research to industry.

Felicity Mulford

Written by

Employee at Oxford Semantic Technologies and Ox Mountain. OST have developed RDFox, a high performance knowledge graph and semantic reasoning engine.

Oxford Semantic Technologies

Oxford Semantic Technologies develop RDFox, the first market-ready high-performance knowledge graph designed from ground up with semantic reasoning in mind. Founded in 2017 as a spin-out of the University of Oxford with a mission to bring cutting-edge research to industry.