Skip to content
Lucerna Law

Getting started with legal AI

Semantic Search for Lawyers: Matching by Meaning

By Published 8 min read

Semantic search finds text by meaning instead of by matching words. For lawyers, that means a search for "fired" can surface an email that says "let go" or "terminated," which a keyword search would skip. The trade is precision: matching by meaning is weaker at exact names, dates, numbers and phrases, so the two methods work best together.

Semantic search ranks passages by how close their meaning is to the query, even when they share no words with it. Keyword search returns passages that contain the query's words, or the combinations a lawyer builds with connectors. Keyword search is exact and literal. Semantic search is approximate and conceptual, and each fails where the other succeeds.

Microsoft's overview of vector search in Azure AI Search gives the plainest example. It says matching by vectors supports "semantic or conceptual likeness," and offers "dog" and "canine," which are "conceptually similar but linguistically distinct." The same page says it can match "dog" in English with "hund" in German.

Lawyers already know keyword search well. Terms and connectors, root expanders and proximity limits are the craft of telling a database exactly what to find, and the post on case law search sets out the syntax in two systems. The weakness of that craft is familiar too: the searcher has to guess the words the author used.

Keyword searchSemantic search
What it matchesThe words typed, or a combination built with connectorsPassages whose meaning is close to the query
Finds synonyms and paraphraseOnly those you listOften, without being told
Finds an exact name, number or phraseReliablyLess reliably
Can explain why a passage came backYes: it contains the wordsNot in plain terms; it was "near"
Typical failureMissing a document that used other wordsReturning a passage on the right topic that is not the one you meant

The fourth row matters in practice. A keyword hit can be defended: the document contains the term. A semantic hit came back because a calculation placed it near the question, and the tool usually cannot say more than that.

How semantic search turns words into numbers

Semantic search depends on embeddings: lists of numbers that a model assigns to a piece of text so that texts with related meanings receive nearby lists. A search tool computes an embedding for each stored passage once, computes one for the question, then returns the passages whose numbers are closest.

OpenAI's guide to embeddings defines an embedding as "a vector (list) of floating point numbers" and says "the distance between two vectors measures their relatedness," with small distances suggesting "high relatedness" and large ones "low relatedness." It lists search, clustering, recommendations and classification among the uses.

Semantic search in four steps, as the Microsoft and OpenAI pages cited here describe it
  1. 01

    Split

    Documents are broken into passages, sometimes called chunks

  2. 02

    Embed

    A model turns each passage into a list of numbers

  3. 03

    Embed the question

    The same model turns the query into a list of numbers

  4. 04

    Rank by nearness

    Passages whose numbers sit closest to the query's come back first

Three practical consequences follow from that design.

  1. The embedding model has its own limits. It was trained like any language model. OpenAI's guide notes that two of its embedding models "lack knowledge of events that occurred after September 2021." A term that entered use later may be placed poorly.
  2. The passage size shapes the result. A tool that cuts documents into long chunks returns long chunks, and a single relevant sentence can be diluted by the paragraphs around it. A tool that cuts very small can lose the context that made a sentence meaningful.
  3. Nearness is relative. A semantic search almost always returns something, because some passage is always the nearest. "Closest" is not the same as "relevant," and a ranked list of weak matches looks just like a list of strong ones.

The legal AI glossary defines embeddings, passages and the other retrieval terms in a sentence or two each.

Where semantic search helps a lawyer find what keywords miss

Semantic search helps most where the author's words cannot be guessed: witnesses describing the same event differently, employees using slang or euphemism, translated or multilingual material, and concepts with many phrasings. In discovery and in a client's own files, the language is rarely the language a lawyer would choose, which is where matching by meaning earns its place.

Some examples where a keyword list tends to fall short:

  • Euphemism. "We need to part ways," "it isn't working out," and "your last day will be Friday" all describe a termination without the word.
  • Informal messages. Text messages and chat logs use abbreviations, misspellings and emoji that no search list anticipates.
  • Concepts. "Retaliation" is a legal conclusion. The documents will describe a schedule change, a missed promotion or a cold shoulder.
  • Other languages. Microsoft's vector search page says matching by vectors can work across languages, as with "dog" in English and "hund" in German, and points to embedding models trained in multiple languages for multilingual search.

The ABA's Formal Opinion 512 notes in passing that "for basic legal research, AI may enhance lawyers' search results." It says nothing about which search method does so, and it does not describe semantic search.

The same idea runs through legal research tools that retrieve passages before a model writes an answer. How those tools work, and the errors their design allows, is covered in AI legal research.

Why does semantic search miss names, dates and exact phrases?

Semantic search misses exact items because it compares meanings, and a name, a date or an invoice number carries little meaning apart from itself. Two different dates sit near each other in meaning. So do two people with similar roles. A search that should return one exact match may return several plausible near-misses ahead of it.

Microsoft's hybrid search overview says so in its own terms: "Some scenarios, such as querying over product codes, highly specialized jargon, dates, and people's names, perform better with keyword search because it can identify exact matches." For a lawyer, that list covers a large share of what gets searched: Bates numbers, defined terms, party names, claim numbers and dates of key events.

Other cases where matching by meaning is a poor fit, on this post's reading of how the method works:

  • Negation. "The tenant signed the lease" and "the tenant never signed the lease" share almost every word and the same topic. Whether a given embedding model places them far apart cannot be assumed. It has to be tested.
  • Quoted language. Looking for every use of a precise contract phrase, such as "commercially reasonable efforts," is a keyword task.
  • Completeness. When the question is "every message from this sender in March," a ranked list by similarity is the wrong tool. A filter on sender and date is the right one.

The same limit appears when an AI tool selects passages to send a model with a question. The post on the AI context window explains what selection does to questions about "everything" and "nothing".

Hybrid search: running keyword and semantic search together

Hybrid search runs a keyword search and a semantic search on the same query and merges the two ranked lists. The aim is to keep the precision of exact matching for names and numbers while still catching passages that use different words. Microsoft's search service offers it, and a lawyer can ask whether a given tool does.

Microsoft's hybrid overview describes it as "a single query request configured for both full-text and vector queries" that runs both "in parallel" and merges the results with a method called Reciprocal Rank Fusion. It says hybrid search "combines the strengths of vector search and keyword search," and its vector search page says the combination "often provides better results than vector or keyword search alone."

What hybrid search does not do is make ranking transparent. A merged list blends two scoring methods, and the reason a passage ranked third is harder to state than for either method alone. For work where a lawyer must later explain how documents were found, such as a search protocol agreed with the other side, a record of the actual terms and settings used is part of the job.

Lucerna Law, for comparison, describes two different mechanisms in its own files. The project's README says the search box in a matter matches chats, file names and passage text by "a plain, case-insensitive 'contains'," which is a literal match. For answering questions, the homepage says a matter of up to about 150 single-spaced pages goes to the model whole, and from a larger one "only the passages that best match the question." Its product section describes what can be asked.

How should a lawyer test a semantic search tool on a known file?

A lawyer can test a semantic search tool by running it on a set of documents whose contents are already known, with questions whose right answers are already written down. Count what it finds, what it misses and what it ranks above the right answer. A few hours on a closed matter says more than any description of the method.

A test plan that fits in an afternoon:

  • Pick a closed matter. Use documents the team knows well, and confirm the firm's rules allow loading them into the tool.
  • Write ten questions with known answers. Include paraphrase questions ("when was she told her job was ending?") and exact questions ("every mention of invoice 4471").
  • Include a negation. Ask for evidence that something did not happen and see whether the tool returns passages saying it did.
  • Include a name and a date. These are where the Microsoft page says keyword search does better.
  • Run the same questions as keyword searches. Compare which method found each known passage.
  • Record the misses. A miss on a known answer is the most useful result of the test, because it shows the kind of question to double-check later.

The results tell a team when to trust the tool's first page of results and when to fall back on keywords or a filter. Neither method is complete alone. Used together, with an understanding of what each one cannot see, they cover more of a file than either does.

Search that finds the right passages is only the first half of an AI answer. What the model then does with them, including whether it works through the problem step by step, is the subject of the post on AI reasoning models for lawyers.