Skip to content
Murmurly
All posts

How we group similar feedback with embeddings

Daniel Osei3 min read

Paper notes sorted into three round piles by colour on a desk, with one blue note lying apart from the piles.

“Can I export to Excel?” and “I need my data in a spreadsheet” share almost no words, but they ask for the same thing. Murmurly has to see that, thousands of times a day, across email, chat and app reviews. This post explains how.

Why keywords weren’t enough

Our first version matched keywords. It grouped “dark mode” with “dark mode” and missed “night theme” completely. Adding synonyms by hand worked for a week, then customers found new ways to say the same thing.

Messages as numbers

Today every message becomes an embedding: a list of numbers that describes its meaning. Messages that mean similar things get similar numbers, even when the words are different.

To compare two messages, we measure the angle between their lists, called cosine similarity. 1 means “same meaning”, 0 means “unrelated”.

similarity.ts
/** How alike two embeddings are: 1 = same meaning, 0 = unrelated. */
export function cosineSimilarity(a: number[], b: number[]): number {
  let dot = 0;
  let normA = 0;
  let normB = 0;
  for (let i = 0; i < a.length; i++) {
    dot += a[i] * b[i];
    normA += a[i] * a[i];
    normB += b[i] * b[i];
  }
  return dot / (Math.sqrt(normA) * Math.sqrt(normB));
}

Choosing the threshold

A new message joins the closest existing request if the similarity is above a threshold. Otherwise it starts a new request.

group.ts
// "Export to CSV" and "Import from CSV" score 0.84: just below the line.
const SAME_REQUEST = 0.86;

export function findRequest(message: Embedded, requests: Request[]) {
  const best = requests
    .map((request) => ({
      request,
      score: cosineSimilarity(message.vector, request.centroid),
    }))
    .sort((a, b) => b.score - a.score)[0];

  return best && best.score >= SAME_REQUEST ? best.request : undefined;
}

We picked 0.86 by hand-labelling 2,000 message pairs from our own inbox. Lower values merged “export to CSV” with “import from CSV”, which is the opposite request. Higher values split one request into five.

When a human decides

Between 0.78 and 0.86, Murmurly doesn’t guess. It suggests a merge and lets someone on the team accept or reject it. Those answers become new labelled pairs, so the threshold keeps improving.

Keeping it fast

Comparing every new message with every request would get slow as a team grows. So each request keeps a centroid: the average of its messages’ embeddings. A new message is compared with the centroids only, which is a few hundred comparisons instead of tens of thousands. When a message joins a request, we update request.centroid in the same step.

We also embed each message only once, when it arrives, and store the numbers next to it. Re-grouping after a threshold change then takes seconds and costs nothing extra.

The result

About 9 in 10 messages are grouped on their own, and the rest take a second each to check. Nobody tags feedback by hand any more, and the counts on the roadmap are counts you can trust.

Daniel Osei · Co-founder & CTO

Daniel wrote the first script that counted every request. Today he leads how Murmurly reads and groups feedback.

Find out what your customers keep asking for

Connect your first channel in minutes. Free to start, no card needed.