# cosine_similarity

> **Function** in `langchain_postgres`

📖 [View in docs](https://reference.langchain.com/python/langchain-postgres/_utils/cosine_similarity)

Row-wise cosine similarity between two equal-width matrices.

## Signature

```python
cosine_similarity(
    X: Matrix,
    Y: Matrix,
) -> np.ndarray
```

---

[View source on GitHub](https://github.com/langchain-ai/langchain-postgres/blob/fe71c5b03f857bbc810ebdc7b3ea4091af5e1ec9/langchain_postgres/_utils.py#L16)