Skip to content

Commit

Permalink
fix(agents-api): Add limit to kNN search. Update search_docs_by_embed…
Browse files Browse the repository at this point in the history
…ding.py (#761)

<!-- ELLIPSIS_HIDDEN -->



> [!IMPORTANT]
> Adds a limit to kNN search in `search_docs_by_embedding` to enhance
diversity based on `mmr_strength`.
> 
>   - **Behavior**:
> - Adds a limit to kNN search in `search_docs_by_embedding` to retrieve
`k*(3 if mmr_strength else 1)` candidates for diversity.
> - Adjusts the limit in both the `search_query` and
`normal_interim_query` sections.
>   - **Misc**:
>     - Updates comments to reflect the new limit logic.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral)<sup>
for edc471d. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
creatorrr authored Oct 28, 2024
1 parent 7892cd7 commit 2b74ef9
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def search_docs_by_embedding(
distance = cos_dist(query, embedding),
distance <= {radius}
:limit {k*(3 if mmr_strength else 1)} # Get more candidates for diversity
:create _search_result {{
doc_id,
index,
Expand Down Expand Up @@ -244,7 +246,7 @@ def search_docs_by_embedding(
# Sort the results by distance to find the closest matches
:sort -mmr_score
:limit {k}
:limit {k*(3 if mmr_strength else 1)} # Get more candidates for diversity
:create _interim {{
owner_type,
Expand Down

0 comments on commit 2b74ef9

Please sign in to comment.