-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[DOCS] Rework semantic search main page #112452
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
szabosteve
merged 11 commits into
elastic:main
from
szabosteve:rework-semantic-search-main
Sep 12, 2024
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fc0320a
[DOCS] Rework semantic search main page.
szabosteve 42acb0e
[DOCS] Improves prose.
szabosteve a33a930
Apply suggestions from code review
szabosteve d633faa
[DOCS] Addresses feedback.
szabosteve 32041ab
Update docs/reference/search/search-your-data/semantic-search.asciidoc
szabosteve 6d2e20d
[DOCS] Adds subheadings.
szabosteve bad32e0
Merge branch 'rework-semantic-search-main' of github.com:szabosteve/e…
szabosteve 102590d
Apply suggestions from code review
szabosteve 7503c4d
[DOCS] More edits.
szabosteve 4e0a49e
Apply suggestions from code review
szabosteve 340926c
[DOCS] Addresses feedback.
szabosteve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
docs/reference/search/search-your-data/semantic-search-deploy-model.asciidoc
This file contains hidden or 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,92 @@ | ||
[[semantic-search-deployed-nlp-model]] | ||
=== Tutorial: semantic search with a deployed model | ||
|
||
++++ | ||
<titleabbrev>Semantic search with deployed model</titleabbrev> | ||
++++ | ||
|
||
IMPORTANT: For the easiest way to perform semantic search in the {stack}, refer to the <<semantic-search-semantic-text, `semantic_text`>> end-to-end tutorial. | ||
|
||
This guide shows you how to implement semantic search with models deployed in {es}: from selecting an NLP model, to writing queries. | ||
|
||
|
||
[discrete] | ||
[[deployed-select-nlp-model]] | ||
==== Select an NLP model | ||
|
||
{es} offers the usage of a {ml-docs}/ml-nlp-model-ref.html#ml-nlp-model-ref-text-embedding[wide range of NLP models], including both dense and sparse vector models. | ||
Your choice of the language model is critical for implementing semantic search successfully. | ||
|
||
While it is possible to bring your own text embedding model, achieving good search results through model tuning is challenging. | ||
Selecting an appropriate model from our third-party model list is the first step. | ||
Training the model on your own data is essential to ensure better search results than using only BM25. | ||
However, the model training process requires a team of data scientists and ML experts, making it expensive and time-consuming. | ||
|
||
To address this issue, Elastic provides a pre-trained representational model called {ml-docs}/ml-nlp-elser.html[Elastic Learned Sparse EncodeR (ELSER)]. | ||
ELSER, currently available only for English, is an out-of-domain sparse vector model that does not require fine-tuning. | ||
This adaptability makes it suitable for various NLP use cases out of the box. | ||
Unless you have a team of ML specialists, it is highly recommended to use the ELSER model. | ||
|
||
In the case of sparse vector representation, the vectors mostly consist of zero values, with only a small subset containing non-zero values. | ||
This representation is commonly used for textual data. | ||
In the case of ELSER, each document in an index and the query text itself are represented by high-dimensional sparse vectors. | ||
Each non-zero element of the vector corresponds to a term in the model vocabulary. | ||
The ELSER vocabulary contains around 30000 terms, so the sparse vectors created by ELSER contain about 30000 values, the majority of which are zero. | ||
Effectively the ELSER model is replacing the terms in the original query with other terms that have been learnt to exist in the documents that best match the original search terms in a training dataset, and weights to control how important each is. | ||
|
||
|
||
[discrete] | ||
[[deployed-deploy-nlp-model]] | ||
==== Deploy the model | ||
|
||
After you decide which model you want to use for implementing semantic search, you need to deploy the model in {es}. | ||
|
||
include::{es-ref-dir}/tab-widgets/semantic-search/deploy-nlp-model-widget.asciidoc[] | ||
|
||
|
||
[discrete] | ||
[[deployed-field-mappings]] | ||
==== Map a field for the text embeddings | ||
|
||
Before you start using the deployed model to generate embeddings based on your input text, you need to prepare your index mapping first. | ||
The mapping of the index depends on the type of model. | ||
|
||
include::{es-ref-dir}/tab-widgets/semantic-search/field-mappings-widget.asciidoc[] | ||
|
||
|
||
[discrete] | ||
[[deployed-generate-embeddings]] | ||
==== Generate text embeddings | ||
|
||
Once you have created the mappings for the index, you can generate text embeddings from your input text. | ||
This can be done by using an | ||
<<ingest,ingest pipeline>> with an <<inference-processor,inference processor>>. | ||
The ingest pipeline processes the input data and indexes it into the destination index. | ||
At index time, the inference ingest processor uses the trained model to infer against the data ingested through the pipeline. | ||
After you created the ingest pipeline with the inference processor, you can ingest your data through it to generate the model output. | ||
|
||
include::{es-ref-dir}/tab-widgets/semantic-search/generate-embeddings-widget.asciidoc[] | ||
|
||
Now it is time to perform semantic search! | ||
|
||
|
||
[discrete] | ||
[[deployed-search]] | ||
==== Search the data | ||
|
||
Depending on the type of model you have deployed, you can query rank features with a <<query-dsl-sparse-vector-query, sparse vector>> query, or dense vectors with a kNN search. | ||
|
||
include::{es-ref-dir}/tab-widgets/semantic-search/search-widget.asciidoc[] | ||
|
||
|
||
[discrete] | ||
[[deployed-hybrid-search]] | ||
==== Beyond semantic search with hybrid search | ||
|
||
In some situations, lexical search may perform better than semantic search. | ||
For example, when searching for single words or IDs, like product numbers. | ||
|
||
Combining semantic and lexical search into one hybrid search request using <<rrf,reciprocal rank fusion>> provides the best of both worlds. | ||
Not only that, but hybrid search using reciprocal rank fusion {blog-ref}improving-information-retrieval-elastic-stack-hybrid[has been shown to perform better in general]. | ||
|
||
include::{es-ref-dir}/tab-widgets/semantic-search/hybrid-search-widget.asciidoc[] |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.