> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aurelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# semantic_router.linear

#### similarity\_matrix

```python theme={null}
def similarity_matrix(xq: np.ndarray, index: np.ndarray) -> np.ndarray
```

Compute the similarity scores between a query vector and a set of vectors.

**Arguments**:

* `xq`: A query vector (1d ndarray)
* `index`: A set of vectors.

**Returns**:

`np.ndarray`: The similarity between the query vector and the set of vectors.

#### top\_scores

```python theme={null}
def top_scores(sim: np.ndarray,
               top_k: int = 5) -> Tuple[np.ndarray, np.ndarray]
```

Get the top scores and indices from a similarity matrix.

**Arguments**:

* `sim`: A similarity matrix.
* `top_k`: The number of top scores to get.

**Returns**:

`Tuple[np.ndarray, np.ndarray]`: The top scores and indices.
