embedding

package
v0.0.0-...-5c79d48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmbeddingHash = sha256.Sum256

EmbeddingHash is the hash function that should be used to compute embedding hashes.

Functions

func SerializeApp

func SerializeApp(app types.Application) ([]byte, error)

SerializeApp converts a type.Application into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

func SerializeDatabase

func SerializeDatabase(db types.Database) ([]byte, error)

SerializeDatabase converts a type.Database into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

func SerializeKubeCluster

func SerializeKubeCluster(cluster types.KubeCluster) ([]byte, error)

SerializeKubeCluster converts a type.KubeCluster into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

func SerializeNode

func SerializeNode(node types.Server) ([]byte, error)

SerializeNode converts a type.Server into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

func SerializeResource

func SerializeResource(resource types.Resource) ([]byte, error)

SerializeNode converts a serializable resource into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

func SerializeWindowsDesktop

func SerializeWindowsDesktop(desktop types.WindowsDesktop) ([]byte, error)

SerializeWindowsDesktop converts a type.WindowsDesktop into text ready to be fed to an embedding model. The YAML serialization function was chosen over JSON and CSV as it provided better results.

Types

type Embedder

type Embedder interface {
	// ComputeEmbeddings computes the embeddings of multiple strings.
	// The embedding list follows the input order (e.g., result[i] is the
	// embedding of input[i]).
	ComputeEmbeddings(ctx context.Context, input []string) ([]Vector64, error)
}

Embedder is implemented for batch text embedding. Embedding can happen in place (with an embedding model, for example) or be done by a remote embedding service like OpenAI.

type Embedding

type Embedding embeddingpb.Embedding

Embedding contains a Teleport resource embedding. Embeddings are small semantic representations of larger and more complex data. Embeddings can be compared, the smaller the distance between two vectors, the closer the concepts are. Teleport Assist embeds resources to perform semantic search. The Embedding is named after the embedded resource id and kind. For example the SSH node "bastion-01" has the embedding "node/bastion-01".

func NewEmbedding

func NewEmbedding(kind, id string, vector Vector64, hash Sha256Hash) *Embedding

NewEmbedding is an Embedding constructor.

func (*Embedding) Dimension

func (e *Embedding) Dimension(i int) float64

Dimension returns the value of the i-th dimension Implements kdtree.Point interface

func (*Embedding) Dimensions

func (e *Embedding) Dimensions() int

Dimensions returns the number of dimensions of the embedding Implements kdtree.Point interface

func (*Embedding) GetEmbeddedID

func (e *Embedding) GetEmbeddedID() string

GetEmbeddedID returns the ID of the resource that was embedded.

func (*Embedding) GetEmbeddedKind

func (e *Embedding) GetEmbeddedKind() string

GetEmbeddedKind returns the kind of the resource that was embedded.

func (*Embedding) GetName

func (e *Embedding) GetName() string

GetName returns the Embedding name, composed of the embedded resource kind and the embedded resource ID.

func (*Embedding) GetVector

func (e *Embedding) GetVector() Vector64

GetVector returns the embedding vector

type Sha256Hash

type Sha256Hash = [sha256.Size]byte

Sha256Hash is the hash of the embedded content. This hash allows to detect if the embedding is still up-to-date or if the content changed and the resource must be re-embedded.

type Vector32

type Vector32 = []float32

Vector32 is an array of float64 that contains the result of the embedding process. OpenAI client returns []float32, hence Vector32 is the main type for handling vector data.

type Vector64

type Vector64 = []float64

Vector64 is an array of float64 that contains the result of the embedding process. While OpenAI returns us 32-bit floats, the vector index uses methods requiring 64-bit floats.

func Vector32to64

func Vector32to64(vector32 Vector32) Vector64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL