agentscope.service.retrieval.similarity module

Similarity functions for retrieval

agentscope.service.retrieval.similarity.cos_sim(a: list[Number], b: list[Number]) ServiceResponse[source]

Compute the cosine similarity between two different embeddings

Parameters:
  • a (Embedding) – Embedding

  • b (Embedding) – Embedding

Returns:

A float.

Return type:

ServiceResponse