Skip to content

Class: LlamaEmbedding

Constructors

new LlamaEmbedding()

ts
new LlamaEmbedding(options: LlamaEmbeddingOptions): LlamaEmbedding

Parameters

ParameterType
optionsLlamaEmbeddingOptions

Returns

LlamaEmbedding

Defined in

evaluator/LlamaEmbedding.ts:13

Properties

vector

ts
readonly vector: readonly number[];

Defined in

evaluator/LlamaEmbedding.ts:11

Methods

toJSON()

ts
toJSON(): LlamaEmbeddingJSON

Returns

LlamaEmbeddingJSON

Defined in

evaluator/LlamaEmbedding.ts:17


calculateCosineSimilarity()

ts
calculateCosineSimilarity(other: readonly number[] | LlamaEmbeddingJSON | LlamaEmbedding): number

Calculates the cosine similarity between this embedding and another embedding.

Note that you should only compare embeddings created by the exact same model file.

Parameters

ParameterType
otherreadonly number[] | LlamaEmbeddingJSON | LlamaEmbedding

Returns

number

A value between 0 and 1 representing the similarity between the embedding vectors, where 1 means the embeddings are identical.

Defined in

evaluator/LlamaEmbedding.ts:31


fromJSON()

ts
static fromJSON(json: LlamaEmbeddingJSON): LlamaEmbedding

Parameters

ParameterType
jsonLlamaEmbeddingJSON

Returns

LlamaEmbedding

Defined in

evaluator/LlamaEmbedding.ts:65