LM StudioLM Studio

Embeddings

Generate embedding vectors 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/developer/openai-compat/embeddings, I want to ask questions about it.

Python example
from openai import OpenAI
client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")

def get_embedding(text, model="model-identifier"):
   text = text.replace("\n", " ")
   return client.embeddings.create(input=[text], model=model).data[0].embedding

print(get_embedding("Once upon a time, there was a cat."))

On this page