qwen-scope-live / Dockerfile
Ex0bit's picture
initial qwen-scope-live deploy
f2ae1f5 verified
# Qwen-Scope Live SAE Feature Steering — HF Space Docker SDK image.
# Free tier (CPU, ~16GB RAM) — locked to Qwen3-1.7B-Base only.
FROM python:3.11-slim
# Avoid interactive prompts during installs
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
HF_HUB_DISABLE_TELEMETRY=1 \
TRANSFORMERS_NO_ADVISORY_WARNINGS=1
# HF Spaces convention: /home/user is writable, expects PORT=7860
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
HF_HOME=/home/user/.cache/huggingface \
PORT=7860
# Add a non-root user (HF Spaces best practice)
RUN useradd -m -u 1000 user && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential ca-certificates && \
rm -rf /var/lib/apt/lists/*
USER user
WORKDIR $HOME/app
# Install Python deps (CPU-only torch from PyTorch index)
COPY --chown=user:user requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Copy application files
COPY --chown=user:user qwen_scope_steer.py qwen_scope_obs.py server.py index.html ./
# Pre-create cache dir (writable for the cached SAE positions JSON)
RUN mkdir -p $HOME/app/feature_positions
EXPOSE 7860
CMD ["python", "server.py"]