Shortcuts

torcharrow.functional.get_cosine_similarity

torcharrow.functional.get_cosine_similarity(input_ids: ListColumn, input_id_scores: ListColumn, matching_ids: ListColumn, matching_id_scores: ListColumn)

Return the cosine between the vector defined by input_ids weighted by input_id_scores and the vector defined by matching_ids weighted by matching_id_scores

Parameters:
  • input_ids (First list of ids) –

  • input_ids_scores (scores (weights) of input_ids) –

  • matching_ids (Second list of ids) –

  • matching_ids_scores (scores (weights) of matching_ids) –

Examples

>>> import torcharrow as ta
>>> from torcharrow import functional
>>> input_ids = ta.column([[1, 2, 3]])
>>> input_id_scores = ta.column([[1.0,2.0,3.0]])
>>> matching_ids = ta.column([[1,2,3]])
>>> matching_id_scores = ta.column([[5.0,4.0,3.0]])
>>> functional.get_cosine_similarity(input_ids, input_id_scores, matching_ids, matching_id_scores)
0  0.831522
dtype: Float32(nullable=True), length: 1, null_count: 0

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources