DS DevShelfHub Projects · AI tools
Tutorials / LangChain / Reference / Classes / DatabricksEmbeddings
Embeddings langchain-databricks Intermediate

DatabricksEmbeddings: Reference Guide

By DevShelfHub

Use Databricks-hosted embeddings.

What is DatabricksEmbeddings?

DatabricksEmbeddings is the LangChain wrapper for embedding models served by Databricks Model Serving and the Mosaic AI Foundation Model APIs. It lets you call a model you have deployed as a serving endpoint inside your own Databricks workspace — for example bge-large-en or a fine-tuned embedding model — rather than sending text to an external provider. For teams whose data already lives in a Databricks Lakehouse, this keeps embeddings inside the same governance, billing, and network boundary.

You point the class at a serving endpoint by name through the endpoint argument, and authenticate with your workspace host and a personal access token, usually supplied through the DATABRICKS_HOST and DATABRICKS_TOKEN environment variables. On a Databricks cluster or notebook those are often injected automatically. The class exposes the standard embed_query and embed_documents methods, so it drops into any LangChain retriever or vector store unchanged — it pairs naturally with Databricks Vector Search for an end-to-end in-platform RAG stack.

The package moved over time: prefer the databricks-langchain package, which supersedes the older langchain-databricks and the even older DatabricksEmbeddings shim that lived in the community package. Because it targets a serving endpoint, throughput and latency depend on how that endpoint is provisioned — scale-to-zero endpoints add cold-start latency on the first call. As with every embeddings model, index and query with the same endpoint; switching the underlying model invalidates existing vectors.

When to Use

You're on Databricks platform. Use for unified data+AI infrastructure.

Use Cases

  • Databricks ecosystem
  • Data + AI integration
  • Enterprise ML
  • Lakehouse
  • Unified data
  • Cloud ML

Key Features

  • Databricks-native
  • Unified ecosystem
  • Enterprise
  • Multi-workspace
  • Integrated
  • Optimized

When NOT to Use

Unless you're using Databricks.

Notes

Use the databricks-langchain package

Install and import from databricks-langchain. It supersedes the older langchain-databricks package and the community DatabricksEmbeddings shim, which are deprecated. Mixing import paths across a project is a common source of confusing version-skew errors.

Endpoint, not model name

DatabricksEmbeddings targets a serving endpoint you deployed, addressed by the endpoint argument. The model lives behind that endpoint. A 404 or RESOURCE_DOES_NOT_EXIST error almost always means the endpoint name is wrong or lives in a different workspace than your host points to.

Cold starts on scale-to-zero endpoints

If the serving endpoint is configured to scale to zero, the first request after idle pays a cold-start delay while the model spins up. For latency-sensitive apps, provision a minimum of one running instance or warm the endpoint before serving traffic.

Auth is host plus token

Set DATABRICKS_HOST and DATABRICKS_TOKEN, or pass them explicitly. Inside a Databricks notebook or job these are often injected automatically; outside the platform you must supply a valid personal access token with permission to query the endpoint.

Import

python
from langchain_databricks import DatabricksEmbeddings

Configuration

Parameter Type Default Purpose
host str None Databricks workspace URL

Usage Examples

Call a serving endpoint

python
from databricks_langchain import DatabricksEmbeddings

embeddings = DatabricksEmbeddings(endpoint='databricks-bge-large-en')
vector = embeddings.embed_query('What is a lakehouse?')
print(len(vector))

Authenticate with host and token

python
import os
from databricks_langchain import DatabricksEmbeddings

os.environ['DATABRICKS_HOST'] = 'https://my-workspace.cloud.databricks.com'
os.environ['DATABRICKS_TOKEN'] = 'dapi...'
embeddings = DatabricksEmbeddings(endpoint='my-embedding-endpoint')
vectors = embeddings.embed_documents(['doc one', 'doc two'])

In-platform RAG with Databricks Vector Search

python
from databricks_langchain import DatabricksEmbeddings, DatabricksVectorSearch

embeddings = DatabricksEmbeddings(endpoint='databricks-bge-large-en')
store = DatabricksVectorSearch(
    index_name='catalog.schema.docs_index',
    embedding=embeddings,
)
hits = store.similarity_search('reset my password', k=4)

Common Pitfalls

❌ Use without Databricks workspace

✅ Requires Databricks setup

Alternative Embedding Models

Model When to Use
OpenAIEmbeddings For standalone use

Browse the full LangChain API reference index to explore more classes, methods, and decorators, or start with the LangChain introduction tutorial for end-to-end context on building with DatabricksEmbeddings and the wider framework.

DatabricksEmbeddings FAQ

What is DatabricksEmbeddings in LangChain?

Use Databricks-hosted embeddings. DatabricksEmbeddings is the LangChain wrapper for embedding models served by Databricks Model Serving and the Mosaic AI Foundation Model APIs. It lets you call a model you have deployed as a serving endpoint inside your own Databricks workspace — for example bge-large-en or a fine-tuned embedding model — rather than sending text to an external provider. For teams whose data already lives in a Databricks Lakehouse, this keeps embeddings inside the same governance, billing, and…

Which package provides DatabricksEmbeddings?

DevShelfHub documents DatabricksEmbeddings from the langchain-databricks package. Pin your installed LangChain version and match imports to the snippet on this page.

When should I use DatabricksEmbeddings?

You're on Databricks platform. Use for unified data+AI infrastructure.

When should I avoid using DatabricksEmbeddings?

Unless you're using Databricks.

How do I import DatabricksEmbeddings in Python?

from langchain_databricks import DatabricksEmbeddings

Where can I explore more LangChain API reference pages?

Open the LangChain API reference index on DevShelfHub to browse classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.