Using AI to detect similar issues

Tom Moor29 Nov 2023

Problem

In a large team with a long backlog, the same bug or request is filed several times. Often the user cannot tell whether an issue already exists. At best the backlog is bigger than needed. At worst several engineers fix the same bug without knowing about each other. Keyword matching misses issues that describe the same thing in different words.

Example from the article: Linear surfaces similar issues while a user fills in a new issue, in the Triage inbox for issues from external sources, and next to incoming customer emails in support integrations.

Solution in brief

Each issue is converted to a text embedding with one API call. Similar issues are found by cosine similarity over stored vectors. The vectors live in PostgreSQL with the pgvector extension, partitioned by workspace, with an index on each partition. The same lookup serves issue creation, Triage and support tools.

Questions this case answers
  • How to detect semantically similar or duplicate records in a large multi-tenant text collection at creation time
  • How to run cosine-similarity search over tens of millions of embeddings on the existing relational database
  • How to warn a user about duplicate or related issues while they create a new one?
  • How to show existing related issues next to incoming customer messages in a support tool?

Tools and methods

  • Text embeddings — encode an issue's text so that issues with the same meaning get close vectors, even when the words differ.
  • Cosine similarity search — rank stored issues by closeness to the new one (near 1 is similar, near -1 is opposite).
  • pgvector on PostgreSQL — stores vectors and runs similarity queries in a database the team already operates.
  • Table partitioning by workspace ID — makes index builds and queries manageable at tens of millions of rows.
  • Kubernetes task runners — run the backfill in parallel.
Continue reading — it's free

Google or a one-time email code. No password.