Skip to content

Embedding Similarity

Embedding Similarity compares two numeric fingerprints of meaning (embeddings) and returns a score that shows how similar the two texts they come from are. This tells you whether two texts say the same thing even when they are written with different words.

The fingerprints come from Text Embedder: one for each text you want to compare.

When to use it

  • Find out whether a customer’s message is about the same matter as a reference sentence, for example a complaint or a return.
  • Detect repeated incidents or requests that are worded differently.
  • Check whether two product descriptions say the same thing.

Configuration

ConnectionWhat to connect
Embedding VectorsThe two fingerprints to compare: connect the Embedding Data output of two Text Embedder components here. There must be exactly two.
FieldWhat it does
Similarity MetricHow similarity is measured. Cosine Similarity (default): the closer to 1, the more similar the two texts are. Euclidean Distance and Manhattan Distance: they measure the distance between the two fingerprints, so the smaller the value, the more similar they are; 0 means they are identical.

Output

  • Similarity Data: a data item with the two fingerprints compared and the score in similarity_score, under the name of the chosen measure (cosine_similarity, euclidean_distance or manhattan_distance). You can pass it to a component that works with data, for example to keep only the score and decide what the flow does next.

Example

The online shop Calzados Brisa wants to alert its team when a message looks like a complaint about an order that has not arrived.

  1. Connect the same embeddings component, for example OpenAI Embeddings, to two Text Embedder components.
  2. In the first one, the customer’s message; in the second one, the sentence “My order has not arrived yet”.
  3. Connect both Embedding Data outputs to Embedding Vectors of Embedding Similarity, with Similarity Metric set to Cosine Similarity.
  4. Use the score in Similarity Data to decide whether the message goes to the complaints team.

Good practices

  • Try a few real messages before deciding from which score you consider that two texts are about the same thing: the right value depends on your texts and on the embeddings model.