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
Container Images (Recommended)
The embed server is published as a container image on Docker Hub, in two variants under one repository:
| Tag | Contents |
|---|---|
scitrera/memorylayer-embed-server:<version> | CPU. sentence-transformers (384-d) + in-process ColPali. Runs anywhere. |
scitrera/memorylayer-embed-server:<version>-cuda13 | CUDA 13. Adds vLLM, OCR, and transcription. Needs an NVIDIA GPU. |
# CPU, plain HTTPdocker 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
# GPUdocker 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-cuda13Mount 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:
git clone https://github.com/scitrera/memorylayercd memorylayer
# Local / CPU: sentence-transformers single-vector embeddings (the default provider)pip install "./memorylayer-embed-server[local]"
# GPU bundle: OCR + vLLM + ColPalipip install "./memorylayer-embed-server[gpu]"
# Everything: local + GPU + Google embeddings + observabilitypip 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.
| Extra | Purpose |
|---|---|
local | Default single-vector backend: sentence-transformers on CPU (all-MiniLM-L6-v2, 384-d). Installs sentence-transformers, torch |
ocr | OCR via Transformers (GLM-OCR and others). Installs transformers, torch, accelerate |
vllm | High-throughput vLLM-served models |
sparkrun | Launch the vLLM lanes through sparkrun recipes (GPU only) |
colpali | ColPali / late-interaction visual embedding |
google | Google GenAI embedding and transcription proxy |
observability | Prometheus /metrics + OpenTelemetry tracing |
gpu | ocr + vllm + colpali |
all | local + gpu + google + observability |
dev | pytest + ruff |
Quick Start
# Start on the default port (61051)memorylayer-embed serve
# Custom host/portmemorylayer-embed serve --host 0.0.0.0 --port 61051
# Verbose loggingmemorylayer-embed -v serveVerify the server is up:
curl http://localhost:61051/healthcurl http://localhost:61051/health/readyWiring 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):
export MEMORYLAYER_EMBEDDING_PROVIDER=embed_serverexport MEMORYLAYER_EMBED_SERVER_URL=http://embed-host:61051export MEMORYLAYER_EMBEDDING_DIMENSIONS=384 # must match the embed server's modelmemorylayer serveThe 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:
export MEMORYLAYER_EMBED_TRANSPORT=aetherexport MEMORYLAYER_EMBED_AETHER_TARGET=sv::memorylayer-embed::defaultWhen 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
| Command | Description |
|---|---|
memorylayer-embed serve | Start the HTTP server (--host, --port) |
memorylayer-embed version | Print the package version |
The global flag -v / --verbose enables debug logging.
Configuration
| Variable | Default | Description |
|---|---|---|
MEMORYLAYER_EMBED_SERVER_HOST | 0.0.0.0 | Bind address |
MEMORYLAYER_EMBED_SERVER_PORT | 61051 | Listening port |
MEMORYLAYER_EMBED_SINGLE_VECTOR_PROVIDER | sentence_transformers | sentence_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_MODEL | provider default (sentence-transformers/all-MiniLM-L6-v2) | Single-vector model for the active provider |
MEMORYLAYER_EMBEDDING_DIMENSIONS | 384 | Vector width. Must match the model. |
MEMORYLAYER_EMBEDDING_ST_DEVICE | auto | cpu, cuda, mps, and so on, for the sentence-transformers provider. Pin to cpu to leave the GPU for ColPali. |
MEMORYLAYER_EMBEDDING_ST_BATCH_SIZE | 32 | Encode batch size for the sentence-transformers provider |
MEMORYLAYER_EMBED_MULTI_VECTOR_PROVIDER | vllm_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_MODEL | ModernVBERT/colmodernvbert | Multi-vector model. The vLLM path auto-upgrades the LoRA-adapter checkpoint to colmodernvbert-merged. |
MEMORYLAYER_EMBEDDING_COLPALI_POOL_FACTOR | 1 | Hierarchical token-pool factor. Must be the same for query-side and document-side calls. |
MEMORYLAYER_EMBEDDING_DEVICE | auto | Device for ColPali (separate from the sentence-transformers device) |
MEMORYLAYER_EMBEDDING_VLLM_GPU_MEM_UTIL | 0.25 | Per-vLLM-subprocess GPU memory budget. Lower it when sharing the GPU. |
EMBED_SERVER_RUN_SIDECAR | true (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.
| Provider | Default model | Dimensions |
|---|---|---|
sentence_transformers (default) | sentence-transformers/all-MiniLM-L6-v2 | 384 |
vllm_subprocess / vllm | Qwen/Qwen3-VL-Embedding-2B | 2048 |
openai | text-embedding-3-small | 1536 |
google | gemini-embedding-001 | 768 |
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-vecextension, the pure-Python fallback scores mismatched vectors as0.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-processvllm serve --runner poolingfor batched, paged-attention throughput. Needs a GPU.colpali_inprocess— colpali-engine via Hugging Face Transformers in the embed-server process. Loads the smallModernVBERT/colmodernvbertadapter (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:
MEMORYLAYER_EMBED_SINGLE_VECTOR_PROVIDER=sentence_transformers # defaultMEMORYLAYER_EMBED_MULTI_VECTOR_PROVIDER=colpali_inprocessMEMORYLAYER_EMBEDDING_ST_DEVICE=cpuMEMORYLAYER_EMBEDDING_DEVICE=cpuGPU 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:
| Dockerfile | Image | Notes |
|---|---|---|
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>-cuda13 | nvidia/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).
# 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 upGET /health/ready— required models are loaded and ready to serveGET /health/load— per-provider load snapshot (in-flight requests, utilization) for upstream load balancingGET /health/gpu— GPU memory status (returns503when 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 completionsGET /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
export MEMORYLAYER_EMBED_LLM_ENABLED=trueexport MEMORYLAYER_EMBED_LLM_PROFILES=qwen # comma-list of profile namesexport MEMORYLAYER_EMBED_LLM_DEFAULT_PROFILE=qwen # used when the request `model` doesn't matchexport MEMORYLAYER_EMBED_LLM_PRELOAD=false # default lazy; set true to start at bootexport 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-Instructexport MEMORYLAYER_EMBED_LLM_PROFILE_QWEN_ALIASES=qwen-7b,qwen2.5export MEMORYLAYER_EMBED_LLM_PROFILE_QWEN_GPU_MEM_UTIL=0.4Internal 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:
export MEMORYLAYER_LLM_PROFILE_INFERENCE_PROVIDER=embed_serverexport MEMORYLAYER_LLM_PROFILE_INFERENCE_MODEL=qwen # matches a profile/alias on the embed serverexport MEMORYLAYER_LLM_ASSIGN_REFLECTION=inference # route reflection through itEach 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-embedscan 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.
Related Pages
- Aether Transport — what running the embed peer behind Aether adds
- Server Configuration — core server environment variables for
embed_serverprovider wiring - Installation — end-to-end install flow
- Architecture — where the embed server fits in the system diagram
- aetherlayer.ai — Aether product site