API Reference
cosineSimilarity()
Cosine similarity over zero-padded vectors. Non-finite results normalize to 0.
Import
import { cosineSimilarity } from "@graphrefly/ts/patterns";
Signature
function cosineSimilarity(
a: readonly number[],
b: readonly number[],
): number
Parameters
| Parameter | Type | Description |
|---|---|---|
a | readonly number[] | a value used by the helper. |
b | readonly number[] | b value used by the helper. |
Returns
A number value.
Example
import { cosineSimilarity } from "@graphrefly/ts/patterns";
Source
packages/ts/src/patterns/semantic-memory.ts