Skip to content
Open
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
36 changes: 34 additions & 2 deletions solutions/search/vector/dense-versus-sparse-ingest-pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,41 @@

While bringing your own text embedding model is possible, achieving strong results typically requires tuning and evaluation. Selecting a well-performing third-party model from our list is a good start. 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 lower the barrier, Elastic provides [**Elastic Learned Sparse EncodeR (ELSER)**](/explore-analyze/machine-learning/nlp/ml-nlp-elser.md), a pre-trained sparse vector model (English-only) that delivers strong out-of-the-box relevance without fine-tuning. This adaptability makes it suitable for various NLP use cases out of the box. Unless you have an ML team, we recommend starting with ELSER.
::::{dropdown} When to use dense or sparse embeddings?
:open:

Sparse vectors are mostly zeros with a small number of non-zero values. This representation is commonly used for textual data. With ELSER, both documents and queries are represented as 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. The ELSER model replaces the terms in the original query with other terms learned from the training dataset that appear in documents matching the original search terms, and assigns weights to control their importance.
Dense and sparse embeddings represent text differently, and each approach fits different search goals. The following examples illustrate typical choices.

#### Sparse embeddings [deployed-sparse-embeddings]

Use sparse embeddings when you want semantic expansion on top of keyword-style search. Sparse models such as [ELSER](/explore-analyze/machine-learning/nlp/ml-nlp-elser.md) expand queries and documents into weighted terms, which helps when users search with short phrases, acronyms, or domain vocabulary. Sparse vectors are high-dimensional vectors where most values are zero and only a small set of token weights are non-zero.

Common use cases include:

- Workplace and IT search: Find runbooks, tickets, and internal wikis when users search for error codes, service names, or team-specific jargon.
- Security and observability: Surface related alerts, playbooks, and detection rules from analyst queries that mix technical terms and natural language.
- Support and self-service: Match customer questions to help articles when the query uses product terminology that does not appear verbatim in the document.

Sparse embeddings are a practical default when you need explainable results, strong relevance for English text without training a custom model, or semantic search at scale without a dedicated {{ml}} team.

For more detail, refer to [Sparse vector search in {{es}}](sparse-vector.md).

#### Dense embeddings [deployed-dense-embeddings]

Use dense embeddings when you want to match content by overall meaning in vector space, not by overlapping keywords. Dense models map text (and other content types) to fixed-length vectors so that conceptually similar items sit close together. Dense vectors are compact arrays of floating-point values from an embedding model.

Common use cases include:

- [Context engineering for AI agents](/explore-analyze/ai-features/elastic-agent-builder.md): Combine retrieval, tools, and instructions so responses are grounded in your data. [Agent Builder](/explore-analyze/ai-features/elastic-agent-builder.md) provides an out-of-the-box toolkit for this workflow.
- [Retrieval augmented generation (RAG)](../rag.md): Retrieve document passages that answer a user's question, even when the question and the source text use different words.
Comment thread
kosabogi marked this conversation as resolved.
- [Natural language Q&A](/explore-analyze/machine-learning/nlp/ml-nlp-text-emb-vector-search-example.md): Match questions like "How do I reset my password?" to FAQ entries, product documentation, or policy pages.

Check notice on line 55 in solutions/search/vector/dense-versus-sparse-ingest-pipelines.md

View workflow job for this annotation

GitHub Actions / build / vale

Elastic.FirstPerson: Use caution when using first-person pronouns such as 'my.'
- [Recommendations and similarity](knn.md): Find related articles, products, or media. For example, you can surface articles like the current one or visually similar product images.

Dense embeddings are ideal when you care more about the semantic meaning of search terms than exact keyword matches - they excel at retrieving relevant results based on synonyms and paraphrasing of the original query to return results that reflect the user's intensions.

For more detail, refer to [Dense vector search in {{es}}](dense-vector.md).

::::

## Deploy the model in {{es}} [deployed-deploy-nlp-model]

Expand Down
Loading