Skip to content

OpenAI.Embedding

Andrew Lambert edited this page Jul 14, 2024 · 5 revisions

OpenAI.Embedding

Class Declaration

 Protected Class Embedding
 Inherits OpenAI.Response

Remarks

This class represents an API embedding response. Refer to the OpenAI documentation on the /v1/embeddings endpoint for further details.

An embedding is basically a list of numbers generated from a text that can be compared to other lists generated from other texts to determine how similar they are. Once generated you can save/reload an embedding for future comparisons.

Example

This example creates two embeddings and then calculates the distance between them:

 OpenAI.APIKey = "YOUR API KEY"
 Dim embed1 As OpenAI.Embedding = OpenAI.Embedding.Create("Hello, my name is Alice.", "text-embedding-ada-002")
 Dim embed2 As OpenAI.Embedding = OpenAI.Embedding.Create("Hello, my name is Bob.", "text-embedding-ada-002")
 Dim distance As Double = embed1.DistanceFrom(embed2) ' 0.9008139275638367 (very similar)

Methods

Properties

Shared methods

Shared properties

Clone this wiki locally