LM StudioLM Studio

Embedding

Generate text embeddings from input text

Ask Bionic to read this page

Copy this prompt, open Bionic, and paste it into a new chat.

Read https://lmstudio.ai/docs/python/embedding, I want to ask questions about it.

Generate embeddings for input text. Embeddings are vector representations of text that capture semantic meaning. Embeddings are a building block for RAG (Retrieval-Augmented Generation) and other similarity-based tasks.

Prerequisite: Get an Embedding Model

If you don't yet have an embedding model, you can download a model like nomic-ai/nomic-embed-text-v1.5 using the following command:

lms get nomic-ai/nomic-embed-text-v1.5

Create Embeddings

To convert a string to a vector representation, pass it to the embed method on the corresponding embedding model handle.

example.py
import lmstudio as lms

model = lms.embedding_model("nomic-embed-text-v1.5")

embedding = model.embed("Hello, world!")