[go: nahoru, domu]

Skip to content

Similarities of Sentence Pairs

Tianyu Gao edited this page May 19, 2021 · 1 revision

Our package also provides a way to easily calculate (cosine) similarities between two sentences:

model.similarity(queries, keys, device=None)

Inputs

  • queries: a string or a list of n strings.
  • keys: a string or a list of m strings.
  • device: cuda or cpu.

Outputs

  • A float if queries and keys are both single sentence. Otherwise the function returns a numpy array of size n * m.