AxilJS Embeddings for Vector Search and AI Applications
Generate vector embeddings with AxilJS for semantic search, RAG pipelines, similarity matching, and other TypeScript and Node.js AI applications.
Vector Embeddings
AxilJS provides an embedding API for converting text into vector embeddings that can be used by TypeScript and Node.js AI applications.
Vector embeddings represent text as numerical vectors, making them useful for semantic search, similarity matching, retrieval-augmented generation (RAG), and other AI workflows.
Generate an Embedding
Use ai.embed() to generate an embedding for a single text input.
The returned embeddings array contains the generated vector representation. For a single input, the first embedding can be accessed with result.embeddings[0].
Each embedding is represented as a number[].
Generate Multiple Embeddings
AxilJS also supports multiple text inputs in a single embedding request.
When multiple inputs are provided, AxilJS generates an embedding for each text input.
This is useful when processing documents, batches of text, or multiple records that need to be converted into vectors.
Embeddings in AI Applications
Embeddings are commonly used as a building block for applications that need to compare the semantic meaning of text.
Typical use cases include:
- Semantic search
- Retrieval-augmented generation (RAG)
- Document retrieval
- Similarity matching
- Knowledge-base search
- Recommendation systems
- Text clustering
- Duplicate or related-content detection
A typical RAG workflow can use embeddings to convert document chunks into vectors and later retrieve the most semantically relevant chunks for an AI model.
Single vs Multiple Inputs
Use a single string when you need to generate one embedding:
Use an array when you need embeddings for multiple pieces of text:
The multiple-input form is particularly useful for batch-oriented document processing and RAG ingestion pipelines.