Skip to main content

usearch

Documentation / similarity/usearch

Similarity​

convertTextToEmbedding()​

function convertTextToEmbedding(text: string, options?: object): Promise<{
embedding: number[];
embeddingsDict: {
};
}>;

Defined in: similarity/usearch.js:52

Text embeddings convert words or phrases into numerical vectors in a high-dimensional space, where each dimension represents a semantic feature extracted by a model like MiniLM-L6-v2. In this concept space, words with similar meanings have vectors that are close together, allowing for quantitative comparisons of semantic similarity. These vector representations enable powerful applications in natural language processing, including semantic search, text classification, and clustering, by leveraging the geometric properties of the embedding space to capture and analyze the relationships between words and concepts. Text Embeddings, Classification, and Semantic Search (Youtube)

Parameters​

ParameterTypeDescription

text

string

The text to embed.

options?

{ pipeline: AutoTokenizer; precision: number; }

options.pipeline?

AutoTokenizer

The pipeline to use for embedding.

options.precision?

number

default=4 - The number of decimal places to round to.

Returns​

Promise<{ embedding: number[]; embeddingsDict: { }; }>


getEmbeddingModel()​

function getEmbeddingModel(options?: object): Promise<AutoTokenizer>;

Defined in: similarity/usearch.js:76

Initialize HuggingFace Transformers pipeline for embedding text.

Parameters​

ParameterTypeDescription

options?

{ modelName: string; pipelineName: string; }

options.modelName?

string

default="Xenova/all-MiniLM-L6-v2" - The name of the model to use

options.pipelineName?

string

default "feature-extraction",

Returns​

Promise<AutoTokenizer>

The pipeline. *