Files
lancedb/docs/web/integrations/reranking/assetfeed.mdx
T
Nikolai Vysotskyi 8a27234be2 feat(python): add AssetFeed reranker (#5258)
Adds `AssetFeedReranker`, which calls the AssetFeed Cohere-style
`/rerank` endpoint (`assetfeed/assetfeed-rerank-v1`). It follows
`JinaReranker` (plain `requests`, no new dependency) and supports
vector, FTS and hybrid search with the same `return_score` options as
the Cohere reranker.

- Key from `api_key` or `ASSETFEED_API_KEY`.
- The API accepts up to 100 documents per request. More raises a clear
error before any request.
- `top_n` is only sent when set.

Python and docs only (`integrations/reranking/assetfeed`).

### Testing

- `test_assetfeed_reranker.py`: 12 tests with a mocked session, no
network.
- `test_rerankers.py`, `test_reranker_credentials.py`: pass. `ruff
check` passes.
- Not tested live: no API key was used.
2026-11-30 20:22:28 +08:00

73 lines
3.2 KiB
Plaintext

---
title: AssetFeed Reranker
sidebarTitle: "AssetFeed"
description: Rerank LanceDB vector, FTS and hybrid search results with the AssetFeed rerank API.
---
This reranker uses the [AssetFeed rerank API](https://assetfeed.com/models/reranker)
to rerank search results. Pass `AssetFeedReranker()` to the `rerank()` method. Set the
`ASSETFEED_API_KEY` environment variable or pass the `api_key` argument. Create a key at
[assetfeed.com/api-keys](https://assetfeed.com/api-keys).
> **Note:** Supported query types: Hybrid, Vector, and FTS.
<CodeGroup>
```bash Bash icon="terminal"
pip install requests
```
</CodeGroup>
The example opens a `documents` table that has an embedding function on its vector column, as in the
[AssetFeed embedding example](/integrations/embedding/assetfeed), and an [FTS index](/indexing/fts-index)
on the text column, which hybrid search needs. See [hybrid search](/search/hybrid-search) for the full setup.
<CodeGroup>
```python Python icon="python"
import lancedb
from lancedb.rerankers import AssetFeedReranker
db = lancedb.connect("./assetfeed-db")
table = db.open_table("documents")
reranker = AssetFeedReranker(top_n=5)
results = (
table.search("ETF flows", query_type="hybrid")
.rerank(reranker=reranker)
.limit(20)
.to_pandas()
)
```
</CodeGroup>
The API reranks up to 100 documents per request, and each document is truncated at
4096 tokens. The reranker raises an error when it receives more than 100 rows. Keep the search `limit` at 100 or lower for vector and FTS search, and at 50 or lower for hybrid search, which merges both result sets.
## Accepted Arguments {#accepted-arguments}
| Argument | Type | Default | Description |
| --- | --- | --- | --- |
| `model_name` | `str` | `"assetfeed/assetfeed-rerank-v1"` | The reranker model ID. |
| `column` | `str` | `"text"` | The column whose text is sent to the reranker. |
| `top_n` | `int` | `None` | The number of results to return. If None, all results are returned. |
| `api_key` | `str` | `None` | The AssetFeed API key. If not provided, the `ASSETFEED_API_KEY` environment variable is used. |
| `return_score` | `str` | `"relevance"` | Options are "relevance" or "all". If "relevance", only the `_relevance_score` column is returned. If "all", the vector (`_distance`) and FTS (`_score`) scores are kept where the query type supports it. |
## Supported Scores for each query type {#supported-scores-for-each-query-type}
### Hybrid Search {#hybrid-search}
|`return_score`| Status | Description |
| --- | --- | --- |
| `relevance` | ✅ Supported | Results only have the `_relevance_score` column |
| `all` | ✅ Supported | Results have vector(`_distance`) and FTS(`_score`) along with Hybrid Search score(`_relevance_score`) |
### Vector Search {#vector-search}
|`return_score`| Status | Description |
| --- | --- | --- |
| `relevance` | ✅ Supported | Results only have the `_relevance_score` column |
| `all` | ✅ Supported | Results have vector(`_distance`) along with the `_relevance_score` |
### FTS Search {#fts-search}
|`return_score`| Status | Description |
| --- | --- | --- |
| `relevance` | ✅ Supported | Results only have the `_relevance_score` column |
| `all` | ✅ Supported | Results have FTS(`_score`) along with the `_relevance_score` |