feat(matching): rank with semantic embeddings and explain matches by evidence
This commit is contained in:
1 parent
facc1789b1
commit
24b64d698a
215 files changed
+16951
-327
No files matched your search
+28
-6
@@ -1,10 +1,14 @@
|
||||
# The base image is a build argument so that make -C deploy release-build can
|
||||
# pin it to the digest it resolved; the default keeps the agreed tag.
|
||||
ARG PYTHON_IMAGE=python:alpine
|
||||
# pin it to the digest it resolved. PyTorch publishes glibc wheels only, so the
|
||||
# service uses the Debian slim variant instead of Alpine, and the minor version
|
||||
# is fixed because requires-python and the locked wheels are for Python 3.14.
|
||||
ARG PYTHON_IMAGE=python:3.14-slim
|
||||
|
||||
FROM ${PYTHON_IMAGE} AS base
|
||||
|
||||
RUN apk upgrade --no-cache
|
||||
RUN apt-get update \
|
||||
&& apt-get upgrade --yes --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM base AS build
|
||||
|
||||
@@ -20,20 +24,38 @@ COPY ml/.python-version ml/pyproject.toml ml/uv.lock ./ml/
|
||||
COPY ml/src ./ml/src
|
||||
RUN uv sync --project ml --python /usr/local/bin/python --locked --no-dev --no-editable
|
||||
|
||||
# The model files are fetched once, at build time, from the pinned revision
|
||||
# and verified against the SHA-256 of the lock file. Only safetensors weights,
|
||||
# configs, and the tokenizer are fetched: no remote code, no pickle weights.
|
||||
FROM base AS model
|
||||
|
||||
COPY ml/src/lincodex_ml/model_files.py /tmp/model_files.py
|
||||
COPY ml/model/giga-embeddings-480m.lock.json /tmp/model.lock.json
|
||||
RUN python /tmp/model_files.py fetch --lock /tmp/model.lock.json --out /opt/lincodex/model \
|
||||
&& rm /tmp/model_files.py /tmp/model.lock.json
|
||||
|
||||
FROM base
|
||||
|
||||
ENV PATH="/opt/venv/bin:${PATH}" \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
PYTHONUNBUFFERED=1 \
|
||||
ML_EMBEDDER=giga \
|
||||
ML_MODEL_DIR=/opt/lincodex/model \
|
||||
ML_TORCH_THREADS=4 \
|
||||
HF_HUB_OFFLINE=1 \
|
||||
TRANSFORMERS_OFFLINE=1 \
|
||||
HF_HUB_DISABLE_TELEMETRY=1
|
||||
|
||||
WORKDIR /app
|
||||
# Package installation belongs to the build stage, not the service runtime.
|
||||
RUN python -m pip uninstall --yes pip \
|
||||
&& python -c "import ensurepip, shutil; shutil.rmtree(ensurepip.__path__[0])" \
|
||||
&& addgroup -S -g 10001 lincodex \
|
||||
&& adduser -S -D -H -u 10001 -G lincodex lincodex
|
||||
&& groupadd --system --gid 10001 lincodex \
|
||||
&& useradd --system --uid 10001 --gid lincodex --no-create-home --shell /usr/sbin/nologin lincodex
|
||||
|
||||
COPY --from=build --chown=lincodex:lincodex /opt/venv /opt/venv
|
||||
# Read-only for the service user: root owns the weights.
|
||||
COPY --from=model /opt/lincodex/model /opt/lincodex/model
|
||||
|
||||
USER 10001:10001
|
||||
EXPOSE 8000
|
||||
|
||||
Reference in new issue
Block a user