File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
examples/agentic-streamlit-chatbot/advanced_app
vespa_shopping_assistant/vespa_module Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,18 @@ schema product {
5959 }
6060
6161 rank-profile bm25 {
62- # This best matches the 'best_fields' (default) scoring in 'multi_match' ES queries.
63- function best_bm25 () {
64- expression: max( bm25(title), bm25(description))
62+
63+ function raw_bm25 () {
64+ expression: (0.6 * bm25(title)) + (0.4 * bm25(description))
6565 }
66+ function scaled_bm25() {
67+ # Squashes the raw BM25 sum into (0, 1).
68+ # Adjust the denominator constant if you want a different curve.
69+ expression: raw_bm25 / (raw_bm25 + 11)
70+ }
71+
6672 first-phase {
67- expression: best_bm25
73+ expression: scaled_bm25
6874 }
6975 }
7076
@@ -78,9 +84,21 @@ schema product {
7884 }
7985
8086 rank-profile hybrid inherits bm25, closeness {
87+ function weighted_hybrid()
88+ {
89+ expression: 0.2 * scaled_bm25 + 0.8 * closeness_embedding
90+ }
91+ function closeness_embedding(){
92+ expression: closeness(field, embedding)
93+ }
8194 first-phase {
82- # This matches the addition of scores used in ES hybrid queries containing both 'query' ('multi_query') and 'knn'.
83- expression: best_bm25 + closeness(field, embedding)
95+
96+ expression: weighted_hybrid()
97+ }
98+ match-features {
99+ scaled_bm25()
100+ closeness_embedding()
101+ weighted_hybrid()
84102 }
85103 }
86104
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ def VespaRetriever(state: SubgraphState):
6666
6767 vespa_app = Vespa (url = VESPA_URL , cert = PUBLIC_CERT_PATH , key = PRIVATE_KEY_PATH )
6868
69- condition_uq = qb .userQuery (user_query )
69+ condition_uq = qb .userInput (user_query )
7070
7171 condition_ann = qb .nearestNeighbor (
7272 field = "embedding" ,
You can’t perform that action at this time.
0 commit comments