Free Lab Series 10: Proving What Works — Paired Evaluation, Security Sandboxes & Model Cards
This dedicated lab series translates Hugging Face Learn modules and official documentation into ten step-by-step, reproducible engineering exercises that run cleanly on a standard Debian 12/13 CPU workstation or rootless OCI container—with zero CUDA or paid GPU subscription required.
Authored by Imad Soltani (human author, sole release authority) with Antigravity (Google DeepMind, non-human co-author).
1. Series Architecture, Hardware & Hugging Face Curriculum Linkage
- Permanent Series ID:
LAB-FREE-10· Cost / Tier (11E): Hugging Face Free ($0/mo) - Hardware Profile (10A): CPU-only (4 vCPU, 8 GB RAM, 10 GB disk — NO CUDA/GPU required)
- Hugging Face Learn (10F): https://huggingface.co/learn/llm-course/chapter8/1
- Hugging Face Docs (10F): https://huggingface.co/docs/evaluate/index
- GitHub Lab Sources: github.com/ximad/solarisk/lab/v106.0/free/series_10_evaluation-security-governance
7. Self-Check Comprehension Gate
Why does this lab series enforce a non-root multi-stage OCI container and idempotent Debian setup?
Multi-stage builds strip compilers and build secrets from the runtime layer, non-root UID execution limits blast radius if a dependency or prompt-triggered tool misbehaves, and idempotent Debian setup ensures repeatable runs across workstations and CI without hidden host drift.
How does the 30/30/30/10 progression split map to operational readiness?
Labs 01–03 establish clean data and deterministic baselines (Beginner), Labs 04–06 integrate adaptation, paired evaluation, and OCI packaging (Practitioner), Labs 07–09 harden latency, security boundaries, and governance compliance (Expert), and Lab 10 consolidates artifacts and primary documentation links (Capstone).
Complete 10-Lab Progression (30% Beginner · 30% Practitioner · 30% Expert · 10% Capstone & Resources)
| ID (10B) | Lab Module | Level | Duration | Cost / Tier | Expected Result & Capability (10F) |
|---|---|---|---|---|---|
| LAB-FREE-10-01 | Environment Bootstrap, Hub Auth & First Reproducible Pipeline | Beginner | 35 min | Hugging Face Free ($0/mo) | Verified Debian virtual environment & OCI container returning deterministic Hugging Face output. Capability (10F): After completing LAB-FREE-10-01, the reader can secure & govern reproducible 'environment bootstrap, hub auth & first reproducible pipeline' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-02 | Data Loading, Schema Inspection & SafeTensors Integrity Verification | Beginner | 40 min | Hugging Face Free ($0/mo) | Reproducible dataset split checksummed with zero pickle execution risk. Capability (10F): After completing LAB-FREE-10-02, the reader can secure & govern reproducible 'data loading, schema inspection & safetensors integrity verification' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-03 | Baseline Inference, Latency Profiling & Memory Measurement | Beginner | 45 min | Hugging Face Free ($0/mo) | Logged p50/p95 latency and RAM/VRAM footprint baseline in JSON. Capability (10F): After completing LAB-FREE-10-03, the reader can secure & govern reproducible 'baseline inference, latency profiling & memory measurement' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-04 | Task Adaptation, Prompt/Context Engineering & Structured Outputs | Practitioner | 50 min | Hugging Face Free ($0/mo) | Validated schema-compliant task output improving baseline accuracy by >= 10%. Capability (10F): After completing LAB-FREE-10-04, the reader can secure & govern reproducible 'task adaptation, prompt/context engineering & structured outputs' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-05 | Evaluation Harness, Paired Benchmarking & Error Analysis | Practitioner | 55 min | Hugging Face Free ($0/mo) | Reproducible paired evaluation table separating genuine gains from prompt noise. Capability (10F): After completing LAB-FREE-10-05, the reader can secure & govern reproducible 'evaluation harness, paired benchmarking & error analysis' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-06 | Packaging as an OCI Non-Root Service & Gradio/API Endpoint | Practitioner | 60 min | Hugging Face Free ($0/mo) | Hardened non-root OCI image running cleanly under Docker, containerd, and CRI-O. Capability (10F): After completing LAB-FREE-10-06, the reader can secure & govern reproducible 'packaging as an oci non-root service & gradio/api endpoint' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-07 | Performance Optimization: Quantization, Batching & Hardware Sizing | Expert | 65 min | Hugging Face Free ($0/mo) | Measured memory reduction and throughput gain under controlled latency SLOs. Capability (10F): After completing LAB-FREE-10-07, the reader can secure & govern reproducible 'performance optimization: quantization, batching & hardware sizing' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-08 | Adversarial Security Testing, Prompt-Injection & Policy Sandboxing | Expert | 70 min | Hugging Face Free ($0/mo) | Zero unauthorized tool/file egress under automated red-team test suite. Capability (10F): After completing LAB-FREE-10-08, the reader can secure & govern reproducible 'adversarial security testing, prompt-injection & policy sandboxing' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-09 | Governance, Model Card Provenance & EU AI Act Transparency Audit | Expert | 75 min | Hugging Face Free ($0/mo) | Complete Model Card + Article 50 / SPDX license disclosure bundle. Capability (10F): After completing LAB-FREE-10-09, the reader can secure & govern reproducible 'governance, model card provenance & eu ai act transparency audit' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
| LAB-FREE-10-10 | Series Capstone Architecture Review, Concept Recap & Upstream URLs | Synthesis & Resources (10%) | 45 min | Hugging Face Free ($0/mo) | Consolidated portfolio summary, updated Semantics glossary entries, and curated Hugging Face Learn/Docs syllabus. Capability (10F): After completing LAB-FREE-10-10, the reader can secure & govern reproducible 'series capstone architecture review, concept recap & upstream urls' workflows aligned with https://huggingface.co/learn/llm-course/chapter8/1 and https://huggingface.co/docs/evaluate/index. |
Debian 12/13 Commented Idempotent Setup & Python Runner (10C)
setup.sh (Debian 12/13 Bash)
#!/usr/bin/env bash
# ==============================================================================
# SolarisK Lab Series Setup — LAB-FREE-10 (evaluation-security-governance)
# Compatible with latest stable Debian Linux (Debian 12 Bookworm / 13 Trixie)
# Idempotent setup script with inline comments and destructive-action safety.
# ==============================================================================
set -euo pipefail
# Define isolated project virtual environment path (never pollutes global system Python)
LAB_VENV="${HOME}/.venvs/solarisk-free-10"
# Warn before any destructive reset requested via --reset
if [[ "${1:-}" == "--reset" ]]; then
echo "[WARNING] Destructive operation: removing existing virtualenv ${LAB_VENV} in 5s (Ctrl+C to abort)..."
sleep 5
rm -rf "${LAB_VENV}"
fi
# Verify Debian Python 3 & venv availability (idempotent check)
if ! command -v python3 >/dev/null 2>&1; then
echo "[ERROR] python3 not found. Install via: sudo apt-get update && sudo apt-get install -y python3 python3-venv python3-pip"
exit 1
fi
# CPU-only lab series: zero CUDA/ROCm/GPU configuration required.
# Create virtual environment idempotently if missing
if [[ ! -d "${LAB_VENV}" ]]; then
echo "[SETUP] Creating isolated Python virtual environment at ${LAB_VENV}..."
python3 -m venv "${LAB_VENV}"
fi
# Upgrade pip and install pinned baseline Hugging Face client packages inside the venv
"${LAB_VENV}/bin/pip" install --quiet --upgrade pip
"${LAB_VENV}/bin/pip" install --quiet huggingface_hub safetensors
echo "[READY] Activate with: source ${LAB_VENV}/bin/activate"
echo "[READY] Run lab harness: ${LAB_VENV}/bin/python3 run_lab.py --check"
run_lab.py (Executable Python Source)
#!/usr/bin/env python3
"""
SolarisK Reproducible Lab Runner — LAB-FREE-10: Model Cards, Prompt-Injection Audits & Reproducible Evals
Hugging Face Learn: https://huggingface.co/learn/llm-course/chapter8/1
Hugging Face Docs: https://huggingface.co/docs/evaluate/index
"""
import argparse, json, os, platform, sys
from datetime import datetime, timezone
def main():
parser = argparse.ArgumentParser(description="SolarisK Lab Series LAB-FREE-10")
parser.add_argument("--check", action="store_true", help="Verify runtime environment and Hugging Face token visibility")
args = parser.parse_args()
report = {
"series_id": "LAB-FREE-10",
"slug": "evaluation-security-governance",
"tier": "FREE",
"timestamp_utc": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"python": platform.python_version(),
"os": platform.platform(),
"hf_token_configured": bool(os.environ.get("HF_TOKEN")),
"learn_module": "https://huggingface.co/learn/llm-course/chapter8/1",
"docs_module": "https://huggingface.co/docs/evaluate/index",
"status": "READY"
}
print(json.dumps(report, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()
OCI Multi-Stage Non-Root Container & Docker / containerd / CRI-O Runbook (10D)
Containerfile (opencontainers.org)
# Multi-stage OCI-compliant Containerfile (opencontainers.org) — CPU-Only Lab (evaluation-security-governance)
# NO CUDA, ROCm, or GPU drivers required.
FROM debian:bookworm-slim AS builder
ENV PIP_NO_CACHE_DIR=1 PYTHONDONTWRITEBYTECODE=1
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip && pip install transformers datasets safetensors huggingface_hub evaluate
FROM debian:bookworm-slim AS runtime
LABEL org.opencontainers.image.title="solarisk-hf-lab-evaluation-security-governance" \
org.opencontainers.image.source="https://github.com/ximad/solarisk" \
org.opencontainers.image.licenses="MIT"
RUN apt-get update && apt-get install -y --no-install-recommends python3 ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --uid 10001 --shell /usr/sbin/nologin solarisk
COPY --from=builder /opt/venv /opt/venv
WORKDIR /home/solarisk/lab
COPY --chown=10001:10001 run_lab.py /home/solarisk/lab/run_lab.py
ENV PATH="/opt/venv/bin:$PATH" HF_HOME="/home/solarisk/.cache/huggingface"
USER 10001:10001
ENTRYPOINT ["python3", "/home/solarisk/lab/run_lab.py"]
Docker, containerd (nerdctl), and CRI-O Commands
# CPU-only lab: NO CUDA, ROCm, or NVIDIA Container Toolkit required.
# 1. Docker (OCI-compliant multi-stage non-root image)
docker build -f Containerfile -t solarisk/lab-free-10:latest .
docker run --rm --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-free-10:latest
# 2. containerd via nerdctl (rootless OCI workflow)
nerdctl build -f Containerfile -t solarisk/lab-free-10:latest .
nerdctl run --rm --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-free-10:latest
# 3. CRI-O / Podman (Kubernetes CRI-O node verification via crictl / podman)
podman build -f Containerfile -t localhost/solarisk/lab-free-10:latest .
podman run --rm --userns=keep-id -e HF_TOKEN="$HF_TOKEN" localhost/solarisk/lab-free-10:latest
# On CRI-O cluster nodes, pull the OCI image and inspect pod sandbox via: crictl images | grep lab-free-10Troubleshooting: Two Most Common Errors & Deterministic Fixes (10E)
Occurs when loading full-precision checkpoints on an 8 GB RAM host without CPU thread capping or local cache persistence. Pin `OMP_NUM_THREADS=4`, keep `HF_HOME` on a persistent volume, and use compact safetensors checkpoints—no CUDA or GPU driver is required.
Occurs when mixing global `pip` packages with Debian system Python or hitting anonymous Hub rate limits. Always execute inside `.venv` created by `setup.sh` (or the multi-stage non-root OCI container) and export a free read-only `HF_TOKEN`.
Living Semantics Chapter — Human Glossary & Machine-Readable RAG Index (12A–12D)
| Term / Concept (12A–12C) | Category | Explanation & Operational Boundary |
|---|---|---|
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Scoped bearer token granting read/write access to gated models, private datasets, and Inference Providers without embedding credentials in code. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Container specification (`opencontainers.org`) separating build dependencies from a minimal runtime stage running under non-privileged UID `10001`. |
| SafeTensors (`.safetensors`) | Security | Memory-safe tensor storage format replacing Python `pickle` to prevent arbitrary code execution on checkpoint load. |
| ZeroGPU / Inference Providers | Compute | Managed Hugging Face GPU sharing (Free ~5 min/day vs PRO 8x priority) and serverless API routing (`router.huggingface.co`). |
| Paired Evaluation Harness | Reliability | Controlled benchmark execution holding prompts, seeds, and dataset splits constant to measure true capability deltas. |
| 30 / 30 / 30 / 10 Mastery Progression | Pedagogy | Curriculum pacing allocating 30% of labs/time to Beginner foundations, 30% to Practitioner integration, 30% to Expert hardening/optimization, and 10% to Capstone synthesis and primary resource indexing. |
| Idempotent Debian Setup & Rootless OCI Runtime | Reproducibility | Execution hygiene guaranteeing that setup.sh can be re-run safely on Debian 12/13 without state corruption and that the same workflow runs identically under Docker, containerd (nerdctl), or CRI-O under a non-root UID. |
No comments:
Post a Comment