Skip to main content

Overview

While switchAILocal uses MiniLM by default, you can integrate custom embedding providers for specialized use cases like:
  • Domain-specific models (medical, legal, code)
  • Multilingual embeddings
  • Higher-dimensional vectors
  • Cloud embedding APIs

Embedding Engine Interface

The semantic tier expects an implementation of the EmbeddingEngine interface:

Custom ONNX Model

Replace the default MiniLM model with your own ONNX model.

Step 1: Export Your Model

Step 2: Configure switchAILocal

Step 3: Verify Compatibility

Ensure your model:
  • Accepts input_ids, attention_mask, token_type_ids as inputs
  • Outputs last_hidden_state tensor
  • Uses BERT-style tokenization

Custom Go Implementation

Implement a completely custom embedding engine.

Step 1: Implement the Interface

Step 2: Integrate with Intelligence Service

Hybrid Approach

Combine local and cloud embeddings for different use cases.

Caching Layer

Add caching to reduce API calls:

Multilingual Models

Domain-Specific Models

High-Dimensional Models

Testing Your Custom Engine

Best Practices

Match Dimensions - Ensure all embeddings have the same dimensionality for valid comparisons.
Normalize Vectors - Apply L2 normalization for optimal cosine similarity computation.
API Rate Limits - Implement caching and rate limiting when using cloud embedding APIs.
Performance - Local models (5-10ms) are significantly faster than API calls (50-200ms).

Next Steps

Overview

Learn embedding fundamentals

Usage Guide

Use the default embedding SDK

Go SDK

Embed switchAILocal in Go apps

Intelligent Routing

Configure semantic routing