-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8442706
commit e46b563
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
supporting-blog-content/Cloud-Vertex-AI/search-templates/generic_kNN_search.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
PUT _scripts/google-template-knn-multioutput | ||
{ | ||
"script": { | ||
"lang": "mustache", | ||
"source": { | ||
"_source": { | ||
"excludes": [ "title_embedding", "description_embedding", "images"] | ||
}, | ||
"size": "{{num_hits}}", | ||
"knn" : [ | ||
{ | ||
"field": "description_embedding", | ||
"k": 5, | ||
"num_candidates": 10, | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "googlevertexai_embeddings_004", | ||
"model_text": "{{query}}" | ||
} | ||
}, | ||
"boost": 0.4 | ||
}, | ||
{ | ||
"field": "title_embedding", | ||
"k": 5, | ||
"num_candidates": 10, | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "googlevertexai_embeddings_004", | ||
"model_text": "{{query}}" | ||
} | ||
}, | ||
"boost": 0.6 | ||
} | ||
] | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../Cloud-Vertex-AI/search-templates/semantic_kNN_search_with_custom_dense_vector_model.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#knn template | ||
PUT _scripts/google-template-knn | ||
{ | ||
"script": { | ||
"lang": "mustache", | ||
"source": { | ||
"_source": false, | ||
"size": "{{num_hits}}", | ||
"query": { | ||
"nested": { | ||
"path": "document_text.inference.chunks", | ||
"query":{ | ||
"knn": { | ||
"field": "document_text.inference.chunks.embeddings", | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": ".multilingual-e5-small_linux-x86_64", | ||
"model_text": "{{query}}" | ||
} | ||
} | ||
} | ||
}, | ||
"inner_hits": { | ||
"size": 1, | ||
"name": "{{index_name}}.document_text", | ||
"_source": "*.text" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Run the knn templated search. | ||
GET nqdataset-simplified-clean-semantictext-e5/_search/template | ||
{ | ||
"id": "google-template-knn", | ||
"params": { | ||
"query": "italian food", | ||
"index_name": "nqdataset-simplified-clean-semantictext-e5", | ||
"num_hits": 1 | ||
} | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
...tent/Cloud-Vertex-AI/search-templates/semantic_search_with_ELSER_sparse_vector_model.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
PUT _scripts/google-template-knn-multioutput | ||
{ | ||
"script": { | ||
"lang": "mustache", | ||
"source": { | ||
"_source": { | ||
"excludes": [ "title_embedding", "description_embedding", "images"] | ||
}, | ||
"size": "{{num_hits}}", | ||
"knn" : [ | ||
{ | ||
"field": "description_embedding", | ||
"k": 5, | ||
"num_candidates": 10, | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "googlevertexai_embeddings_004", | ||
"model_text": "{{query}}" | ||
} | ||
}, | ||
"boost": 0.4 | ||
}, | ||
{ | ||
"field": "title_embedding", | ||
"k": 5, | ||
"num_candidates": 10, | ||
"query_vector_builder": { | ||
"text_embedding": { | ||
"model_id": "googlevertexai_embeddings_004", | ||
"model_text": "{{query}}" | ||
} | ||
}, | ||
"boost": 0.6 | ||
} | ||
] | ||
} | ||
} | ||
} |