Setting up a semantic search UI for your data

min read

What do you mean?

(Eager to get stuck in? Jump straight to setting up semantic search in Relevance AI.)

Humans search for data. Although we’re used to making accommodations for computers with specific phrasing and technical operators, this asks us to concern ourselves with what computers mean instead of what we mean. Fortunately, there are strides in search technology which seek to reverse that approach.

By the end of this article we’ll even implement them in a production app with just a few minutes of configuring.

Search engines often go some way to interpret what we mean using fuzzy search, also known as fuzzy matching or approximate string matching. Implementing fuzzy search handles queries that are ‘close enough’ to a term found in the results, most commonly used for typos.

relevnt = relevant

(Handling typos in fuzzy search)

This helps us when we’re tapping out a fat-fingered mobile message, looking for words with diácritїcs, or indeed, forgetting that a new tech company plays fast and loose with vowels in its name.

Strictly speaking however, fuzzy search only helps to interpret what we mean to put in, not what we want to get out. How would a search which understood the qualitative meaning of our input behave?

It’s movie night and you’re in the mood for a classic whodunnit. Do you look in the “crime” category? Cop dramas and crime documentaries abound, but they’re not what you’re after. “Murder” returns some too-intense thrillers and you’ve already seen everything listed under your favourite director.

Blue and white striped seersucker suit jacket by Kent Wang

(“Seersucker” by Kent Wang)

Imagine seeing the style of suit above and trying to describe it to someone. You’d be excused for thinking “blue and white stripey suit” sooner than you reached for the term “seersucker”!

Times like these are where ✨semantic search✨ can save the day. When you search for a term like “blue and white stripey suit” using semantics, the meaning of that term is evaluated to give you relevant results.

Google Image Search results for

(Google Image Search understanding what we mean)

Intelligent search results like these use vectors which power Google image search, Spotify recommendations and Shopify’s product categorisations. Broadly, the resources required to generate and deploy vectors have only been the domain of these giant tech companies.

Today, Relevance AI productionises vectors for you and lets you employ semantic powers without the hefty investment. The only thing you need to think about is your data.

Follow along to see for yourself! All you need is:

  1. Your data as a CSV file with column headers or JSON file with object keys (we’ll provide a sample file if you just want to test things out)
  2. A free account on
  3. A mind to be blown

With those ready, head to the datasets page in the Relevance AI Playground to create and name a new dataset to configure search apps for.

Creating and naming your new dataset in Relevance AI

From there, upload the data you want to use for semantic search. Don’t worry if you don’t have anything of your own right now— if you just want to see what vectors can do, grab our sample of movie listings from the page and upload that instead.

Uploading CSV or JSON dataset in Relevance AI

Once your data is uploaded, it needs to be encoded into vectors (vectorised) for semantic search to work. Thankfully, Relevance AI takes care of the heavy lifting and all you need to do is choose which fields to vectorise. Some useful choices would be qualitative fields like titles, descriptions and tags, but not those with little semantic meaning.

Table showing that fields like title, description and tags are good, username is questionable and url is bad.

Once you’ve chosen, encoding may take a while depending on the number of entries in your dataset and how many fields you’ve chosen to vectorise.

Deploying your Search App

While Relevance AI is busy generating vectors for your fields, head to Deploy > Discovery to create a new Search App which will allow you to query your data.

Creating a new Search App in Relevance AI

We now have a search UI that uses your dataset! Results are snappy, it handles fuzzy search and you could even share this Search App right now via the Export button. We’re about to enhance this search further, but feel free to try out a few queries to see what results you get.

Search App user interface in Relevance AI

To truly make this yours as well as employ ✨semantic search✨ however, we’ll want to Configure it first, which you can begin using the button in the top right. There are a range of ways to customise your Search App, so let’s go through the most noticeable options:

  • Vectors To Search: If the fields you chose to vectorise earlier have finished encoding, you’ll be able to add them here so that the qualitative meaning of field values will be factored into your results. As you may have guessed, this is what enables ✨semantic search✨ so don’t skip it!
  • Text Fields to Search: These are the fields that will be used for traditional fuzzy search. You may want to exclude those that aren’t text-based like numeric or boolean fields.
  • Image fields to display: You can customise how your results appear and if any of your fields contain the URL to an image, you can choose to display them here.
  • Text fields to display: The fields to search with don’t have to be same as those displayed. For example, if you want to use a description field to base results on but want to keep your results minimal, you can omit it from this option. Note that for longer result values, we also automatically truncate text with a “read more” button.
  • Header field: The title that will be used for each result listed. Use this to prominently show the most identifying piece of information for a result.
  • App name: You can either configure the name in configuration settings, or by simply clicking and editing the name while you’re in the Search App. This will help distinguish your search and its configuration if you create multiple Search Apps

With the vector fields added, your Search App will now understand the qualitative meaning of what you want! Give it a whirl and see how you get relevant results even if the text fields don’t include your query. That’s the power of vectors and— one last time— ✨semantic search✨.

Search App user interface in Relevance AI using vectors for semantic search results

(Now we’re cooking with vectors)

Hit Export to get a public URL of your Search App that anyone can access without login. You can share this with other stakeholders, embed it in your site or bookmark it to query your dataset at any time.

If you’re interested in programatically using semantic search via our API, check out our more hands on article, End to End Semantic Search via API.

Setting up a semantic search UI for your data
Benedek Zajkas
September 22, 2021