<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Andrea Rossi]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>https://www.andrearossi.io/</link><image><url>https://www.andrearossi.io/favicon.png</url><title>Andrea Rossi</title><link>https://www.andrearossi.io/</link></image><generator>Ghost 4.10</generator><lastBuildDate>Thu, 14 May 2026 00:08:56 GMT</lastBuildDate><atom:link href="https://www.andrearossi.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Kelpie: explaining embedding-based Link Predictions]]></title><description><![CDATA[<p>Hello, there!</p><p>I&apos;m very excited to announce that my latest paper has been accepted for the SIGMOD 2022 conference! It is my most ambitious work so far, and now that the peer-review process is over, I can finally disclose some details about it.</p><p>My work consists in a</p>]]></description><link>https://www.andrearossi.io/introducing-kelpie/</link><guid isPermaLink="false">61d4245c81ff8505b4d7b1b4</guid><category><![CDATA[Explainability]]></category><category><![CDATA[Link Prediction]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Knowledge Graphs]]></category><dc:creator><![CDATA[Andrea Rossi]]></dc:creator><pubDate>Tue, 04 Jan 2022 20:04:34 GMT</pubDate><media:content url="https://www.andrearossi.io/content/images/2022/01/5_thumbnail.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.andrearossi.io/content/images/2022/01/5_thumbnail.png" alt="Kelpie: explaining embedding-based Link Predictions"><p>Hello, there!</p><p>I&apos;m very excited to announce that my latest paper has been accepted for the SIGMOD 2022 conference! It is my most ambitious work so far, and now that the peer-review process is over, I can finally disclose some details about it.</p><p>My work consists in a novel explainability framework for embedding-based Link Prediction models, named Kelpie. Given any link yielded by an embedding-based model, Kelpie can identify why the model predicted it by extracting various types of explanations.</p><p>By the way, Kelpies are mythological shapeshifting fish-horse creatures said to dwell in the depths of Scottish lakes, so they seemed the perfect mascot for a machine learning / deep learning project <strong>*ba-dum tsss*</strong>. Also, &#x201C;Kelpie&#x201D; makes a nice acronym: &#x201C;<strong>K</strong>nowledge graph <strong>E</strong>mbeddings for <strong>L</strong>ink <strong>P</strong>rediction: <strong>I</strong>nterpretable <strong>E</strong>xplanations&#x201D;. </p><p>Since this work is heavily invested in Link Prediction on Knowledge Graphs, allow me to start with a brief recap on the topic &#x1F601;</p><h1 id="knowledge-graphs-and-link-prediction">Knowledge Graphs and Link Prediction</h1><p>As I already <a href="https://www.andrearossi.io/link-prediction-primer/">mentioned in the past</a>, Knowledge Graphs are repositories of real-world information where entities are connected via edges labeled by relations: they thus form &lt;<em>head</em>, <em>relation</em>, <em>tail</em>&gt; triples called <em>facts</em>. Knowledge Graphs are powerful but generally incomplete; Link Prediction tackles this issue by inferring new facts from the patterns and semantics of the already known ones.</p><p>Most Link Prediction models nowadays map the entities and relations in the graph to vectorized representations called Knowledge Graph Embeddings. Embedding-based Link Prediction models generally define a scoring function &#x3A6; that, given a head entity, a relation, and a tail entity, uses their embeddings to estimate a plausibility value for the corresponding fact. The embeddings of all entities and relations are usually initialized randomly, and then trained with Machine Learning methods to optimize the &#x3A6; values of a set of facts known to be true a priori (i.e., our training set). The trained embeddings should generalize and result in high plausibility scores for unseen true facts too.</p><h1 id="explainability-and-link-prediction">Explainability and Link Prediction</h1><p>Embedding-based models have achieved promising results in Link Prediction, often surpassing traditional rule-based counterparts. Unfortunately, these systems are almost always opaque: the embedding of an entity or relation is just a vector of numbers, with no memory of which training facts have been most influential to it, and with no insights on why it supports certain predictions while hindering others.</p><p>Explaining the outcomes of embedding-based Link Prediction models is thus becoming an increasingly urgent challenge. Link Prediction models are often used in scenarios that inherently require explainability, such as <a href="https://dl.acm.org/doi/10.1145/3357384.3358036">fact checking</a> or <a href="https://www.nature.com/articles/s41598-019-42806-6">drug discovery and repurposing</a>; furthermore, explanations can reveal if our systems are leveraging reliable patterns or rather spurious correlation, thus assessing their trustworthiness (or lack thereof).</p><p>One could ask: &#x201C;Why don&#x2019;t we just use one of the general-purpose explainability frameworks that are already out there? Why do we need a new framework specific for Link Prediction?&#x201D; The answer is that, unfortunately, no general-purpose frameworks seem to apply well to embedding-based Link Prediction models. </p><p>Most explainability frameworks operate by perturbing the features of the input samples and then checking the resulting effect on predictions: if the prediction outcome changes, it means that the perturbed features were relevant, or <em>salient</em>, to it. These <em>saliency-based frameworks</em>, unfortunately, are only useful when the input features of samples are directly interpretable by humans: e.g., macro-pixels in images, or words in a sentence. In the case of Link Prediction, samples are just triplets of embeddings: perturbation approaches would thus just identify the most salient components of those vectors, which would not be informative from a human point of view. </p><p>A few frameworks follow a different paradigm, and try to identify the training samples that have been most influential to the prediction to explain. The <a href="https://arxiv.org/abs/1703.04730">approach by Koh and Liang</a>, based on the robust statistics concept of Influence Functions, is considered the cornerstone of this category. This approach seems quite sensible for our scenario; unfortunately, Influence Functions are computationally very expensive, and this approach has been proved unfeasible to explain Link Predictions.</p><h1 id="introducing-kelpie">Introducing Kelpie</h1><p>Kelpie overcomes these issues by mixing the advantages of both categories of frameworks. On the one hand, similarly to Influence Function methods, Kelpie explains predictions in terms of the training samples that have enabled them in the first place: on the other hand, it identifies those training samples with a custom, saliency-inspired approach which is feasible for the Link Prediction field.</p><p>More specifically, Kelpie interprets any tail prediction &lt;<em>h</em>, <em>r</em>, <em>t</em>&gt; by identifying the enabling training facts mentioning the head entity <em>h</em>, and, analogously, any head prediction by identifying the enabling facts featuring the tail. Given any tail prediction &lt;<em>h</em>, <em>r</em>, <em>t</em>&gt;, Kelpie supports two different explanation types:</p><ul><li>a <strong>necessary explanation</strong> is the smallest set of training facts mentioning <em>h</em> such that, if those facts are erased from the training set, the model (retraining it from scratch) will predict a different tail for head <em>h</em> and relation <em>r</em>. <br></li></ul><!--kg-card-begin: html--><p align="center">
    <img alt="Kelpie: explaining embedding-based Link Predictions" src="https://www.andrearossi.io/content/images/2022/01/5_necessary.png" style="width:60rem;"><br>
    <small>Given the tail prediction &lt;Barack Obama, nationality, USA&gt;, a necessary explanation is the set {&lt;Barack Obama, born_in, Honolulu&gt;, &lt;Barack Obama, president, USA&gt;} if, removing those facts from the training set, the model ceases to predict that Barack Obama is American.</small>
</p><!--kg-card-end: html--><ul><li>a <strong>sufficient explanation</strong> is the smallest set of training facts mentioning <em>h</em> such that, if those facts are added to any random entity <em>e</em>, the model (retraining it from scratch) will predict &lt;<em>e</em>, <em>r</em>, <em>t</em>&gt; too.</li></ul><!--kg-card-begin: html--><p align="center">
    <img alt="Kelpie: explaining embedding-based Link Predictions" src="https://www.andrearossi.io/content/images/2022/01/5_sufficient.png" style="width:60rem;"><br>
    <small>Given the tail prediction &lt;Barack Obama, nationality, USA&gt;, a sufficient explanation is the fact &lt;Barack_Obama, president, USA&gt; if, adding the USA presidency to any non-American entity (e.g.,&#xA0;&#xC9;dith Piaf, Vladimir Putin, or Pikachu) the model starts to predict their nationality as USA.</small>
</p><!--kg-card-end: html--><p>The same concepts apply to head predictions as well.</p><p>In order to identify which sets of facts constitute necessary or sufficient explanations, Kelpie creates alternate versions of the already existing entities, called <em>mimics</em>. A mimic is featured in the same training facts as the original entity it refers to, except for a few purposefully injected perturbations, i.e. removals or additions. Ideally, a mimic should display the same behavior that the original entity would have shown if its training facts had been perturbed in that way since the very beginning. By creating mimics and checking how their predictions differ from those of the original entities, we are able to verify which sets of facts constitute a necessary or a sufficient explanation to the prediction to interpret. </p><p>Clearly, mimics are only useful as long as they are both <em>faithful</em> to the behavior that the embeddings of original entities would have displayed, and <em>feasible</em> in the way they are computed. For example, a faithful mimic can be easily obtained by actually re-training the model from scratch after injecting the perturbations; the heavy computational costs of re-training the whole model, however, would make this approach unfeasible.</p><p>Kelpie generates mimics that are both faithful and feasible by relying on a novel Machine Learning methodology that we have called <em>post-training</em>. The embedding of any mimic is initialized randomly, as any other entity embedding; then, it undergoes a training process analogous to the original training in terms of optimizer and hyper-parameters, but with two key differences:</p><ul><li>Except for the embedding of the mimic, <em>all the other embeddings and shared parameters are kept frozen and constant</em>: the only component that gets updated in the training process is the embedding of the mimic.</li><li>Since the embedding of the mimic is the only one that gets updated, <em>the training set is limited to the training facts that actually feature the mimic entity</em>, i.e., to the perturbed set of training facts of the original entity.</li></ul><!--kg-card-begin: html--><p align="center">
    <img alt="Kelpie: explaining embedding-based Link Predictions" src="https://www.andrearossi.io/content/images/2022/01/5_mimic.png" style="width:60rem;"><br>
    <small>The Obama Mimic is an alternate version of Barack Obama: its facts (in purple) are identical<br>to those of the original Barack Obama, except for a few injected perturbations.<br>And, yeah, in an alternate universe Barack Obama is a Cthulhu cultist.</small>
</p><!--kg-card-end: html--><p>These differences make the post-training a very lightweight process, because it only involves one embedding (instead of thousands) and it only optimizes the scores of a few dozens or hundreds of facts (instead of hundreds of thousands). In practice, while fully training a Link Prediction model usually takes several hours, a post-training process is generally over in a few seconds. This makes it possible to use post-training to discover which perturbations would affect the prediction to explain the most, and, thus, which training facts enabled it.</p><p>Finally, an aspect I am particularly proud of is that, thanks to the flexibility of post-training, Kelpie can theoretically support any Link Prediction models based on embeddings: this is a sorely needed quality in a field where dozens of new models are released each year. </p><p>That&#x2019;s it for this post!</p><p>As usual, I will leave here some references to additional contents:</p><ul><li>you can find here the papers of three general purpose explainability frameworks: <a href="https://arxiv.org/pdf/1602.04938.pdf">LIME</a>, <a href="https://homes.cs.washington.edu/~marcotcr/aaai18.pdf">ANCHOR</a>, and <a href="https://arxiv.org/pdf/1705.07874.pdf">SHAP</a>. They all have had a big impact in the AI community.</li><li>here are the links to <a href="https://www.ijcai.org/Proceedings/2019/0674.pdf">Data Poisoning</a> and <a href="https://arxiv.org/pdf/1905.00563.pdf">CRIAGE</a>, two very interesting data poisoning frameworks for Link Prediction models. Rather than explaining predictions, they focus on verifying the robustness of the learned embeddings to perturbations. Since their techniques and experiments partially overlap with ours, we have used them in our Kelpie as a baseline.</li></ul><p>See you next time! &#x1F44B;</p>]]></content:encoded></item><item><title><![CDATA[Data Bias and Machine Learning]]></title><description><![CDATA[<p>Hi, there!</p><p>I am super excited to announce that the paper &quot;<em>Knowledge Graph Embeddings or Bias Graph Embeddings? A Study of Bias in Link Prediction Models</em>&quot;, which I have written with Paolo Merialdo and Donatella Firmani, has won the best paper award in DL4KG &apos;21! &#xA0;&#x1F973;</p>]]></description><link>https://www.andrearossi.io/data-bias-and-machine-learning/</link><guid isPermaLink="false">618c334081ff8505b4d7b08c</guid><dc:creator><![CDATA[Andrea Rossi]]></dc:creator><pubDate>Wed, 10 Nov 2021 22:23:23 GMT</pubDate><media:content url="https://www.andrearossi.io/content/images/2021/11/4_thumbnail.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.andrearossi.io/content/images/2021/11/4_thumbnail.png" alt="Data Bias and Machine Learning"><p>Hi, there!</p><p>I am super excited to announce that the paper &quot;<em>Knowledge Graph Embeddings or Bias Graph Embeddings? A Study of Bias in Link Prediction Models</em>&quot;, which I have written with Paolo Merialdo and Donatella Firmani, has won the best paper award in DL4KG &apos;21! &#xA0;&#x1F973; &#x1F973; The paper defines three types of sample selection bias, assesses their presence in the best-established Link Prediction datasets, and investigates how they affect the behavior of Link Prediction models.</p><p>I thought it would be fitting to write something about the effects of data bias on AI models on a broader scale. Data bias is defined as the presence of unwanted patterns or distributions in a dataset; in the context of AI, and in particular of Machine Learning, data bias can be a huge issue, because training a model on biased data usually leads the model to incorporate the bias and, thus, to yield biased outcomes.</p><h1 id="data-bias-and-machine-learning">Data Bias and Machine Learning</h1><p>The history of Machine Learning is studded with examples of data bias messing with the behaviour of models.</p><p>In 2013 the <a href="https://aclanthology.org/N13-1090.pdf">Word2Vec</a> word embeddings were famously found to reflect semantic relations among words. For example it was observed that embedding(&#x201C;<em>King</em>&#x201D;) - embedding (&#x201C;<em>Man</em>&#x201D;) + embedding (&#x201C;<em>Woman</em>&#x201D;) lands almost exactly on embedding(&#x201C;<em>Queen</em>&#x201D;), thus conveying the relation &#x201C;<em>Man</em>&#x201D;:&#x201D;<em>Woman</em>&#x201D;=&#x201C;<em>King</em>&#x201D;:&#x201D;<em>Queen</em>&#x201D;. Unfortunately, these embeddings have also been observed to convey sexist relations, such as &#x201C;<em>Man</em>&#x201D;:&#x201D;<em>Woman</em>&#x201D;=&#x201D;<em>Doctor</em>&#x201D;:&#x201D;<em>Nurse</em>&#x201D;, or &#x201C;<em>Man</em>&#x201D;:&#x201D;<em>Woman</em>&#x201D;=&#x201D;<em>Computer Programmer</em>&#x201D;:&#x201D;<em>Housemaker</em>&#x201D;. This is likely due to how different professions are referred to men and women in the training corpora.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Data Bias and Machine Learning" src="https://www.andrearossi.io/content/images/2021/11/4_doctor_nurse.png" style="width:40rem;"><br>
    <small>Ouch.</small>
</p><!--kg-card-end: html--><p>In 2015 the automatic labelling feature of Google Photos sparked controversy due to <a href="https://www.bbc.com/news/technology-33347866">tagging pictures of black people as &quot;<em>Gorillas</em>&quot;</a>. This type of mispredictions typically occurs in the presence of skewed datasets: in this case, black people were probably underrepresented in the &#x201C;Person&#x201D; class in training. Interestingly, rather than (or in addition to) correcting this problem directly, Google have decided to <a href="https://www.theverge.com/2018/1/12/16882408/google-racist-gorillas-photo-recognition-algorithm-ai">remove the &quot;<em>Gorilla</em>&quot;</a> class altogether from its classifier.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Data Bias and Machine Learning" src="https://www.andrearossi.io/content/images/2021/11/4_google_gorillas.png" style="width:40rem;"><br>
    <small>This is really messed up.</small>
</p><!--kg-card-end: html--><p>More recently, in 2020 the PULSE method, which relies on the NVIDIA StyleGAN architecture to generate upscaled versions of low-res face pictures, was found to most often produce faces with Caucasian features <a href="https://www.theverge.com/21298762/face-depixelizer-ai-machine-learning-tool-pulse-stylegan-obama-bias">even if the person in the original low-res image had a different ethnicity</a>. Once more, this probably depends on a skewed distribution in the original StyleGAN training data, even though other reasons may also concur.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Data Bias and Machine Learning" src="https://www.andrearossi.io/content/images/2021/11/4_white_obama.png" style="width:40rem;"><br>
    <small>Aaand that&apos;s it, I&apos;m outta here</small>
</p><!--kg-card-end: html--><p>These are just a handful of examples, but dozens more could be mentioned. In all these cases, the presence of unnaturally skewed distributions in training only became apparent after the models were released in production, and they were faced with a different distribution of samples: e.g., a model that focused on a certain demographic in training will perform poorly in real-world scenarios that also involve other demographics.</p><h1 id="how-to-counter-data-bias">How To Counter Data Bias</h1><p>In short, trying to remove bias from our models or datasets is a heck of a challenge.</p><p>De-biasing a model <em>a posteriori</em>, i.e., after its training is over, is very troublesome. <a href="https://proceedings.neurips.cc/paper/2016/hash/a486cd07e4ac3d270571622f4f316ec5-Abstract.html">Some works</a> have proposed ways to mitigate gender bias in trained word embeddings. However, no approaches are general enough to cover all the many possible types of bias, or all the possible architectures of our models.</p><p>Intuitively, a more general meth would be to work a priori, just fixing the training data eliminating the unwanted skew in their distribution, and then re-training the model from scratch. This approach is quite natural, but it comes with a set of issues of its own:</p><ul><li>Defining bias in an operative way is not trivial: the line separating sensible correlations from biases may not always be as clear as in the examples discussed above. The concept of bias inherently depends on the reference context: at the beginning of the 1900s a classifier distinguishing men from women based on whether they wore pants or gowns would be considered reasonable; the same criteria today would seem silly and controversial.</li><li>Even when a correlation is found to be clearly undesirable, e.g., <a href="&#x200B;&#x200B;https://www.reuters.com/article/us-amazon-com-jobs-automation-insight-idUSKCN1MK08G">unfavouring women in hiring processes</a>, removing bias from our training data may be very challenging. Our datasets cannot be de-biased automatically: if a software could automatically identify bias, then this would be an already solved issue. On the contrary, it is generally required to include human workers in the loop, which may not be feasible when dealing with hundreds of Gigabytes or even Terabytes of training data.</li><li>Some systems are designed to continuously learn even after they are deployed, granting even less control on their training data. This is the case of the Tay chatbot launched by Microsoft, which should ideally have honed its conversational skills by interacting with humans on Twitter. In practice, the experiment was shut down after less than 24 hours, as <a href="https://www.theguardian.com/world/2016/mar/29/microsoft-tay-tweets-antisemitic-racism">internet trolls</a> had managed to quickly <a href="https://www.cbsnews.com/news/microsoft-shuts-down-ai-chatbot-after-it-turned-into-racist-nazi/">convert Tay into a full-fledged nazi</a>:</li></ul><!--kg-card-begin: html--><p align="center">
    <img alt="Data Bias and Machine Learning" src="https://www.andrearossi.io/content/images/2021/11/4_tay.png" style="width:30rem;"><br>
    <small>Whelp.</small>
</p><!--kg-card-end: html--><p>It must also be acknowledged that in development even just <em>assessing</em> the presence of bias - let alone fix it - would come at significantly high costs and longer development times, without any guarantee of success. Needless to say, researchers and engineers (or their managers) are not particularly eager to include these activities in their development process.</p><h1 id="some-help-from-xai">Some Help From XAI</h1><p>Explainable AI, or XAI, is a subcategory of AI trying to &#x201C;open the black box&#x201D; of our models by interpreting their outcomes and behaviours. XAI frameworks can be extremely valuable in the fight against data bias, because they can highlight the reasons why our models yield certain predictions. In development, they can tell us which correlations our model is leveraging to yield the correct answers: if such correlations are inappropriate, the model is probably biased and unsuitable for real-world uses, so further investigation is recommended.</p><p>For instance, the authors of the popular framework <a href="https://arxiv.org/abs/1602.04938">LIME</a> have shown a logistic regression classifier that could correctly distinguish Wolves from Husky dogs in the datasets, but only did so by verifying the presence of snow in the picture: in the used dataset, Wolf pictures tended to most often include a snowy background whereas Husky pictures didn&#x2019;t.</p><p>As another example, a recent explainability framework for Link Prediction that I have developed in the course of my PhD (more details in upcoming posts!) has revealed weird correlations. For example, we have found that in certain datasets, correctly predicting the birthplace of a person always depends on that person playing on a football team from that city or nation. This was caused by those datasets being very poor in personal data, so the best pattern that models can leverage seems to be the slight preference that football players may have towards teams from their birthplace.</p><h1 id="conclusions">Conclusions</h1><p>All in all, there is no clear-cut approach to cleanse our data and/or our models from bias. Fighting bias is hard because bias is heavily embedded in our data: this, in turn, is a reflection of how deeply bias is rooted in our history and in our culture. </p><p>In this regard, AI only incorporates bias if we are the ones exposing it to bias in the first place. I like to think of AI just like a mirror: given a large set of training data, AI can find trends and return us a bigger picture; it can slightly deform things; or it can even show us things that we didn&apos;t know were there. But ultimately, what AI models show to us is just a reflection of what we have shown to them.</p><p>I believe this is actually a good thing: it means that we, as a species, are the ones in control. As long as we keep progressing and working hard to eliminate prejudices from our cultures, the contents and data we produce will reflect this type of improvement, and our AI models will too. </p><p>I find this kind of poetic: the only way to eradicate biases in AI models may be to keep fighting and eradicate them from our own minds.</p><p>That&#x2019;s it for this post! Thanks for reading this far &#x1F64F;</p><p>As usual, I will leave here some additional contents:</p><ul><li>my <a href="https://alammehwish.github.io/dl4kg2021/papers/knowledge_graph_embeddings_or_.pdf">paper on Data bias in Link Prediction</a>, published in the Deep Learning for Knowledge Graphs (DL4KG) workshop at ISWC 2021;</li><li>And here is a <a href="https://dl.acm.org/doi/pdf/10.1145/3457607">very recent comprehensive survey</a> on this topic, published in July 2021 by researchers from the USC Information Sciences Institute.</li></ul><p>See you soon! &#x1F44B;</p>]]></content:encoded></item><item><title><![CDATA[Machine Learning, Videogames, and Mechanical Turks]]></title><description><![CDATA[<p>As a very passionate gamer and a Machine Learning researcher, this is a post that I definitely couldn&apos;t help writing &#x1F601;</p><p>Nowadays AI, and by extension Machine Learning, is common in several areas of game design. For example games like <a href="https://www.minecraft.net/">Minecraft</a> and <a href="https://www.nomanssky.com/">No Man&apos;s Sky</a> successfully</p>]]></description><link>https://www.andrearossi.io/machine-learning-and-videogames/</link><guid isPermaLink="false">61031d554915bb1780987fa3</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[Game Design]]></category><dc:creator><![CDATA[Andrea Rossi]]></dc:creator><pubDate>Wed, 11 Aug 2021 20:19:07 GMT</pubDate><media:content url="https://www.andrearossi.io/content/images/2021/08/3_thumbnail.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.andrearossi.io/content/images/2021/08/3_thumbnail.png" alt="Machine Learning, Videogames, and Mechanical Turks"><p>As a very passionate gamer and a Machine Learning researcher, this is a post that I definitely couldn&apos;t help writing &#x1F601;</p><p>Nowadays AI, and by extension Machine Learning, is common in several areas of game design. For example games like <a href="https://www.minecraft.net/">Minecraft</a> and <a href="https://www.nomanssky.com/">No Man&apos;s Sky</a> successfully apply procedural AI to create entire worlds, and Machine Learning is heavily used in graphics: the <a href=" https://www.nvidia.com/it-it/geforce/technologies/dlss/">Nvidia DLSS</a> technology allows games to render images at lower resolutions (say, 1080p) and scales them up with Machine Learning before outputting them at 4K, achieving better quality and higher framerates with an overall lighter GPU workload. </p><p>In this post, however, I want to discuss specifically how AI is used to model the behavior of NPCs (non-playable characters). Videogames almost always simulate scenarios where one or multiple agents cooperate or compete to achieve certain goals, so controlling NPCs is intuitively the first task that comes to mind when mentioning AI in game design.</p><h2 id="ai-and-games-an-age-old-love-story">AI and Games: an Age-Old Love Story</h2><p>The idea of gaming AIs capable of outwitting humans has fascinated people for ages. In the 18th century the &#x201C;Turk&#x201D; chess automaton achieved worldwide fame for beating the likes of Napoleon Bonaparte and Benjamin Franklin; it was actually a hoax (a human secretly operated the automaton from the inside), but the idea of a Verne-esque machine smart enough to defeat humans captivated people immensely - and it still does. </p><p>Since the 1950s, computer scientists have been applying AI to board games with increasingly impressive results. In 1997 the IBM DeepBlue model famously defeated the chess champion Garry Kasparov: it was the first time a reigning champion was beaten at an intellectual task by an AI. The recent rise of Machine Learning has allowed AIs to tackle the harder game of Go: in 2015 the DeepMind AlphaGo model beat the Go champion Lee Sedol, with Sedol himself <a href="https://www.theverge.com/2019/11/27/20985260/ai-go-alphago-lee-se-dol-retired-deepmind-defeat">recently claiming that</a> AIs have become &quot;an entity that cannot be defeated&quot;.</p><p>I believe that the reason why AI in games is so appealing is that games provide a fictional setting in which both people and AI agents are restricted to the same set of rules and actions. This scenario facilitates the illusion of interacting with an artificial human-like intelligence, i.e., a general AI, and allows the players to fully immerse in the game.</p><p>Given this premise, Machine Learning should be ubiquitous in videogames, which, being natively digital, provide the ideal environment for AI agents... right?</p><h2 id="does-the-game-industry-use-machine-learning">Does the Game Industry Use Machine Learning?</h2><p>Unfortunately, nowadays Machine Learning is mostly <strong>not</strong> employed in videogames. Game developers rather prefer traditional AI techniques such as Pathfinding, Finite State Machines and Behavior Trees.</p><h3 id="pathfinding">Pathfinding</h3><p>Pathfinding studies the best way to move from a point A to a point B; most of them are heavily based on graph traversal algorithms, such as Dijkstra or A*. Pathfinding algorithms are used in almost all games where agents act on a map, (especially if made of tiles): for example, 2D strategic games such as Age of Empires, MMORPGs such as World of Warcraft, and first person shooters such as Half-Life and Counter-Strike. </p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://www.codingame.com/servlet/fileservlet?id=7766456941361" class="kg-image" alt="Machine Learning, Videogames, and Mechanical Turks" loading="lazy"><figcaption>A graphical example of a Pathfinding Algorithm based on Dijkstra. (source: <a href="https://www.codingame.com/learn/pathfinding">Codingame</a>).</figcaption></figure><h3 id="finite-state-machines-fsm">Finite State Machines (FSM)</h3><p>Finite State Machines (FSMs) define all the situations (<em>states</em>) that AI agents can encounter, and script the corresponding reactions. For instance if the health value of an agent falls below a threshold, this may trigger the reaction &quot;<em>heal yourself</em>&quot;; applying it may switch the FSM another state, which in turn will elicit a new reaction, and so on, resulting in an infinite decision-making loop. FSMs are great at modeling simple behaviors, and they have been used a lot in gaming, ranging from the ghosts of Pac-man to the NPCs of Call of Duty, Metal Gear Solid, Halo and The Elder Scrolls (e.g., Skyrim). </p><!--kg-card-begin: html--><p align="center">
    <img alt="Machine Learning, Videogames, and Mechanical Turks" src="https://www.andrearossi.io/content/images/2021/08/3_fsm.png" style="width:45rem;"><br>
    <small>A simple schema for a FSM (source: <a href="https://gamedevelopment.tutsplus.com/it/tutorials/finite-state-machines-theory-and-implementation--gamedev-11867">gamedevelopment.tutsplus</a>).</small>
</p><!--kg-card-end: html--><h3 id="behavior-trees">Behavior Trees</h3><p>When AI agents need to choose the best among many possibile actions, Behavior Trees are usually a better solution than FSMs. Behavior Trees are similar to flow-charts: possible conditions are represented as tree branches, and possible actions are the tree leafs. The tree is evaluated at regular intervals, identifying the best action to apply. If the tree is too large to visit it entirely, algorithms such as the Monte Carlo Search Tree (MCST)<strong> </strong>can provide estimates of the payback of each action. Behavior Trees are very common in strategic turn-based games, such as Civilization, Heroes of Might and Magic, and Pok&#xE9;mon.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Machine Learning, Videogames, and Mechanical Turks" src="https://www.andrearossi.io/content/images/2021/08/3_behavior_tree.png" style="width:50rem;"><br>
    <small>An example of behavior tree in the <a href="https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/ArtificialIntelligence/BehaviorTrees/BehaviorTreesOverview/">Unreal Engine 4 framework</a> documentation.</small>
</p><!--kg-card-end: html--><h2 id="does-the-game-industry-need-machine-learning">Does the Game Industry Need Machine Learning?</h2><p>All in all, while many AI-based tasks have shifted towards Machine Learning in the last decade, the game industry has not undergone the same process: devs have generally just refined and enhanced the same technologies with no radical changes.</p><p>I think the main reason behind this lies in what the <strong>actual</strong> <strong>purpose of games</strong> is. Similarly to other medias, such as movies or books, games build a narrative pact between developers and players: even the simplest game, through its context and rules, tells a story that the players unconsciously accept to believe. In this context AI agents are not meant to be <em>strong</em>: rather, they should be <em>plausible</em>,<em> </em>to sustain the suspension of disbelief. </p><p>Therefore the goal of AI in gaming is not to create smart agents, but rather to provide the <em>illusion</em> of smart agents. <a href="https://www.theverge.com/2019/3/6/18222203/video-game-ai-future-procedural-generation-deep-learning">Game designers themselves</a> claim that AI in games &quot;is the equivalent of smoke and mirrors&quot;. Interestingly, this is the same philosophy behind the &quot;Turk&quot; hoax: the most important thing was, and still is, the <em>experience</em> felt by the player rather than the actual intelligence of the machine. I find these considerations quite interesting: out of the dozens of fields where AI is currently employed, they mostly only apply to games due to their inherent nature of medias.</p><p>This explains why the game industry seem so reluctant to adopt Machine Learning: given the purpose of AI in gaming, it may be useless or even counter-productive. In addition to that, of course, Machine Learning is not actually devoid of issues:</p><ul><li><strong>Predictability</strong> : Machine Learning agents may behave inconsistently, e.g., they may alternate smart actions with idiotic ones, or display certain flaws only under specific conditions never met in development. The opacity of Machine Learning models would make it very hard for game designers to identify these behaviors and correct them.</li><li><strong>Development Processes</strong>: in most games the development is ruled by very tight schedules. Spending months (or years!) to build from scratch a whole new AI engine based on Machine Learning sounds like a bad move when you can just re-use pre-existing technologies with incremental refinements. </li><li><strong>Computation</strong>: Machine Learning models, unless they are really small and simple, generally need to run on GPUs. In videogames, though, GPUs are already busy with the game graphics, so they may not be able to handle the behavior of AI agents too (especially if there are too many of them).</li></ul><p>However, I do not think that any of these issues is truly blocking: as a matter of fact a few experimental games in the past have already overcome them, using neural networks for specific tasks, e.g., Peter Molyneux&apos;s <a href="https://www.ea.com/it-it/games/black-and-white/black-and-white">Black and White</a> in the early 2000s.</p><h2 id="will-the-game-industry-need-machine-learning">Will the Game Industry Need Machine Learning?</h2><p>If in the present Machine Learning and Game Industry do not look like a well-matched pair, the same may not apply for the future. Researchers have already run impressive (and extremely cool) experiments proving that Machine Learning technically <strong>can</strong> be applied to videogames with amazing results:</p><ul><li>OpenAI have developed an <a href="https://openai.com/five/">OpenAI Five</a> model capable of playing <a href="https://www.dota2.com/home">Dota 2</a>, a very popular MOBA where players clash in 5 vs 5 matches. OpenAI Five, which is based on self-play reinforcement learning, has spent about 10 months in a custom distributed training process; after that, it has <a href="https://openai.com/blog/openai-five-defeats-dota-2-world-champions/">defeated the Dota 2 world champions</a> on a livestream event, thus becoming the first AI to beat the world champions in an esports game.</li><li>DeepMind have developed an <a href="https://deepmind.com/blog/article/alphastar-mastering-real-time-strategy-game-starcraft-ii">AlphaStar</a> model to play the famous Real Time Strategic (RTS) game <a href="https://starcraft2.com">Starcraft 2.</a> In its <a href="https://deepmind.com/blog/article/AlphaStar-Grandmaster-level-in-StarCraft-II-using-multi-agent-reinforcement-learning">latest iteration</a> AlphaStar is limited to the same constraints as humans (e.g., viewing the game world through a camera, performing actions with a limited frequency, etc.); it has ranked above 99.8% of active players in the official server battle.net, achieving the grandmaster class in all the three races (Protoss, Terran, Zerg) of the game.</li></ul><p>These results prove that Machine Learning can indeed be applied to videogame agents with formidable results. The technology is here, and it is mature: studios could probably adopt it right away if it provided some added value in the greater picture of the game purposes. I feel that the only missing piece is a scenario where Machine Learning enables new gameplay possibilities would not be achievable otherwise; for instance, I would love to battle adaptive NPCs that learn in real time to counter the style and strategies of human players.</p><p>I can definitely see indie devs, or the most authorial game designers (e.g., Hideo Kojima, or the already mentioned Peter Molyneux) acting as pioneers in this field, and being later followed by more mainstream productions. </p><p>Until then, I can only keep dreaming of a neural-powered Ganondorf &#x1F62D;</p><p>Thank you for reading this far!</p><p>As usual I&apos;ll leave here some additional sources:</p><ul><li>A <a href="https://towardsdatascience.com/artificial-intelligence-in-video-games-3e2566d59c22">nice article</a> by Laura Maass on the current state of AI in gaming;</li><li>A <a href="https://arxiv.org/abs/1912.10944">scientific survey</a> by Kun Shao <em>et al</em>. on how reinforcement learning has been used so far on games in research projects.</li></ul><p>Have a nice day!</p>]]></content:encoded></item><item><title><![CDATA[Knowledge Graphs, Link Prediction and enterprises]]></title><description><![CDATA[<p>Hello, there! In <a href="https://www.andrearossi.io/link-prediction-primer/">my previous post</a> I discussed the basics of embedding-based Link Prediction on Knowledge Graphs.</p><p>On that occasion I included a pointer to a <a href="https://dl.acm.org/doi/10.1145/3424672">comparative analysis</a> that I published on the topic; in this post I&#x2019;d like to borrow a few of the concepts from that</p>]]></description><link>https://www.andrearossi.io/kg-enterprises/</link><guid isPermaLink="false">6102e4a74915bb1780987ef3</guid><category><![CDATA[Knowledge Graphs]]></category><category><![CDATA[Link Prediction]]></category><category><![CDATA[Machine Learning]]></category><dc:creator><![CDATA[Andrea Rossi]]></dc:creator><pubDate>Sat, 07 Aug 2021 12:58:31 GMT</pubDate><media:content url="https://www.andrearossi.io/content/images/2021/07/2_thumbnail.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.andrearossi.io/content/images/2021/07/2_thumbnail.png" alt="Knowledge Graphs, Link Prediction and enterprises"><p>Hello, there! In <a href="https://www.andrearossi.io/link-prediction-primer/">my previous post</a> I discussed the basics of embedding-based Link Prediction on Knowledge Graphs.</p><p>On that occasion I included a pointer to a <a href="https://dl.acm.org/doi/10.1145/3424672">comparative analysis</a> that I published on the topic; in this post I&#x2019;d like to borrow a few of the concepts from that work about the current status of Link Prediction research.</p><p>Quick recap: Link Prediction infers new facts in a Knowledge Graph leveraging the already known ones. Most Link Prediction models use Machine Learning to learn embeddings of the entities and relations; embeddings are optimized to fit a Scoring Function &#x3A6; that estimates the plausibility of individual facts. After training on many facts already known to be true, the learned embeddings should yield good &#x3A6; values for unknown true facts as well.</p><h2 id="link-prediction-trends">Link Prediction Trends</h2><p>Since the pioneering TransE model researchers have gone into a &#x201C;Link Prediction frenzy&#x201D; and they have started creating dozens and dozens of new embedding-based models, each with a &#x3A6; function of its own. To put things into a numeric perspective, these are Google Scholar yearly numbers of the works citing TransE:</p><!--kg-card-begin: html--><p align="center">
    <img alt="Knowledge Graphs, Link Prediction and enterprises" src="https://www.andrearossi.io/content/images/2021/07/2_transe_citations.png" style="width:45rem;"><br>
    <small>Damn, 2020, you just couldn&#x2019;t keep the exponential trend going, could you?</small>
</p><!--kg-card-end: html--><p>This trend is pretty darn impressive. Of course, not all of these works propose new models, nonetheless these numbers are huge &#x2013; and TransE is now a bit outdated, so the most recent works may not even mention it that often anymore. It would not be an understatement to say that hundreds of embedding-based Link Prediction models have been developed in the last 7-8 years.</p><p>With such a crowded scene, when I started my PhD on this topic I felt utterly overwhelmed. My first reaction was denial: &#x201C;<em>There&#x2019;s no way all of these models are really meaningful! Most of them must just be junk!</em>&#x201D;. While this is not necessarily wrong, after a while my point of view started shifting. When you think about it, there is a special kind of beauty in the fact that knowledge can be learned in hundreds of different approaches, each with its own features and quirks, and even if many of them turn out to be suboptimal research-wise. I guess this is part of what makes Machine Learning so attractive, after all.</p><p>I was still puzzled, though: why are there so many Link Prediction models? Why is this topic getting this much attention, when it does not even have many practical applications yet? It took me some time to wrap my head around this, but I think the answer lies in the big shift that Knowledge Graphs have undergone in the last decade.</p><h2 id="the-knowledge-graph-boom">The Knowledge Graph Boom</h2><p>In the 2000s Knowledge Graphs (or Knowledge Bases, or Ontologies) were synonyms to Linked Open data. The big players were open projects like <a href="https://developers.google.com/freebase">Freebase</a> or <a href="https://www.dbpedia.org/">DBpedia</a>, trying to implement the vision of Tim Berners-Lee of a Semantic Web of distributed, machine-readable concepts.</p><p>In the 2010s, for the good or the bad, enterprise Knowledge Graphs have taken over. In 2010 Google outright bought Freebase and built their <a href="https://blog.google/products/search/introducing-knowledge-graph-things-not/">Google Knowledge Graph</a> (2012) on top of it to enhance their web engine with semantic knowledge (fun fact: this is where the term &#x201C;<em>Knowledge Graph</em>&#x201D; comes from!). Two years later they launched the <a href="https://research.google/pubs/pub45634/">Knowledge Vault project</a>, combining the data obtained by a multitude of extractors with Link Prediction outcomes. In the same years, Microsoft developed their own Knowledge Graph <a href="https://blogs.bing.com/search/2013/03/21/understand-your-world-with-bing">Satori</a> (&#x201C;<em>understanding</em>&#x201D; in Japanese), and in 2017 they merged it with Bing into the <a href="https://www.microsoft.com/en-us/bing/apis/bing-entity-search-api">Bing Entity Search</a> service.</p><p>Big marketplaces like Amazon and Ebay joined the game too, developing product graphs to encompass semantic knowledge on the products they sale. <a href="https://ieeexplore.ieee.org/document/8731403">Amazon</a> leverages the data in their graph to improve product recommendation, while <a href="https://www.ebayinc.com/stories/news/cracking-the-code-on-conversational-commerce/">Ebay</a> mostly uses theirs to power smart conversational agents. In 2018 both <a href="https://medium.com/airbnb-engineering/scaling-knowledge-access-and-retrieval-at-airbnb-665b6ba21e95">Airbnb</a> and <a href="https://eng.uber.com/uber-eats-query-understanding">Uber Eats</a> announced the creation of their own Knowledge Graphs, that they use to improve recommendation of activities and foods/restaurants respectively.</p><p>In the meantime the social networks did not stay dormant. In 2013 Facebook launched their <a href="https://newsroom.fb.com/news/2013/01/introducing-graph-search-beta">Facebook Graph Search</a> project to leverage semantic knowledge on the entities and topics that users are most invested on; it is mostly used to improve user profiling and, thus, provide users with better recommendations and targeted advertising. In 2016 <a href="https://engineering.linkedin.com/blog/2016/10/building-the-linkedin-knowledge-graph">LinkedIn</a> announced their own Knowledge Graph with similar purposes, and in 2020 the same route has been followed by <a href="https://medium.com/pinterest-engineering/interest-taxonomy-a-knowledge-graph-management-system-for-content-understanding-at-pinterest-a6ae75c203fd">Pinterest</a>.</p><p>It is undeniable that such a Knowledge Graph boom has boosted many related research topics too. In the specific case of Link Prediction, I think it has become so popular because it has hit the &#x201C;sweet spot&#x201D; of three extremely favorable conditions:</p><ol><li>It applies to tools that have rapidly become very useful and profitable for giant tech companies, i.e., <em>Knowledge Graphs</em>;</li><li>It attempts to tackle arguably the greatest issue that such tools suffer from, i.e., <em>incompleteness</em>;</li><li>It does so with super fancy and trendy novel technologies that everybody is interested in, i.e., <em>Machine Learning</em>.</li></ol><p>I finally tried to come full circle, developing my own organization to the messy scenario of Link Prediction models. </p><h2 id="link-prediction-taxonomy">Link Prediction Taxonomy</h2><p>This taxonomy groups embedding-based models based on the interpretation of their &#x3A6; function.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Knowledge Graphs, Link Prediction and enterprises" src="https://www.andrearossi.io/content/images/2021/07/2_taxonomy.png" style="width:100%;"><br>
    <small>My taxonomy for Link Prediction models, with a small selection of representative examples. And with colors!</small>
</p><!--kg-card-end: html--><p>I identified three main families, each with further sub-groups:</p><ul><li><strong>Matrix Factorization Models</strong><br>They mostly rely on linear algebra to combine the embeddings of heads, relations, and tails. I further split them into Bilinear Models, based on bilinear products, and Non-bilinear Models, that may employ more &#x201C;esoteric&#x201D; operations, e.g., Circular Correlation or Tucker composition.</li><li><strong>Geometric Models</strong><br>They interpret relations as geometric operations in the embedding space. Starting from TransE, which is a purely translational model, researchers have studied smart ways including Additional Embeddings, often mapping each entity to multiple relation-specific embeddings. Lately, though, Roto-translational operations have become the most promising research direction in this family.</li><li><strong>Deep Learning Models</strong><br>They rely on Neural Networks, which include deep sequences of layers interspersed with non-linear activation functions. Their parameters are learned jointly the embeddings, on which they operate in the &#x278; function. This family can be naturally divided into sub-groups based on the neural architecture type: Convolutional Models, Recurrent Models, Capsule Models, etc. The use of additional parameters makes these models quite expressive, but in turn lead to longer training times and greater risks of overfitting.</li></ul><p>That&#x2019;s it for this post! Thank you for reading this far &#x1F64F;</p><p>As usual I will leave here a few useful references:</p><ul><li>Some data on enterprise Knowledge Graphs have been collected from the excellent book &#x201C;<a href="https://arxiv.org/pdf/2003.02320.pdf">Knowledge Graphs</a>&#x201D;, by Hogan <em>et al</em>.</li><li>Tsinghua University has collected a <a href="https://github.com/thunlp/KRLPapers">list</a> with no less than 50 must-read scientific papers on Link Prediction: enjoy!</li></ul>]]></content:encoded></item><item><title><![CDATA[Using Embeddings to Predict New Links in Knowledge Graphs]]></title><description><![CDATA[<p>Hello, there! </p><p>This is my very first post, so I&apos;m super excited. I&apos;d like to talk about my current field of research, which deals with how Machine Learning techniques can be applied to Link Prediction on Knowledge Graphs.</p><p>Knowledge Graphs are stores of real-world information structured</p>]]></description><link>https://www.andrearossi.io/link-prediction-primer/</link><guid isPermaLink="false">61007d924915bb1780987d1c</guid><category><![CDATA[Link Prediction]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Knowledge Graphs]]></category><dc:creator><![CDATA[Andrea Rossi]]></dc:creator><pubDate>Wed, 28 Jul 2021 14:18:00 GMT</pubDate><media:content url="https://www.andrearossi.io/content/images/2021/07/1_thumbnail.png" medium="image"/><content:encoded><![CDATA[<img src="https://www.andrearossi.io/content/images/2021/07/1_thumbnail.png" alt="Using Embeddings to Predict New Links in Knowledge Graphs"><p>Hello, there! </p><p>This is my very first post, so I&apos;m super excited. I&apos;d like to talk about my current field of research, which deals with how Machine Learning techniques can be applied to Link Prediction on Knowledge Graphs.</p><p>Knowledge Graphs are stores of real-world information structured into nodes and labeled directed edges. Nodes represent <strong>entities</strong> (people, places, etc) and they are connected by edges whose labels convey semantic <strong>relations</strong>.<br>In a Knowledge Graph an edge linking two nodes represents a unit of information called <strong>fact</strong>, i.e., &lt;<em>Barack_Obama</em>, <em>was_born_in</em>, <em>Honolulu</em>&gt;.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Using Embeddings to Predict New Links in Knowledge Graphs" src="https://www.andrearossi.io/content/images/2021/07/1_kg.png" style="width:30rem;"><br>
    <small>A wee little Knowledge Graph.</small>
</p><!--kg-card-end: html--><p>Knowledge Graphs are quite useful and they are employed in a wide variety of contexts, from semantic web projects to user profiling and recommendation systems. Unfortunately though, all Knowledge Graphs tend to suffer from <strong>incompleteness</strong>, as they only contain a small portion of all the real-world information they should encompass.</p><p>Link Prediction tackles incompleteness by inferring new facts from the existing ones. For instance, knowing that &lt;<em>Barack_Obama</em>, <em>was_born_in</em>, <em>Honolulu</em>&gt; you can deduce that, probably, &lt;<em>Barack_Obama</em>, <em>has_nationality</em>, <em>USA</em>&gt; (assuming it was previously unknown).</p><p>Nowadays, most Link Prediction models map each entity and relation to vectorized representations called <strong>embeddings</strong>. Link Prediction model based on embeddings usually works by defining a mathematical scoring function &#x3A6; that, for any fact &lt;<em>h</em>, <em>r</em>, <em>t</em>&gt;, can use the embeddings of <em>h</em>, <em>r</em>, and <em>t</em> to compute a floating point output value &#x3A6;(<em>h</em>, r, t) .</p><!--kg-card-begin: html--><p align="center">
    <img alt="Using Embeddings to Predict New Links in Knowledge Graphs" src="/content/images/2021/07/1_embeddings.png" style="width:30rem;">
    <br>
    <small>Each entity and relation is mapped to an embedding.</small>

</p><!--kg-card-end: html--><p>In training, all the embeddings are initialized randomly, and then optimized to maximize the scores &#x3A6; of the known facts. In other words, we tweak and improve the values for the embeddings of all entities and all relations so that, for any known fact &lt;<em>h</em>, <em>r</em>, t&gt;, we make &#x3A6;(<em>h</em>, r, t) become as large as possible. In practice, what we actually gather the &#x3A6; scores of all the known facts in a Loss Function (e.g., Negative Log-Likelihood, Binary Cross-Entropy, or Pairwise Ranking Loss), and train the embeddings to optimize the Loss value.</p><p>After the training is complete, the learned embeddings should (hopefully!) be able to generalize and to lead to high &#x3A6; values even for true facts that were not seen in training. So we can discover new relevant facts by just trying new combinations &lt;<em>entity_1</em>, <em>relation</em>, <em>entity_2</em>&gt; and their &#x3A6; score: if it is good enough, chances are the combination corresponds to a true, previously unknown, fact. In other words, after we have carefully trained the embeddings, we expect &#x3A6; to be a good estimate of the plausibility of any (known or unknown) fact.</p><p>Does this seem a bit too convenient? Well, it should &#x1F61C; In practice, the hardest part of building a new Link Prediction model is devising a &quot;good&quot; &#x3A6; &#xA0;function. Many functions sounded very good at first, but in time unexpected flaws emerged.</p><p>At this regard, the <strong>TransE</strong> model is a fine example. TransE was created by Bordes <em>et al.</em> in 2013; it is a pioneering work, and one of the very first Link Prediction models based on embeddings in history. TransE was largely inspired by the translational properties <em>Word2Vec</em> neural language model, and it enforces the translational operation explicitly in its scoring function &#x3A6;:</p><!--kg-card-begin: html--><p align="center">
    &#x3A6;(<i>h</i>, <i>r</i>, <i>t</i>) = |<i>h</i> + <i>r</i> - <i>t</i>|
</p><!--kg-card-end: html--><p>The scoring function of TransE can be read in this way: given the fact &lt;<em>h</em>, <em>r</em>, <em>t</em>&gt; we take into account the vector of the head entity h and we translate it by the relation embedding r; if the fact was true, we expect to land on a position close to the embedding of t (distance is measured with L1 or L2 norm). In a space with 3-dimensional embeddings, applying the &#x3A6; &#xA0;function of TransE would look like this:</p><!--kg-card-begin: html--><p align="center">
    <img alt="Using Embeddings to Predict New Links in Knowledge Graphs" src="/content/images/2021/07/1_transe_1.png" style="width:40rem;">
    <br>
    <small>TransE scoring function in a nutshell.</small>

</p><!--kg-card-end: html--><p>This is a very simple &#x3A6; &#xA0;function inspired by basic geometry, but for many cases it works pretty well. For instance, it was found to correctly predict the Capital cities of various countries:</p><!--kg-card-begin: html--><p align="center">
    <img alt="Using Embeddings to Predict New Links in Knowledge Graphs" src="/content/images/2021/07/1_transe_2.png" style="width:30rem;">
    <br>
    <small>TransE is good on one-to-one relations, such as <i>capital_of</i>.</small>

</p><!--kg-card-end: html--><p>Unfortunately for TransE, though, not all relations are as smooth as <em>capital_of</em>.<br>Many relations may convey &#x201C;one-to-many&#x201D; semantics: the same head entity can be connected by the same relation to multiple tail entities, e.g., &#xA0;the same uncle can have multiple nephews: &lt;<em>Donald</em>, <em>uncle_of</em>, <em>Huey</em>&gt;, &lt;<em>Donald</em>, <em>uncle_of</em>, <em>Dewey</em>&gt;, and &lt;<em>Donald</em>, <em>uncle_of</em>, <em>Louie</em>&gt;.</p><!--kg-card-begin: html--><p align="center">
    <img alt="Using Embeddings to Predict New Links in Knowledge Graphs" src="/content/images/2021/07/1_transe_3.png" style="width:30rem;">
    <br>
    <small>&quot;You are a terrible uncle, unca&apos; Donald!&quot;</small>

</p><!--kg-card-end: html--><p>In cases like this, TransE fails spectacularly. Starting from the same head entity (e.g., <em>Donald</em>) and applying the same relation translation (e.g., <em>uncle_of</em>), we will just land in one spot of the vector space; and a single spot is not likely to lead equally good &#x3A6; values for all the correct tail entities (<em>Huey</em>, <em>Dewey</em> and <em>Louie</em>). The same issues occurs with many other types of relations: for starters, many-to-one and many-to-many relations, but also symmetric relations, transitive relations, and so on.</p><p>After this flaw was found, researchers did what they do best: they developed new models trying to overcome this issue, and then the next one, and so on. In time, new families of &#x3A6; functions have been tailored, each with its own pros and cons. Starting from TransE, in just a few years Knowledge Graph embeddings have become a sparkling research topic, with dozens of new models being proposed every year.</p><p>I don&apos;t want to get into too much detail - I will probably cover this in another post - but often times the &#x3A6; &#xA0;function of such models also includes the use of deep machine learning architectures, such as convolutional or recurrent layers.<br>The weights of such layers can be seen as just additional parameters that are learned at the same time as the embeddings of entities and relations. Since they do not refer to any of the KG entities or relations, but rather affect all of them, in the Link Prediction field they &#xA0;are often called &#x201C;shared parameters&#x201D;.</p><p>Thank you for reading this far! Of course this is just an overview, and there are a lot of details worth exploring&#x2026; but that&#x2019;s a topic for another day &#x1F604; </p><p>I will just leave here some material further materials if you are curious to delve deeper into these topics:</p><ul><li>First of all, here is the <a href="https://papers.nips.cc/paper/2013/file/1cecc7a77928ca8133fa24680a88d2f9-Paper.pdf">original TransE paper</a> published in the NIPS conference in 2013. I will also leave here a link to the <a href="https://arxiv.org/pdf/1301.3781.pdf">Word2Vec paper</a> inspiring it;</li><li>I would also like to reference this <a href="https://dl.acm.org/doi/abs/10.1145/3424672">extensive comparative analysis</a> among Link Prediction models published in the TKDD Journal. I have written it myself, so I&apos;m quite proud of it!</li></ul><p>That&#x2019;s it! Have a nice day &#x1F44B;</p>]]></content:encoded></item></channel></rss>