Skip to content

Two-tower retrieval libraries for the embedded Apple Silicon service

Status: research, 2026-09-25. This is a library assessment, not an approved design or implementation. Sources below are first-party documentation, package metadata, and source. The current repository targets Python 3.12–3.14, has an optional PyTorch extra, and publishes scope-local CPU Faiss HNSW artifacts; see pyproject.toml and ann.py.

Answer and recommendation

Yes: libraries implement the two-tower retrieval architecture, loss, metrics, and training loop. None is a turnkey commerce-recommendation service that automatically supplies this product's Commerce Scope isolation, time-correct training examples, privacy limits, eligibility, atomic snapshots, or cold-item semantics. The two towers must emit same-width vectors trained for a dot-product or cosine objective. Candidate vectors can be exported as contiguous float32 arrays into the existing Faiss builder; query vectors must use the same model version and preprocessing. TensorFlow Recommenders tutorial, TorchRec two-tower/Faiss example, current ANN code.

For the existing embedded macOS 26+ Apple Silicon service, start a proof of fit with ordinary PyTorch nn.Module towers on MPS, using the already-declared optional torch dependency, and consider Lightning only if its trainer removes meaningful loop boilerplate. PyTorch 2.14 publishes a CPython 3.14 macOS ARM64 wheel, and PyTorch documents MPS training/inference on Apple silicon; Lightning supports an MPS accelerator but warns of unsupported operations. This reuses Faiss and avoids a second model-serving stack. It is not a prebuilt recommendation model: feature encoders, positive/negative pair construction, loss wiring, and artifact lifecycle remain application work. A small object-oriented model/trainer/artifact boundary should contain these responsibilities, not accumulate strategy if branches in serving. PyTorch wheel, PyTorch MPS, Apple's PyTorch guidance, Lightning MPS.

If avoiding architecture code is more important than staying on the current Python/MPS stack, TensorFlow Recommenders (TFRS) is the clearest prebuilt retrieval task: it provides tfrs.tasks.Retrieval, in-batch negatives, FactorizedTopK metrics, and examples for user-to-item and item-to-item two towers. But current TensorFlow install documentation lists macOS Arm64 wheels through Python 3.13, while Apple's latest published tensorflow-metal wheel is for CPython 3.9–3.12. There is no published 3.14 Metal wheel in that release. TFRS could be trialed in a separate, pinned Python 3.12 training environment, but this is a worse fit for the current Python 3.14 development environment and would add artifact/interpreter integration. Do not assume GPU acceleration without an install-and-train smoke test. TFRS retrieval API, TFRS tutorial, TensorFlow wheels, Apple Metal wheel list, Apple Metal guidance.

Candidates

Library What it supplies Fit and limitation here
TensorFlow Recommenders (Apache-2.0 package) Explicit query/candidate towers, retrieval loss, full-corpus top-K evaluation, Keras preprocessing, and exportable SavedModel/ScaNN examples. Its tutorial explicitly discusses item-to-item pairs. Most complete direct API, but TensorFlow/Metal wheel availability does not cover this repo's Python 3.14 development interpreter; ScaNN/TensorFlow Serving are unnecessary because Faiss is already embedded. Training candidate vectors into Faiss instead of ScaNN is an integration step, not a provided TFRS workflow.
TorchRec (BSD-3-Clause license) Sparse embedding collections, sharding, distributed training, inference/quantization, and an explicit two-tower + Faiss example. Designed for large multi-GPU recommender systems. Its current introduction asks for CUDA/FBGEMM, and the cited Faiss inference example asserts CUDA availability. PyPI has Python 3.14 wheels, but that does not establish Apple MPS execution of its FBGEMM/sharded components. Keep it as a design reference unless a focused MPS packaging/runtime spike passes. TorchRec introduction, PyPI files.
RecBole DSSM (MIT package) A ready-made double-tower model, training runner, dataset conventions, and evaluation tooling. Useful for a disposable baseline experiment. Its documented interaction-file workflow expects user/item records and its GPU instructions target CUDA; neither establishes compatibility with this service's no-raw-staging rule or Apple MPS. Do not import its data pipeline into production without a separate privacy and runtime design. RecBole data workflow, official installation.
NVIDIA Merlin Models (Apache-2.0 license) Higher-level retrieval architectures including Two Tower/YouTube DNN; schema-driven preprocessing, dataloaders, and integration with Merlin Systems/Triton. Documentation describes GPU-accelerated NVIDIA/CUDA containers and dependencies on NVTabular; its PyTorch API is described as incomplete. This is not an Apple Silicon embedded fit. Merlin README, Merlin Systems.
Sentence Transformers (Apache-2.0 source) Pretrained/fine-tunable bi-encoders, contrastive retrieval losses, training/evaluation and MPS text embedding inference. Bi-encoder training, MPS inference. Good candidate tower or product-text Similar Items challenger, not a ready-made Shopper History/user tower, structured price/category encoder, or commerce objective. Public pretrained search models are trained on text retrieval, not substitute/purchase relevance.
Plain PyTorch + optional Lightning (PyTorch license, Lightning license) Native MPS tensor/model execution; Lightning can own optimizer, epoch/checkpoint and evaluation loops. Best platform fit and easiest Faiss interop, but a project-specific two-tower module and data/loss contracts are still required. Lightning is training infrastructure, not a recommendation algorithm. PyTorch MPS, Lightning training model.

Integration boundary to validate before selecting

  1. Training pairs: two distinct tasks are plausible: Shopper Profile/context → purchased/viewed Item for For You, and anchor Item → co-considered/substitute Item for Similar Items. TFRS explicitly distinguishes user-item from item-item training. They need separate relevance evaluation and possibly separate models or objectives; a single universal tower is not justified by library availability. TFRS item-to-item section, current evaluation limits.
  2. Feature and privacy contract: stream/reduce raw source interactions, use property-local bounded projections, and never stage raw Shopper/Order/Session identifiers. Fit vocabularies/normalizers only on the training cutoff; version them with the weights. Those are repository-specific requirements, not capabilities supplied by the libraries. Repository context, personalization contract.
  3. Snapshot interface: batch-encode only eligible candidate Items, validate finite normalized same-width float32 vectors, build the existing eligible-only Faiss index, and publish weights/preprocessing/vector/index/mapping under one Commerce Scope and one atomic Recommendation Snapshot. A query embedding from a different model generation must not search that index. This is an architectural inference from the current snapshot contract and Faiss integration, not a library guarantee. Current ANN implementation, implementation contract.
  4. Proof before dependency decision: on the reference Apple Silicon machine, verify package installation in the configured interpreter, one MPS forward/backward batch for actual sparse/dense feature shapes, float32 export and Faiss retrieval, deterministic reload, bounded memory/training time, and relevance versus the current sparse/ANN baseline. MPS op support and performance are workload-dependent. PyTorch MPS, Apple PyTorch guidance, existing ANN evidence.

Decision status

Recommend PyTorch/MPS proof of fit first; TFRS Python-3.12 isolated spike only if reducing model code outweighs a second framework. TorchRec and Merlin are not recommended as production dependencies for this embedded Apple Silicon target. Sentence Transformers is a narrower product-text representation challenger. No package was installed or benchmarked for this note, so these are compatibility and architecture findings—not measured performance claims.