node-llama-cpp
Version:
Run AI models locally on your machine with node.js bindings for llama.cpp. Enforce a JSON schema on the model output on the generation level
22 lines (21 loc) • 842 B
TypeScript
export type LlamaEmbeddingOptions = {
vector: readonly number[];
};
export type LlamaEmbeddingJSON = {
type: "embedding";
vector: readonly number[];
};
export declare class LlamaEmbedding {
readonly vector: readonly number[];
constructor(options: LlamaEmbeddingOptions);
toJSON(): LlamaEmbeddingJSON;
/**
* Calculates the cosine similarity between this embedding and another embedding.
*
* Note that you should only compare embeddings created by the exact same model file.
* @returns A value between 0 and 1 representing the similarity between the embedding vectors,
* where 1 means the embeddings are identical.
*/
calculateCosineSimilarity(other: LlamaEmbedding | LlamaEmbeddingJSON | readonly number[]): number;
static fromJSON(json: LlamaEmbeddingJSON): LlamaEmbedding;
}