On this page

Text Embeddings

Instrument Azure OpenAI embeddings calls with Statsig to log inputs, vectors, and metadata for AI evaluations and downstream experiments.

Embeddings are numerical representations of data (such as text, images, or audio) that capture essential features as vectors. For text, embeddings map words or sentences to vector spaces where similar items are positioned closer together, enabling comparisons and efficient searches.

Developers use embeddings in tasks such as semantic search, recommendation engines, and clustering. Embeddings let machine learning models analyze and process unstructured data by recognizing patterns in those vector representations.

Generate text embeddings

js
const result = await modelClient.getEmbeddings([
  "Hello, world!",
  "Goodbye, world!",
]);
for (const data of result.data) {
  console.log(`Embedding: ${data.embedding}`);
}

Output

plaintext
Embedding: -0.01918462,-0.025279032,-0.0017195191,0.018848283,-0.033795066,-0.019695852,-0.020947022,0.05158053,-0.03212684,-0.03037789,-0.0021458254,-0.028978731,-0.0024737532,-0.031481072,0.01033225,0.018606123,-0.046145335,0.041463535,0.00044186175,0.041221373,0.053679265,0.001873393,0.004567446,0.01002282,0.047867376,0.0022013208,-0.009834472,0.03847687,0.00089213194,-0.052118666,0.051150016,-0.03255735,-0.0140319485,-0.01263279, .....

Was this helpful?