Skip to content
AI & DataUpdated at

Introduction to Semantic Web

A gentle introduction to the new paradigm in the Web

The model behind the Web could be roughly summarized as a way to publish documents represented in a standard way (HTML), containing links to other documents and accessible through the Internet using standard protocols (TCP/IP and HTTP). The result is a worldwide, distributed file system of interconnected documents humans can read, exchange and discuss.

tldr;

Before the Web, if I wanted to follow a citation I had to physically hunt down the reference in a library. The Web's great invention, the hyperlink, changed that: click a link and you are at the next document in the chain, which is why Web 1.0 was the web of read-only documents. Web 2.0 brought interactive, social applications, but they were silos that do not interoperate; updating your profile on one social network does nothing to your profile on another, and the same lack of linking plagues data inside enterprises. Web 3.0 is about connecting the data itself, not the documents but the data at lower levels, to facilitate machine-to-machine communication.

In summary, the great advantage of Web 1.0 was that it abstracted away the physical storage and networking layers involved in information exchange between two machines. This breakthrough enabled documents to appear to be directly connected to one another. Click a link, and you're there, even if that link goes to a different document on a different machine on another network on another continent! So, in the same way that Web 1.0 abstracts away the network and physical layers, the Semantic Web abstracts away the document and application layers involved in the exchange of information.

The aim of the Semantic Web is to solve the most problematic issues that come with the growth of the non-semantic (HTML-based or similar) Web that results in a high level of human effort for finding, retrieving and exploiting information

The Semantic Web connects facts so that rather than linking to a specific document or application, you can instead refer to a specific piece of information contained in that document or application. If Ahmad changes his blog's title, the identifier for his blog stays the same. An application that saved the old title still needs to fetch the new one.

The word semantic itself implies meaning or understanding. A table in a relational database can record the owner of a blog. To interpret that table, a reader needs to know what its owner column means. On the Semantic Web, we can publish the meaning of that relationship alongside the data. Shared meanings help when an application combines data from several sources. For a system recording large volumes of transactions under one stable schema, they may matter less than the cost of each write.

What "semantic" means in the Semantic Web is not that computers will understand the meaning of anything but that the logical pieces of meaning can be mechanically manipulated by a machine to valuable ends.

So now imagine a new Web where the actual content can be manipulated by computers. For now, picture it as a web of databases. One site publishes Ahmad's profile, another lists his blog, and the blog publishes its articles. How could a reader start from his profile and discover those articles without each site keeping a copy of the others' records?

A publisher can give the links in its data explicit meanings, such as owning a blog or writing a post. Nothing stops anyone from writing a program now to do those sorts of things, just like nothing stopped anyone from exchanging data before we had XML. But standards facilitate building applications, especially in a decentralized system.

A Uniform Resource Identifier (URI) can name a person or a blog as well as a document. If two publishers use the same identifier for Ahmad, a reader can follow facts about him across their records. If they each use a different identifier, the spelling alone doesn't tell us whether they mean the same person. W3C guidance on URIs

Why do RDF, RDFS, OWL, SPARQL and SHACL have separate names?

Suppose we’re building a directory of blogs. Someone submits an entry for Ahmad and his blog. We want to publish that information, include the blog when someone searches for websites, and tell the submitter if they’ve left out the name we need to display. The acronyms start to make sense when we look at each of those jobs.

RDF records a fact. In “the blog has Ahmad as its owner,” the blog is the subject, the ownership relationship (aa:owner) is the predicate, and Ahmad is the object. Here aa: stands for our local vocabulary. Together they make a triple. RDF, the Resource Description Framework, uses IRIs (Internationalized Resource Identifiers) to name things and relationships. Here http://assaf.website/blog identifies the blog. A second triple gives it the name Ahmad Assaf's Blog. Someone else can use the same identifier to say more about that blog, even if they use a different name for it. RDF concepts

RDFS describes categories. Our directory has a page listing websites. Ahmad’s submission says that his site is a Blog. Should it appear on that page? In RDF Schema we can say that our aa:Blog is a subclass of schema:WebSite. The schema: prefix stands for the Schema.org vocabulary, which supplies the website class. Software applying that rule can infer that Ahmad’s blog is a website. We write the subclass statement once, and it applies to every blog in the directory. RDF Schema

OWL lets us define a category through a relationship. Suppose the directory also has a page for People with blogs. In OWL, the Web Ontology Language, we can define aa:ownsBlog as the inverse of aa:owner. A link from the blog to Ahmad then implies that Ahmad owns the blog. We can define People with blogs as people who own at least one blog. Given that Ahmad is a person and the site is a blog, an OWL reasoner can use the ownership link and our definition to classify him. The definition is part of the ontology. The reasoner is the software that draws the conclusion. OWL primer

SPARQL asks a question. What is the name of Ahmad’s blog? In SPARQL (SPARQL Protocol and RDF Query Language), we can answer that by matching two patterns. First, find a blog whose aa:owner is Ahmad and bind the blog to a variable. Then use that same variable to look up its aa:hasName value. The answer in our data is Ahmad Assaf's Blog. Asking for everyone classified under People with blogs is a different query: it can see that classification if the inferred fact has been stored or the query service supplies it through reasoning. SPARQL query language

SHACL checks what someone submitted. Now remove the blog’s name from the submission. We still know it’s a blog, and the RDFS rule still lets us infer that it’s a website. But what should the directory display? With SHACL, the Shapes Constraint Language, we can write a shape for blog entries that requires at least one aa:hasName value. A validator can then report which entry is missing its name. That distinction matters in practice: the inference tells us where to list the blog; the validation report tells us what to ask the submitter to fix. SHACL

I go into the details of writing triples in my RDF post and matching them in my SPARQL guide.

Other technologies can help us describe and search the information on the Web.

  • Natural-language processing (NLP): NLP technologies attempt to process unstructured text content and extract the names, dates, organizations, events, etc., discussed within the text. There are many extensions of NLP, and they include:

    • Search: Entity extraction picks out names in text. On this blog it might find both “Ahmad” and “Ahmad Assaf.” The directory can check the author link before treating those mentions as references to the same person.
    • Auto-categorization: A program can group the blog's articles by topic so readers can browse them.
    • Sentiment Analysis measures whether the tone of a piece of text is positive, negative, or neutral. A blog editor might use it to find comments that need a closer read.
    • Summarization: Often used in conjunction with research applications, summaries of topics are created automatically so that people do not have to wade through many long-winded articles (perhaps such as this one!).
    • Question Answering: At the time, this was the hot topic in NLP, as evidenced by Siri and Watson. However, long before these tools, we had Ask Jeeves (now Ask.com) and later Wolfram Alpha, which specialized in question-answering. The idea here is to ask a computer a question and have it answer you (Star Trek-style! "Computer…").
  • Data mining: Data mining technologies employ pattern-matching algorithms to tease out trends and correlations within large data sets.

  • Artificial intelligence or expert systems: AI or expert systems technologies automatically use elaborate reasoning models to answer complex questions. These systems often include machine-learning algorithms that can improve the system's decision-making capabilities over time.

  • Classification: Classification technologies use heuristics and rules to tag data with categories to help search and analyze information.

  • Semantic search: A search for articles by Ahmad asks a different question from a search for articles that mention Ahmad. A search service can use an explicit author link to tell the two apart.

The main goal behind knowing these technologies is that they help us assemble the Semantic Web's building blocks. For example, NLP can extract structured data from unstructured documents (flat files like text documents). This data is then linked via Semantic Web technologies to other published data. This bridges the gap between documents (unstructured data) and structured data.

What does that all mean in practice?

The Semantic Web is a vision about an extension of the existing World Wide Web, which provides software programs with machine-interpretable metadata of the published information and data. For a blog post, the metadata can say who wrote it even if the author's name never appears in the article text.

What's behind the original vision of the Semantic Web comes under the umbrella of three things: Automation of information retrieval, the Internet of Things and Personal Assistants. You can read more about all three in the seminal article by Tim Berners-Lee, James Hendler and Ora Lassila, published in Scientific American: The Semantic Web.

The ultimate ambition of the Semantic Web, as its founder Tim Berners-Lee sees it, is to enable computers to better manipulate information on our behalf. He further explains that, in the context of the Semantic Web, the word "semantic" indicates machine-processable or what a machine is able to do with the data, whereas "web" conveys the idea of a navigable space of interconnected objects with mappings from URIs to resources.

Linked Open Data (LOD)

Linked Data gives publishers a way to name things and connect their descriptions across sites. Linked Open Data also gives others permission to reuse the data under an open license. Tim Berners-Lee set out four rules for publishing Linked Data. Linked Data · Open Definition

  • Use URIs as names for things.
  • Use HTTP URIs so that people can look up those names.
  • When someone looks up a URI, provide useful information using the standards such as RDF and SPARQL.
  • Include links to other URIs so that they can discover more things.

The Four Rules Applied

Suppose one table holds Ahmad's profile and another holds the blog's details. The blog row has an internal key for its owner. A reader on another site can't follow that key. Here's how I'd publish the link.

  1. Give Ahmad and his blog distinct names. In our example, http://assaf.website/triples#ahmadassaf identifies Ahmad and http://assaf.website/blog identifies the blog. I can keep the database keys I already use.
  2. Serve descriptions at those HTTP addresses. Looking up Ahmad's identifier should take a reader to information about him.
  3. Return RDF describing the resource. For the blog, one triple gives its title, “Ahmad Assaf's Blog.”
  4. Link the blog to its owner using Ahmad's identifier. A reader can follow that link to his profile, even if a different site publishes the profile data.

From keywords to named entities

A search for the words “Ahmad Assaf” can turn up articles he wrote and articles that mention him. Structured data lets a publisher identify him as the author of a particular page.

Consider the page you're reading. A search engine can analyze the text and find phrases like structured data and knowledge graph. It can also read the page's metadata. There, a publisher can explicitly identify the article, its author and its publication date. Google's introduction to structured data

Examples of Using Structured Data

Rich Snippets

If Ahmad marks up a post with its headline, author and publication date, a search engine can use those details when it displays the article in results. The markup makes that information available. The search engine decides what to show. Google's article markup guide

Global Knowledge Graphs

A knowledge graph can bring descriptions from several pages together. If the blog and its articles use the same identifier for Ahmad, a graph using those descriptions can connect him to the blog he owns and the posts he wrote.

Structured Data Standards

A publisher needs terms for the things a page describes and a syntax for writing those descriptions.

  • Schema.org: A standard vocabulary of entities defined by major search engines like Google.
  • Microdata: Embedding structured data within HTML markup.
  • JSON-LD: A JSON syntax for Linked Data. A publisher can serve a JSON-LD document on its own or embed it in an HTML page.
  • RDFa: A syntax for embedding RDF in HTML.

Page markup is one source of information for a knowledge graph. When Google introduced its Knowledge Graph in 2012, it named Freebase, Wikipedia and the CIA World Factbook among its sources. Google's Knowledge Graph announcement

Knowledge graphs in practice

An organization can use the same approach with its own records. Suppose a staff directory uses “blog owner” for the person who runs the site, while the catalog uses it for the person who owns the blog. An ontology can give administration and ownership distinct definitions, so a reader can ask about either relationship when the records are combined.

I find these ideas relevant to large language models because a model can give a fluent but incorrect answer. A retrieval system can supply a model with a passage of text. For a question about who owns a blog, it can also retrieve the triple that links the blog to its owner. That gives me a specific record to check if the model names someone else.

You can read more information about Knowledge Graphs in my post here.

The opinions and views expressed on this blog are solely my own and do not reflect the opinions, views, or positions of my employer or any affiliated organizations. All content provided on this blog is for informational purposes only.

I'm glad to speak at events, join a panel or a podcast, or compare notes on AI, knowledge graphs and engineering leadership. Get in touch if you'd like to talk.