File size: 1,257 Bytes
f2ae1f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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"]