langchain/docs/modules/models/text_embedding/examples
Jeff Vestal 0b542a9706
Add ElasticsearchEmbeddings class for generating embeddings using Elasticsearch models (#3401)
This PR introduces a new module, `elasticsearch_embeddings.py`, which
provides a wrapper around Elasticsearch embedding models. The new
ElasticsearchEmbeddings class allows users to generate embeddings for
documents and query texts using a [model deployed in an Elasticsearch
cluster](https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-model-ref.html#ml-nlp-model-ref-text-embedding).

### Main features:

1. The ElasticsearchEmbeddings class initializes with an Elasticsearch
connection object and a model_id, providing an interface to interact
with the Elasticsearch ML client through
[infer_trained_model](https://elasticsearch-py.readthedocs.io/en/v8.7.0/api.html?highlight=trained%20model%20infer#elasticsearch.client.MlClient.infer_trained_model)
.
2. The `embed_documents()` method generates embeddings for a list of
documents, and the `embed_query()` method generates an embedding for a
single query text.
3. The class supports custom input text field names in case the deployed
model expects a different field name than the default `text_field`.
4. The implementation is compatible with any model deployed in
Elasticsearch that generates embeddings as output.

### Benefits:

1. Simplifies the process of generating embeddings using Elasticsearch
models.
2. Provides a clean and intuitive interface to interact with the
Elasticsearch ML client.
3. Allows users to easily integrate Elasticsearch-generated embeddings.

Related issue https://github.com/hwchase17/langchain/issues/3400

---------

Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
2023-05-23 14:50:33 -07:00
..
aleph_alpha.ipynb embedding docs (#2200) 2023-03-30 08:34:14 -07:00
azureopenai.ipynb Fix AzureOpenAI embeddings documentation example. model -> deployment (#4389) 2023-05-17 21:05:53 -07:00
cohere.ipynb
elasticsearch.ipynb Add ElasticsearchEmbeddings class for generating embeddings using Elasticsearch models (#3401) 2023-05-23 14:50:33 -07:00
fake.ipynb
huggingfacehub.ipynb
instruct_embeddings.ipynb
jina.ipynb
llamacpp.ipynb Fix 'embeddings is not defined' (#2468) 2023-04-06 12:45:45 -07:00
openai.ipynb Update \docs\modules\models\text_embedding\examples\openai.ipynb (#3976) 2023-05-02 14:41:31 -07:00
sagemaker-endpoint.ipynb Fix Sagemaker Batch Endpoints (#3249) 2023-04-22 08:49:51 -07:00
self-hosted.ipynb
sentence_transformers.ipynb Sentence Transformers Aliasing (#3541) 2023-04-25 23:29:20 -07:00
tensorflowhub.ipynb