from topk_sdk.query import select, field, fn
docs = client.collection("articles").query(
select(
"title",
paper_score=fn.semantic_similarity("paper_summary", "deep learning optimization"),
paragraph_score=fn.semantic_similarity("paragraph_summary", "stochastic gradient descent"),
)
.topk(field("paper_score") * 0.7 + field("paragraph_score") * 0.3, 10)
)
# Example results:
[
{
"_id": "2",
"title": "On the Importance of Initialization and Momentum in Deep Learning",
"paper_score": 0.9774298071861267,
"paragraph_score": 0.9783554673194885,
# "blend_score": 0.9777075052261353,
},
{
"_id": "1",
"title": "Understanding the Difficulty of Training Deep Feedforward Neural Networks",
"paper_score": 0.9773390889167786,
"paragraph_score": 0.976479709148407,
# "blend_score": 0.977081298828125,
}
]