usearch
ai-research-agent / similarity/usearch
Similarity
convertTextToEmbedding()
function convertTextToEmbedding(text, options?): Promise<{
embedding: number[];
embeddingsDict: {};
}>
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
Parameter | Type | Description |
---|---|---|
|
| The text to embed. |
| { | |
|
| The pipeline to use for embedding. |
|
| default=4 - The number of decimal places to round to. |
Returns
Promise
<{
embedding
: number
[];
embeddingsDict
: {};
}>
getEmbeddingModel()
function getEmbeddingModel(options?): Promise<AutoTokenizer>
Initialize HuggingFace Transformers pipeline for embedding text.
Parameters
Parameter | Type | Description |
---|---|---|
| { | |
|
| default="Xenova/all-MiniLM-L6-v2" - The name of the model to use |
|
| default "feature-extraction", |
Returns
Promise
<AutoTokenizer
>
The pipeline. *