Skip to content

SDK - Patch re-ranking #1521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pgml-sdks/pgml/src/vector_search_query_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ pub async fn build_sqlx_query(
SIden::Str("chunk"),
SIden::Str("score"),
]);
query.expr_as(Expr::cust("(rank).score"), Alias::new("rank_score"));
query.expr_as(Expr::cust("(rank).score"), Alias::new("rerank_score"));

// Build the actual select statement sub query
let mut sub_query_rank_call = Query::select();
Expand Down Expand Up @@ -364,6 +364,20 @@ pub async fn build_sqlx_query(

query
} else {
// Wrap our query to return a fourth null column
let mut vector_search_cte = CommonTableExpression::from_select(query);
vector_search_cte.table_name(Alias::new(format!("{prefix}_vector_search")));
ctes.push(vector_search_cte);

let mut query = Query::select();
query
.columns([
SIden::Str("document"),
SIden::Str("chunk"),
SIden::Str("score"),
])
.expr_as(Expr::cust("NULL"), Alias::new("rerank_score"))
.from(SIden::String(format!("{prefix}_vector_search")));
query
};

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy