Skip to content

Embed Server

memorylayer-embed-server is a stateless embedding and transcription server that runs as a peer to memorylayer-server. It serves the heavy ML work (text embeddings, multi-vector / ColPali, OCR, transcription) over HTTP and keeps the core server lightweight. It is part of MemoryLayer (core) and is licensed Apache-2.0.

Since 0.2.0 the embed server’s default single-vector provider is sentence_transformers (all-MiniLM-L6-v2, 384 dimensions), which runs on CPU. You no longer need a GPU, a CUDA toolchain, or a 2B-parameter model download to get real semantic embeddings. GPU back-ends (vLLM, OCR, transcription) remain available as an opt-in.

In v0.1.x the in-process providers local (sentence-transformers), colpali, and qwen3-vl were removed from memorylayer-server. All self-hosted embedding now routes through this package via the core server’s embed_server provider.

When to Use It

Run memorylayer-embed-server when you want any of the following:

  • Self-hosted semantic text embeddings on CPU (the default) or GPU
  • Multi-vector / ColPali visual embeddings for document pages
  • GPU OCR (GLM-OCR and others) or transcription
  • Air-gapped or compliance-sensitive deployments that cannot call OpenAI or Google

You do not need it if you use cloud embeddings (openai / google), or if the core server’s default lexical hash provider is enough for your testing.

Installation

The embed server is published as a container image on Docker Hub, in two variants under one repository:

TagContents
scitrera/memorylayer-embed-server:<version>CPU. sentence-transformers (384-d) + in-process ColPali. Runs anywhere.
scitrera/memorylayer-embed-server:<version>-cuda13CUDA 13. Adds vLLM, OCR, and transcription. Needs an NVIDIA GPU.
Terminal window
# CPU, plain HTTP
docker run -d --name memorylayer-embed -p 61051:61051 \
-e EMBED_SERVER_RUN_SIDECAR=false \
-v hf-cache:/home/memorylayer/.cache/huggingface \
scitrera/memorylayer-embed-server:0.2.0
# GPU
docker run -d --name memorylayer-embed --gpus all -p 61051:61051 \
-e EMBED_SERVER_RUN_SIDECAR=false \
-e MEMORYLAYER_EMBED_SINGLE_VECTOR_PROVIDER=vllm_subprocess \
-v hf-cache:/home/memorylayer/.cache/huggingface \
scitrera/memorylayer-embed-server:0.2.0-cuda13

Mount the Hugging Face cache (as above) so model weights are downloaded only once. The first request after a fresh start is slow while weights download. The latest tag now points at the CPU build; GPU hosts should use a -cuda13 tag.

The repository’s docker-compose.yml runs the CPU image together with the core server. See Installation.

From Source

The embed server is not published to PyPI. To run it outside a container, install it from a checkout of the MemoryLayer repository:

Terminal window
git clone https://github.com/scitrera/memorylayer
cd memorylayer
# Local / CPU: sentence-transformers single-vector embeddings (the default provider)
pip install "./memorylayer-embed-server[local]"
# GPU bundle: OCR + vLLM + ColPali
pip install "./memorylayer-embed-server[gpu]"
# Everything: local + GPU + Google embeddings + observability
pip install "./memorylayer-embed-server[all]"

The default provider needs the local extra. A bare install with no extras gives you the server skeleton with no embedding backend: it starts, but logs an error naming the extra to install.

ExtraPurpose
localDefault single-vector backend: sentence-transformers on CPU (all-MiniLM-L6-v2, 384-d). Installs sentence-transformers, torch
ocrOCR via Transformers (GLM-OCR and others). Installs transformers, torch, accelerate
vllmHigh-throughput vLLM-served models
sparkrunLaunch the vLLM lanes through sparkrun recipes (GPU only)
colpaliColPali / late-interaction visual embedding
googleGoogle GenAI embedding and transcription proxy
observabilityPrometheus /metrics + OpenTelemetry tracing
gpuocr + vllm + colpali
alllocal + gpu + google + observability
devpytest + ruff

Quick Start

Terminal window
# Start on the default port (61051)
memorylayer-embed serve
# Custom host/port
memorylayer-embed serve --host 0.0.0.0 --port 61051
# Verbose logging
memorylayer-embed -v serve

Verify the server is up:

Terminal window
curl http://localhost:61051/health
curl http://localhost:61051/health/ready

Wiring It to the Core Server

Once the embed server is running, point memorylayer-server at it. The core server’s default provider is hash, so you must select embed_server explicitly (the official server Docker image already does):

Terminal window
export MEMORYLAYER_EMBEDDING_PROVIDER=embed_server
export MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051
export MEMORYLAYER_EMBEDDING_DIMENSIONS=384 # must match the embed server's model
memorylayer serve

The core server probes the peer at startup and logs an actionable error if it cannot reach it.

For cross-datacenter or mTLS deployments, use Aether transport instead of plain HTTP:

Terminal window
export MEMORYLAYER_EMBED_TRANSPORT=aether
export MEMORYLAYER_EMBED_AETHER_TARGET=sv::memorylayer-embed::default

When EMBED_TRANSPORT=aether, the embed server runs behind the Aether proxy-sidecar. The sidecar is PID 1 in the official Docker images (supervisor mode); it terminates inbound ProxyHttpRequest envelopes and forwards them to the embed FastAPI app on 127.0.0.1:61051. See Aether Transport for what the mesh adds (mTLS, identity headers, OBO delegation, service discovery).

CLI

CommandDescription
memorylayer-embed serveStart the HTTP server (--host, --port)
memorylayer-embed versionPrint the package version

The global flag -v / --verbose enables debug logging.

Configuration

VariableDefaultDescription
MEMORYLAYER_EMBED_SERVER_HOST0.0.0.0Bind address
MEMORYLAYER_EMBED_SERVER_PORT61051Listening port
MEMORYLAYER_EMBED_SINGLE_VECTOR_PROVIDERsentence_transformerssentence_transformers (CPU, 384-d), vllm_subprocess (GPU, 2048-d), vllm (in-process), vllm_sparkrun, openai, google, or mock. Changing this changes the vector dimension. See Embedding dimensions.
MEMORYLAYER_EMBEDDING_MODELprovider default (sentence-transformers/all-MiniLM-L6-v2)Single-vector model for the active provider
MEMORYLAYER_EMBEDDING_DIMENSIONS384Vector width. Must match the model.
MEMORYLAYER_EMBEDDING_ST_DEVICEautocpu, cuda, mps, and so on, for the sentence-transformers provider. Pin to cpu to leave the GPU for ColPali.
MEMORYLAYER_EMBEDDING_ST_BATCH_SIZE32Encode batch size for the sentence-transformers provider
MEMORYLAYER_EMBED_MULTI_VECTOR_PROVIDERvllm_subprocess (the CPU image sets colpali_inprocess)vllm_subprocess (out-of-process vLLM, GPU) or colpali_inprocess (in-process colpali-engine, runs on CPU)
MEMORYLAYER_EMBEDDING_COLPALI_MODELModernVBERT/colmodernvbertMulti-vector model. The vLLM path auto-upgrades the LoRA-adapter checkpoint to colmodernvbert-merged.
MEMORYLAYER_EMBEDDING_COLPALI_POOL_FACTOR1Hierarchical token-pool factor. Must be the same for query-side and document-side calls.
MEMORYLAYER_EMBEDDING_DEVICEautoDevice for ColPali (separate from the sentence-transformers device)
MEMORYLAYER_EMBEDDING_VLLM_GPU_MEM_UTIL0.25Per-vLLM-subprocess GPU memory budget. Lower it when sharing the GPU.
EMBED_SERVER_RUN_SIDECARtrue (Docker)When true, the Aether sidecar is PID 1 and supervises the embed server. When false, the embed server runs directly as plain HTTP (use this for Docker Compose, local development, and CI).

The full per-provider variable list and recipes are in the repository’s embedding providers guide.

Embedding Dimensions

Pick a single-vector model before you ingest anything, and treat it as a long-lived decision. The vector width it produces is written into every stored memory in memorylayer-server, so it is a property of your data, not only of this server’s configuration.

ProviderDefault modelDimensions
sentence_transformers (default)sentence-transformers/all-MiniLM-L6-v2384
vllm_subprocess / vllmQwen/Qwen3-VL-Embedding-2B2048
openaitext-embedding-3-small1536
googlegemini-embedding-001768

Set MEMORYLAYER_EMBEDDING_DIMENSIONS on both this server and the core memorylayer-server to match the model you run. The core server’s default for embed_server is 384. The provider checks the value against the loaded model at startup and warns if they disagree; the model wins, because writing a wrong-width vector is worse than a noisy log.

Mixing widths breaks recall:

  • On SQLite with sqlite-vec (the default), a width mismatch makes the whole query return nothing, not just the offending rows. A handful of wrong-width memories breaks recall for the entire workspace.
  • Without the sqlite-vec extension, the pure-Python fallback scores mismatched vectors as 0.0, so the older memories silently stop matching.

Changing dimensions needs no schema migration (the column is a plain BLOB), but it does require re-embedding existing memories or starting a fresh workspace. Matching widths are not enough on their own: two different 384-d models produce vectors that compare without error but mean nothing to each other.

Multi-Vector Back-Ends

The multi-vector / ColPali path has two interchangeable back-ends. Both serve /v1/embeddings/multi, /v1/embeddings/images, and /v1/score:

  • vllm_subprocess (default) — out-of-process vllm serve --runner pooling for batched, paged-attention throughput. Needs a GPU.
  • colpali_inprocess — colpali-engine via Hugging Face Transformers in the embed-server process. Loads the small ModernVBERT/colmodernvbert adapter (about 250 MB) and runs on CPU. The CPU Docker image selects this back-end.

A CPU-only deployment outside the CPU image must opt into the in-process back-end explicitly:

Terminal window
MEMORYLAYER_EMBED_SINGLE_VECTOR_PROVIDER=sentence_transformers # default
MEMORYLAYER_EMBED_MULTI_VECTOR_PROVIDER=colpali_inprocess
MEMORYLAYER_EMBEDDING_ST_DEVICE=cpu
MEMORYLAYER_EMBEDDING_DEVICE=cpu

GPU is still strongly preferred for multi-vector. On CPU a page-image multi-vector takes several seconds, which is fine for development and ad-hoc queries but impractical for bulk document ingestion.

Docker Build Details

Both images are built from the repository root:

DockerfileImageNotes
memorylayer-embed-server/Dockerfile.cpu:<version>python:3.12-slim, CPU PyTorch, extras local,colpali,google,observability. Sets MEMORYLAYER_EMBED_MULTI_VECTOR_PROVIDER=colpali_inprocess and CPU devices.
memorylayer-embed-server/Dockerfile:<version>-cuda13nvidia/cuda:13.1.2 base with CUDA 13 PyTorch, vLLM, OCR, and ColPali.

Both copy the Aether proxy-sidecar binary from a pinned ghcr.io/scitrera/aether image, expose port 61051, and run /usr/local/bin/embed-server-entrypoint.sh as a non-root user (uid 65532).

Terminal window
# Build the CPU image (from the repository root)
docker build -f memorylayer-embed-server/Dockerfile.cpu -t memorylayer-embed-server:cpu .

Test variants (Dockerfile.test, Dockerfile.real-test, Dockerfile.real-test-full) are used by the integration test harness.

Health Checks

  • GET /health — process is up
  • GET /health/ready — required models are loaded and ready to serve
  • GET /health/load — per-provider load snapshot (in-flight requests, utilization) for upstream load balancing
  • GET /health/gpu — GPU memory status (returns 503 when no GPU monitor is configured)

The Docker images’ HEALTHCHECK targets /health (30s interval; 180s start period on the CPU image, 60s on the CUDA image).

LLM Inference Hosting (optional)

When MEMORYLAYER_EMBED_LLM_ENABLED=true, the embed server hosts chat / completions LLM workloads alongside embeddings. One or more vllm serve child processes run inside the same container, each serving a distinct LLM, and the FastAPI app exposes OpenAI-compatible endpoints:

  • POST /v1/chat/completions — OpenAI chat (streaming and non-streaming)
  • POST /v1/completions — legacy text completions
  • GET /v1/models — model list (profile names, aliases, and underlying model IDs)

Routing uses the OpenAI-standard model request field, so any OpenAI client works, including the core server’s embed_server LLM provider. The payload is forwarded verbatim to the underlying vLLM: tool calls, structured output, multimodal images, and reasoning fields all pass through. This requires the GPU (-cuda13) image or the vllm extra.

Enabling

Terminal window
export MEMORYLAYER_EMBED_LLM_ENABLED=true
export MEMORYLAYER_EMBED_LLM_PROFILES=qwen # comma-list of profile names
export MEMORYLAYER_EMBED_LLM_DEFAULT_PROFILE=qwen # used when the request `model` doesn't match
export MEMORYLAYER_EMBED_LLM_PRELOAD=false # default lazy; set true to start at boot
export MEMORYLAYER_EMBED_LLM_PORT_RANGE=18100-18199 # private port pool for internal vLLM subprocesses
# Per-profile (substitute the uppercased profile name)
export MEMORYLAYER_EMBED_LLM_PROFILE_QWEN_MODEL=Qwen/Qwen2.5-7B-Instruct
export MEMORYLAYER_EMBED_LLM_PROFILE_QWEN_ALIASES=qwen-7b,qwen2.5
export MEMORYLAYER_EMBED_LLM_PROFILE_QWEN_GPU_MEM_UTIL=0.4

Internal vLLM ports are auto-assigned from the port pool; you never set them manually.

Pointing the Core Server at a Hosted LLM

The core server has an embed_server LLM provider type that uses the same HTTP / Aether transport as embeddings:

Terminal window
export MEMORYLAYER_LLM_PROFILE_INFERENCE_PROVIDER=embed_server
export MEMORYLAYER_LLM_PROFILE_INFERENCE_MODEL=qwen # matches a profile/alias on the embed server
export MEMORYLAYER_LLM_ASSIGN_REFLECTION=inference # route reflection through it

Each core-side LLM profile can override _EMBED_SERVER_URL, _EMBED_SERVER_TRANSPORT, _EMBED_SERVER_AETHER_TARGET, and _EMBED_SERVER_TIMEOUT, so two profiles can use two different embed-server peers. See Server Configuration.

The complete schema, routing rules, and recipes are in the repository’s embedding providers guide, “LLM Inference Profiles”.

Enterprise Embedding Extensions

MemoryLayer Enterprise includes open-source (AGPL-3.0) plugins for the embed server, in the memorylayer-embed-server-enterprise component of the memorylayer-enterprise repository:

  • Visual tokenization (Qwen3.5/3.6): produces precomputed prompt embeddings for page images at /v1/visual-tokenize, which a vLLM chat profile started with --enable-prompt-embeds can consume
  • GLiNER2 named-entity extraction: serves /v1/ner

When installed alongside memorylayer-embed-server, the embed server discovers the plugins automatically. Each plugin is off until you enable it: MEMORYLAYER_EMBED_VISUAL_TOKENIZER_ENABLED=true for visual tokenization and MEMORYLAYER_EMBED_GLINER2_ENABLED=true for NER. They are distributed as source in the Enterprise repository; there is no PyPI package or separate image.

Versioning

memorylayer-embed-server is versioned independently of the other MemoryLayer packages and is distributed as a container image. The current release is 0.2.0, matching memorylayer-server 0.2.0.