Skip to content

Class: LlamaEmbedding

Defined in: evaluator/LlamaEmbedding.ts:10

Constructors

new LlamaEmbedding()

ts
new LlamaEmbedding(options: LlamaEmbeddingOptions): LlamaEmbedding

Defined in: evaluator/LlamaEmbedding.ts:13

Parameters

ParameterType
optionsLlamaEmbeddingOptions

Returns

LlamaEmbedding

Properties

vector

ts
readonly vector: readonly number[];

Defined in: evaluator/LlamaEmbedding.ts:11

Methods

toJSON()

ts
toJSON(): LlamaEmbeddingJSON

Defined in: evaluator/LlamaEmbedding.ts:17

Returns

LlamaEmbeddingJSON


calculateCosineSimilarity()

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

Defined in: evaluator/LlamaEmbedding.ts:31

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
other| readonly 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.


fromJSON()

ts
static fromJSON(json: LlamaEmbeddingJSON): LlamaEmbedding

Defined in: evaluator/LlamaEmbedding.ts:65

Parameters

ParameterType
jsonLlamaEmbeddingJSON

Returns

LlamaEmbedding