Skip to main content
Embeddings transform text into arrays of floating-point numbers — dense vectors that capture the semantic meaning of the input. Text with similar meaning ends up close together in vector space, regardless of whether the exact words match. This makes embeddings the foundation for semantic search, retrieval-augmented generation (RAG), document clustering, and content recommendation.

Common Use Cases

  • Semantic search — find documents that are conceptually related to a query, not just keyword-matched
  • Retrieval-augmented generation (RAG) — embed your knowledge base, retrieve the most relevant chunks at query time, and pass them as context to a chat completion
  • Document clustering — group large document sets by topic without predefined labels
  • Recommendation — surface items similar to what a user has already engaged with
  • Classification — train a lightweight classifier on top of embeddings as features

Generate an Embedding

Make a POST request to https://api.swytcho.com/v1/embeddings with your model and the input text.

Response Format

The API returns an object with a data array. Each entry corresponds to one input string and contains the embedding vector at embedding.
Access the vector with result["data"][0]["embedding"]. Store it as a list of floats in your database or vector store.

Batch Embedding

Pass an array of strings as input to embed multiple texts in a single API call. The response data array preserves the original order via the index field.
Python
Batching is more efficient than sending one request per document — use it whenever you are embedding more than a handful of strings.

Computing Cosine Similarity

Cosine similarity measures how closely two embedding vectors point in the same direction. A score of 1.0 means identical meaning; 0.0 means unrelated.
Python
For production search at scale, use a dedicated vector database (such as Pinecone, Weaviate, or pgvector) rather than computing pairwise similarity in Python — these systems index vectors for approximate nearest-neighbor search across millions of entries.

Storage and Dimensions

The swytcho-embed model produces 1,536-dimensional vectors. Each dimension is a 32-bit float (4 bytes), so a single embedding occupies roughly 6 KB. Plan your storage accordingly: one million embeddings require approximately 6 GB of raw vector storage before any index overhead. If your use case is storage-constrained, check whether your vector database supports product quantization or dimensionality reduction.

Chunking Long Documents

Embeddings are computed on the full input text, but most embedding models have a token limit (typically 512–8,192 tokens). If you submit text that exceeds the limit, it will be silently truncated, and the resulting embedding will not represent your full document. Split long documents into overlapping chunks (e.g., 512 tokens with a 64-token overlap) before embedding, store each chunk with a reference to its source document, and embed your query at retrieval time to find the most relevant chunks.