HUGGING FACE FREE LAB SERIES · 10 REPRODUCIBLE LABS
Free Lab Series 01: Teaching Silicon to Read — Language Models & Tokenizers on CPU
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
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 | Series-Specific Lab Module | Level | Duration | Cost / Tier | Expected Result & Capability |
|---|
| LAB-FREE-01-01 | Pipeline Anatomy & Model Cards on CPU | Beginner | 35 min | Free ($0/mo) | Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F): Design, verify, and deploy reproducible 'Pipeline Anatomy & Model Cards on CPU' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-02 | Byte-Pair Encoding & WordPiece Deep Dive | Beginner | 40 min | Free ($0/mo) | Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F): Design, verify, and deploy reproducible 'Byte-Pair Encoding & WordPiece Deep Dive' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-03 | Batch Padding, Attention Masks & KV Footprint | Beginner | 45 min | Free ($0/mo) | Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F): Design, verify, and deploy reproducible 'Batch Padding, Attention Masks & KV Footprint' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-04 | Custom Tokenizer Training with tokenizers | Practitioner | 50 min | Free ($0/mo) | Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F): Design, verify, and deploy reproducible 'Custom Tokenizer Training with tokenizers' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-05 | Deterministic Decoding: Greedy, Top-p & Repetition Control | Practitioner | 55 min | Free ($0/mo) | Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F): Design, verify, and deploy reproducible 'Deterministic Decoding: Greedy, Top-p & Repetition Control' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-06 | Gradio CPU Chat Demo in Rootless OCI | Practitioner | 60 min | Free ($0/mo) | Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F): Design, verify, and deploy reproducible 'Gradio CPU Chat Demo in Rootless OCI' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-07 | ONNX Runtime & INT8 Dynamic CPU Quantization | Expert | 65 min | Free ($0/mo) | Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F): Design, verify, and deploy reproducible 'ONNX Runtime & INT8 Dynamic CPU Quantization' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-08 | Prompt Boundary & Special-Token Injection Hardening | Expert | 70 min | Free ($0/mo) | Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F): Design, verify, and deploy reproducible 'Prompt Boundary & Special-Token Injection Hardening' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-09 | SPDX License & Model Card Provenance Audit | Expert | 75 min | Free ($0/mo) | Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F): Design, verify, and deploy reproducible 'SPDX License & Model Card Provenance Audit' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
| LAB-FREE-01-10 | Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus | Capstone & Resources (10%) | 45 min | Free ($0/mo) | Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
Living Semantics & Disambiguation Table
| Term | Domain | Operational Definition |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | Subword compression iteratively merging the most frequent byte/character pairs; governs context cost across scripts. |
| Attention Mask | Architecture | Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | Deterministic serializer mapping system/user/assistant roles into special control tokens; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Executable Lab Kit (Bash / Python / OCI — kept in canonical LTR code format below)
SÉRIE PRATIQUE GRATUITE HUGGING FACE · 10 TRAVAUX PRATIQUES REPRODUCTIBLES
Série pratique gratuite 01 : Apprendre au silicium à lire — modèles de langage et tokeniseurs sur CPU
Cette série dédiée traduit les cours Hugging Face Learn et la documentation officielle en dix travaux pratiques reproductibles pas à pas sur poste Debian 12/13 CPU ou conteneur OCI sans privilèges root — sans aucune dépendance CUDA ni abonnement payant.
Rédigé par Imad Soltani (auteur humain, seule autorité de publication) avec Antigravity (Google DeepMind, co-auteur non humain).
1. Architecture de la série, matériel et lien avec Hugging Face Learn
7. Auto-évaluation de compréhension
Pourquoi cette série impose-t-elle un conteneur OCI multi-étapes non-root et un script Debian idempotent ?
La construction multi-étapes élimine les compilateurs de l’image finale, l’exécution sans privilèges root réduit la surface d’impact en cas d’outil compromis, et l’idempotence garantit des exécutions reproductibles sous Debian 12/13 sans dérive de configuration.
Comment la répartition 30/30/30/10 prépare-t-elle au déploiement réel ?
Les travaux 01 à 03 posent les bases reproductibles (Débutant), 04 à 06 couvrent l’adaptation, l’évaluation appariée et l’empaquetage OCI (Praticien), 07 à 09 traitent la performance, la sécurité et la conformité (Expert), et le travail 10 consolide la synthèse et les sources officielles.
Progression complète en 10 laboratoires (30 % Débutant · 30 % Praticien · 30 % Expert · 10 % Synthèse)
| ID | Module de laboratoire dédié | Niveau | Durée | Coût / Palier | Résultat attendu et capacité |
|---|
LAB-FREE-01-01 | Module technique : Pipeline Anatomy et Model Cards on CPU | Débutant | 35 min | Gratuit ($0) | Livrable vérifié : Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F) : Design, verify, and deploy reproducible ’Pipeline Anatomy et Model Cards on CPU’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-02 | Module technique : Byte-Pair Encoding et WordPiece Deep Dive | Débutant | 40 min | Gratuit ($0) | Livrable vérifié : Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F) : Design, verify, and deploy reproducible ’Byte-Pair Encoding et WordPiece Deep Dive’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-03 | Module technique : Batch Padding, Attention Masks et KV Footprint | Débutant | 45 min | Gratuit ($0) | Livrable vérifié : Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F) : Design, verify, and deploy reproducible ’Batch Padding, Attention Masks et KV Footprint’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-04 | Module technique : Custom Tokenizer Training with tokenizers | Praticien | 50 min | Gratuit ($0) | Livrable vérifié : Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F) : Design, verify, and deploy reproducible ’Custom Tokenizer Training with tokenizers’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-05 | Module technique : Deterministic Decoding : Greedy, Top-p et Repetition Control | Praticien | 55 min | Gratuit ($0) | Livrable vérifié : Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F) : Design, verify, and deploy reproducible ’Deterministic Decoding : Greedy, Top-p et Repetition Control’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-06 | Module technique : Gradio CPU Chat Demo in Rootless OCI | Praticien | 60 min | Gratuit ($0) | Livrable vérifié : Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F) : Design, verify, and deploy reproducible ’Gradio CPU Chat Demo in Rootless OCI’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-07 | Module technique : ONNX Runtime et INT8 Dynamic CPU Quantization | Expert | 65 min | Gratuit ($0) | Livrable vérifié : Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F) : Design, verify, and deploy reproducible ’ONNX Runtime et INT8 Dynamic CPU Quantization’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-08 | Module technique : Prompt Boundary et Special-Token Injection Hardening | Expert | 70 min | Gratuit ($0) | Livrable vérifié : Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F) : Design, verify, and deploy reproducible ’Prompt Boundary et Special-Token Injection Hardening’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-09 | Module technique : SPDX License et Model Card Provenance Audit | Expert | 75 min | Gratuit ($0) | Livrable vérifié : Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F) : Design, verify, and deploy reproducible ’SPDX License et Model Card Provenance Audit’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-10 | Module technique : Capstone : End-to-End CPU LLM Reference Pack et HF Learn Syllabus | Synthèse | 45 min | Gratuit ($0) | Livrable vérifié : Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F) : Design, verify, and deploy reproducible ’Capstone : End-to-End CPU LLM Reference Pack et HF Learn Syllabus’ workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
Table de sémantique vivante et désambiguïsation
| Terme | Domaine | Définition opérationnelle |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | Définition technique : Subword compression iteratively merging the most frequent byte/character pairs ; governs context cost across scripts. |
| Attention Mask | Architecture | Définition technique : Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | Définition technique : Deterministic serializer mapping system/user/assistant roles into special control tokens ; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Définition technique : Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Définition technique : Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Définition technique : Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Définition technique : Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Kit exécutable de laboratoire (Bash / Python / OCI — conservé en format de code canonique LTR ci-dessous)
HUGGING FACE 免费实战系列 · 10 个可复现实验
免费实战系列 01:让芯片学会阅读——纯 CPU 语言模型与分词器
本独立专题实验系列将 Hugging Face Learn 课程模块与官方文档拆解为十个可逐步复现的工程实验,可在标准 Debian 12/13 纯 CPU 环境或非 root OCI 容器中直接运行,无需 CUDA 或付费 GPU。
由 Imad Soltani(人类作者,唯一生产发布授权人)与 Antigravity(Google DeepMind,非人类合著者)共同编写。
1. 系列架构、硬件要求与 Hugging Face 官方课程映射
7. 自测理解关卡
为何本实验系列同时要求多阶段非 root OCI 容器与幂等 Debian 脚本?
多阶段构建将编译工具链剥离出运行层,非 root 用户限制依赖或工具越权时的爆炸半径,而幂等脚本确保在任意 Debian 12/13 主机上重复运行都能得到一致结果。
30/30/30/10 进阶结构如何支撑真实系统落地?
实验 01–03 建立可复现基线(入门),04–06 完成任务适配、成对评测与容器封装(实践),07–09 强化性能、安全边界与合规披露(专家),实验 10 汇总成果并索引权威文档。
完整 10 阶实验路线(30% 入门 · 30% 实践 · 30% 专家 · 10% 综合封顶)
| 编号 | 专题实验模块 | 等级 | 时长 | 成本 / 层级 | 预期成果与工程能力 |
|---|
LAB-FREE-01-01 | 专题模块:Pipeline Anatomy & Model Cards on CPU | 入门 | 35 分钟 | 免费 ($0) | 验证成果:Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F): Design, verify, and deploy reproducible 'Pipeline Anatomy & Model Cards on CPU' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-02 | 专题模块:Byte-Pair Encoding & WordPiece Deep Dive | 入门 | 40 分钟 | 免费 ($0) | 验证成果:Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F): Design, verify, and deploy reproducible 'Byte-Pair Encoding & WordPiece Deep Dive' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-03 | 专题模块:Batch Padding, Attention Masks & KV Footprint | 入门 | 45 分钟 | 免费 ($0) | 验证成果:Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F): Design, verify, and deploy reproducible 'Batch Padding, Attention Masks & KV Footprint' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-04 | 专题模块:Custom Tokenizer Training with tokenizers | 实践 | 50 分钟 | 免费 ($0) | 验证成果:Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F): Design, verify, and deploy reproducible 'Custom Tokenizer Training with tokenizers' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-05 | 专题模块:Deterministic Decoding: Greedy, Top-p & Repetition Control | 实践 | 55 分钟 | 免费 ($0) | 验证成果:Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F): Design, verify, and deploy reproducible 'Deterministic Decoding: Greedy, Top-p & Repetition Control' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-06 | 专题模块:Gradio CPU Chat Demo in Rootless OCI | 实践 | 60 分钟 | 免费 ($0) | 验证成果:Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F): Design, verify, and deploy reproducible 'Gradio CPU Chat Demo in Rootless OCI' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-07 | 专题模块:ONNX Runtime & INT8 Dynamic CPU Quantization | 专家 | 65 分钟 | 免费 ($0) | 验证成果:Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F): Design, verify, and deploy reproducible 'ONNX Runtime & INT8 Dynamic CPU Quantization' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-08 | 专题模块:Prompt Boundary & Special-Token Injection Hardening | 专家 | 70 分钟 | 免费 ($0) | 验证成果:Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F): Design, verify, and deploy reproducible 'Prompt Boundary & Special-Token Injection Hardening' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-09 | 专题模块:SPDX License & Model Card Provenance Audit | 专家 | 75 分钟 | 免费 ($0) | 验证成果:Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F): Design, verify, and deploy reproducible 'SPDX License & Model Card Provenance Audit' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-10 | 专题模块:Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus | 综合封顶 | 45 分钟 | 免费 ($0) | 验证成果:Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
动态语义与术语消歧表
| 术语 | 所属领域 | 工程操作定义 |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | 技术定义:Subword compression iteratively merging the most frequent byte/character pairs; governs context cost across scripts. |
| Attention Mask | Architecture | 技术定义:Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | 技术定义:Deterministic serializer mapping system/user/assistant roles into special control tokens; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | 技术定义:Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | 技术定义:Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | 技术定义:Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | 技术定义:Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
可执行实验代码套件(Bash / Python / OCI — 下方保持规范 LTR 代码格式)
HUGGING FACE 免費實作系列 · 10 個可重現實驗
免費實作系列 01:讓晶片學會閱讀——純 CPU 語言模型與分詞器
本獨立專題實驗系列將 Hugging Face Learn 課程模組與官方文件拆解為十個可逐步重現的工程實驗,可在標準 Debian 12/13 純 CPU 環境或非 root OCI 容器中直接執行,無需 CUDA 或付費 GPU。
由 Imad Soltani(人類作者,唯一生產發布授權人)與 Antigravity(Google DeepMind,非人類合著者)共同撰寫。
1. 系列架構、硬體需求與 Hugging Face 官方課程對應
7. 自我檢測理解關卡
為何本實驗系列同時要求多階段非 root OCI 容器與冪等 Debian 腳本?
多階段建置將編譯工具鏈自執行層剝離,非 root 使用者能降低相依套件或工具越權時的影響範圍,而冪等腳本確保在任何 Debian 12/13 主機重複執行都能獲得一致結果。
30/30/30/10 進階結構如何支撐真實系統落地?
實驗 01–03 建立可重現基線(入門),04–06 完成任務適配、成對評測與容器封裝(實踐),07–09 強化效能、安全邊界與合規揭露(專家),實驗 10 彙整成果並索引權威文件。
完整 10 階實作進程(30% 入門 · 30% 實務 · 30% 專家 · 10% 總結專題)
| 編號 | 專題實作模組 | 級別 | 時長 | 費用 / 層級 | 預期成果與工程能力 |
|---|
LAB-FREE-01-01 | 專題模組:Pipeline Anatomy & Model Cards on CPU | 入門 | 35 分鐘 | 免費 ($0) | 驗證成果:Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F): Design, verify, and deploy reproducible 'Pipeline Anatomy & Model Cards on CPU' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-02 | 專題模組:Byte-Pair Encoding & WordPiece Deep Dive | 入門 | 40 分鐘 | 免費 ($0) | 驗證成果:Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F): Design, verify, and deploy reproducible 'Byte-Pair Encoding & WordPiece Deep Dive' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-03 | 專題模組:Batch Padding, Attention Masks & KV Footprint | 入門 | 45 分鐘 | 免費 ($0) | 驗證成果:Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F): Design, verify, and deploy reproducible 'Batch Padding, Attention Masks & KV Footprint' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-04 | 專題模組:Custom Tokenizer Training with tokenizers | 實務 | 50 分鐘 | 免費 ($0) | 驗證成果:Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F): Design, verify, and deploy reproducible 'Custom Tokenizer Training with tokenizers' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-05 | 專題模組:Deterministic Decoding: Greedy, Top-p & Repetition Control | 實務 | 55 分鐘 | 免費 ($0) | 驗證成果:Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F): Design, verify, and deploy reproducible 'Deterministic Decoding: Greedy, Top-p & Repetition Control' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-06 | 專題模組:Gradio CPU Chat Demo in Rootless OCI | 實務 | 60 分鐘 | 免費 ($0) | 驗證成果:Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F): Design, verify, and deploy reproducible 'Gradio CPU Chat Demo in Rootless OCI' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-07 | 專題模組:ONNX Runtime & INT8 Dynamic CPU Quantization | 專家 | 65 分鐘 | 免費 ($0) | 驗證成果:Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F): Design, verify, and deploy reproducible 'ONNX Runtime & INT8 Dynamic CPU Quantization' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-08 | 專題模組:Prompt Boundary & Special-Token Injection Hardening | 專家 | 70 分鐘 | 免費 ($0) | 驗證成果:Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F): Design, verify, and deploy reproducible 'Prompt Boundary & Special-Token Injection Hardening' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-09 | 專題模組:SPDX License & Model Card Provenance Audit | 專家 | 75 分鐘 | 免費 ($0) | 驗證成果:Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F): Design, verify, and deploy reproducible 'SPDX License & Model Card Provenance Audit' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-10 | 專題模組:Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus | 總結專題 | 45 分鐘 | 免費 ($0) | 驗證成果:Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
動態語意與術語消歧對照表
| 術語 | 領域 | 工程操作定義 |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | 技術定義:Subword compression iteratively merging the most frequent byte/character pairs; governs context cost across scripts. |
| Attention Mask | Architecture | 技術定義:Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | 技術定義:Deterministic serializer mapping system/user/assistant roles into special control tokens; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | 技術定義:Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | 技術定義:Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | 技術定義:Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | 技術定義:Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
可執行實作程式碼套件(Bash / Python / OCI — 下方維持標準 LTR 程式碼格式)
DARMOWA SERIA LABORATORYJNA HUGGING FACE · 10 POWTARZALNYCH LABORATORIÓW
Darmowa seria laboratoryjna 01: Jak krzem uczy się czytać — modele językowe i tokenizatory na CPU
Ta dedykowana seria przekłada moduły Hugging Face Learn i dokumentację na dziesięć powtarzalnych ćwiczeń inżynierskich dla systemu Debian 12/13 na samym CPU lub w kontenerze OCI bez uprawnień root — bez wymogu CUDA ani płatnego planu GPU.
Autor: Imad Soltani (autor ludzki, wyłączny decydent wydań produkcyjnych) we współpracy z Antigravity (Google DeepMind, współautor nieludzki).
1. Architektura serii, wymagania sprzętowe i powiązanie z Hugging Face Learn
7. Pytania kontrolne (samosprawdzenie)
Dlaczego ta seria wymaga wieloetapowego kontenera OCI bez uprawnień root oraz idempotentnego skryptu Debian?
Budowa wieloetapowa usuwa kompilatory z warstwy uruchomieniowej, brak uprawnień root ogranicza skutki błędów zależności, a idempotentność zapewnia powtarzalne środowisko na każdym hoście Debian 12/13.
W jaki sposób podział 30/30/30/10 buduje gotowość produkcyjną?
Laboratoria 01–03 ustanawiają powtarzalną bazę (Początkujący), 04–06 obejmują adaptację, ewaluację parowaną i pakowanie OCI (Praktyk), 07–09 wzmacniają wydajność, bezpieczeństwo i zgodność (Ekspert), a laboratorium 10 spina artefakty i źródła.
Pełna ścieżka 10 laboratoriów (30% Podstawowy · 30% Praktyk · 30% Ekspert · 10% Zwieńczenie)
| ID | Dedykowany moduł laboratoryjny | Poziom | Czas | Koszt / Plan | Oczekiwany rezultat i kompetencja |
|---|
LAB-FREE-01-01 | Moduł techniczny: Pipeline Anatomy & Model Cards on CPU | Podstawowy | 35 min | Bezpłatny ($0) | Zweryfikowany rezultat: Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F): Design, verify, and deploy reproducible 'Pipeline Anatomy & Model Cards on CPU' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-02 | Moduł techniczny: Byte-Pair Encoding & WordPiece Deep Dive | Podstawowy | 40 min | Bezpłatny ($0) | Zweryfikowany rezultat: Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F): Design, verify, and deploy reproducible 'Byte-Pair Encoding & WordPiece Deep Dive' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-03 | Moduł techniczny: Batch Padding, Attention Masks & KV Footprint | Podstawowy | 45 min | Bezpłatny ($0) | Zweryfikowany rezultat: Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F): Design, verify, and deploy reproducible 'Batch Padding, Attention Masks & KV Footprint' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-04 | Moduł techniczny: Custom Tokenizer Training with tokenizers | Praktyk | 50 min | Bezpłatny ($0) | Zweryfikowany rezultat: Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F): Design, verify, and deploy reproducible 'Custom Tokenizer Training with tokenizers' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-05 | Moduł techniczny: Deterministic Decoding: Greedy, Top-p & Repetition Control | Praktyk | 55 min | Bezpłatny ($0) | Zweryfikowany rezultat: Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F): Design, verify, and deploy reproducible 'Deterministic Decoding: Greedy, Top-p & Repetition Control' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-06 | Moduł techniczny: Gradio CPU Chat Demo in Rootless OCI | Praktyk | 60 min | Bezpłatny ($0) | Zweryfikowany rezultat: Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F): Design, verify, and deploy reproducible 'Gradio CPU Chat Demo in Rootless OCI' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-07 | Moduł techniczny: ONNX Runtime & INT8 Dynamic CPU Quantization | Ekspert | 65 min | Bezpłatny ($0) | Zweryfikowany rezultat: Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F): Design, verify, and deploy reproducible 'ONNX Runtime & INT8 Dynamic CPU Quantization' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-08 | Moduł techniczny: Prompt Boundary & Special-Token Injection Hardening | Ekspert | 70 min | Bezpłatny ($0) | Zweryfikowany rezultat: Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F): Design, verify, and deploy reproducible 'Prompt Boundary & Special-Token Injection Hardening' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-09 | Moduł techniczny: SPDX License & Model Card Provenance Audit | Ekspert | 75 min | Bezpłatny ($0) | Zweryfikowany rezultat: Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F): Design, verify, and deploy reproducible 'SPDX License & Model Card Provenance Audit' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-10 | Moduł techniczny: Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus | Zwieńczenie | 45 min | Bezpłatny ($0) | Zweryfikowany rezultat: Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
Tabela żywej semantyki i ujednoznaczniania
| Termin | Domena | Definicja operacyjna |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | Definicja techniczna: Subword compression iteratively merging the most frequent byte/character pairs; governs context cost across scripts. |
| Attention Mask | Architecture | Definicja techniczna: Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | Definicja techniczna: Deterministic serializer mapping system/user/assistant roles into special control tokens; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Definicja techniczna: Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Definicja techniczna: Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Definicja techniczna: Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Definicja techniczna: Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Wykonywalny zestaw laboratoryjny (Bash / Python / OCI — poniżej w kanonicznym formacie LTR)
سلسلة مختبرات Hugging Face المجانية · 10 مختبرات قابلة للتكرار
سلسلة المختبرات المجانية 01: تعليم السيليكون القراءة — النماذج اللغوية والمقطّعات على المعالج المركزي
تحوّل هذه السلسلة المخصصة وحدات Hugging Face Learn والوثائق الرسمية إلى عشرة مختبرات هندسية عملية قابلة للتكرار على نظام Debian 12/13 بالمعالج المركزي (CPU) أو داخل حاوية OCI دون الحاجة إلى CUDA أو اشتراك مدفوع.
بقلم عماد سلطاني (Imad Soltani، المؤلف البشري وصاحب الصلاحية الحصرية لإعلان الإصدارات الإنتاجية) بمشاركة Antigravity (Google DeepMind) كمؤلف غير بشري.
1. بنية السلسلة والعتاد وربطها بمنصة Hugging Face Learn
7. اختبار الفهم الذاتي
لماذا تفرض هذه السلسلة حاوية OCI متعددة المراحل دون صلاحيات root مع نص تهيئة Debian قابل لإعادة التشغيل؟
يزيل البناء متعدد المراحل أدوات الترجمة من طبقة التشغيل، ويحد التشغيل دون صلاحيات الجذر من أثر أي خلل أمني، وتضمن القابلية لإعادة التشغيل نتائج متطابقة عبر أي بيئة Debian 12/13.
كيف يرتبط تقسيم 30/30/30/10 بالجاهزية الإنتاجية؟
ترسي المختبرات 01–03 الأساس الحتمي (مبتدئ)، وتغطي 04–06 التكييف والتقييم المقارن وحزم OCI (ممارس)، وتعالج 07–09 الأداء والأمن والحوكمة (خبير)، ويجمع المختبر 10 النتائج والمصادر الرسمية.
مسار المختبرات العشرة الكامل (30% مبتدئ · 30% ممارس · 30% خبير · 10% مشروع ختامي)
| الرمز | وحدة المختبر المتخصصة | المستوى | المدة | التكلفة / الفئة | النتيجة المتوقعة والقدرة الهندسية |
|---|
LAB-FREE-01-01 | الوحدة التطبيقية: Pipeline Anatomy & Model Cards on CPU | مبتدئ | 35 دقيقة | مجاني ($0) | المخرج المتحقق: Inspect AutoConfig, AutoTokenizer, and pipeline() internals with SmolLM2 on pure CPU Reader capability (10F): Design, verify, and deploy reproducible 'Pipeline Anatomy & Model Cards on CPU' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-02 | الوحدة التطبيقية: Byte-Pair Encoding & WordPiece Deep Dive | مبتدئ | 40 دقيقة | مجاني ($0) | المخرج المتحقق: Compare BPE, WordPiece, and Unigram token fertility across EN/FR/zh/PL/AR scripts Reader capability (10F): Design, verify, and deploy reproducible 'Byte-Pair Encoding & WordPiece Deep Dive' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-03 | الوحدة التطبيقية: Batch Padding, Attention Masks & KV Footprint | مبتدئ | 45 دقيقة | مجاني ($0) | المخرج المتحقق: Measure attention-mask invariants and CPU RAM scaling across context lengths Reader capability (10F): Design, verify, and deploy reproducible 'Batch Padding, Attention Masks & KV Footprint' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-04 | الوحدة التطبيقية: Custom Tokenizer Training with tokenizers | ممارس | 50 دقيقة | مجاني ($0) | المخرج المتحقق: Train a domain-specific BPE tokenizer from scratch and verify lossless round-trip Reader capability (10F): Design, verify, and deploy reproducible 'Custom Tokenizer Training with tokenizers' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-05 | الوحدة التطبيقية: Deterministic Decoding: Greedy, Top-p & Repetition Control | ممارس | 55 دقيقة | مجاني ($0) | المخرج المتحقق: Audit temperature, top-p, and seed determinism under constrained CPU threads Reader capability (10F): Design, verify, and deploy reproducible 'Deterministic Decoding: Greedy, Top-p & Repetition Control' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-06 | الوحدة التطبيقية: Gradio CPU Chat Demo in Rootless OCI | ممارس | 60 دقيقة | مجاني ($0) | المخرج المتحقق: Package a streaming CPU inference demo inside a multi-stage non-root Containerfile Reader capability (10F): Design, verify, and deploy reproducible 'Gradio CPU Chat Demo in Rootless OCI' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-07 | الوحدة التطبيقية: ONNX Runtime & INT8 Dynamic CPU Quantization | خبير | 65 دقيقة | مجاني ($0) | المخرج المتحقق: Benchmark FP32 vs dynamic INT8 CPU throughput and perplexity drift Reader capability (10F): Design, verify, and deploy reproducible 'ONNX Runtime & INT8 Dynamic CPU Quantization' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-08 | الوحدة التطبيقية: Prompt Boundary & Special-Token Injection Hardening | خبير | 70 دقيقة | مجاني ($0) | المخرج المتحقق: Test chat-template escape payloads and enforce strict role-delimiter sanitization Reader capability (10F): Design, verify, and deploy reproducible 'Prompt Boundary & Special-Token Injection Hardening' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-09 | الوحدة التطبيقية: SPDX License & Model Card Provenance Audit | خبير | 75 دقيقة | مجاني ($0) | المخرج المتحقق: Generate machine-readable model cards and EU AI Act Art. 50/53 metadata Reader capability (10F): Design, verify, and deploy reproducible 'SPDX License & Model Card Provenance Audit' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
LAB-FREE-01-10 | الوحدة التطبيقية: Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus | مشروع ختامي | 45 دقيقة | مجاني ($0) | المخرج المتحقق: Consolidate latency logs, tokenizer benchmarks, and LLM Course Ch. 0–9 URLs Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: End-to-End CPU LLM Reference Pack & HF Learn Syllabus' workflows grounded in https://huggingface.co/learn/llm-course and https://huggingface.co/docs/transformers/index. |
جدول الدلالات الحية وإزالة الالتباس
| المصطلح | المجال | التعريف التشغيلي |
|---|
| Byte-Pair Encoding (BPE) | Tokenization | توصيف معياري: Subword compression iteratively merging the most frequent byte/character pairs; governs context cost across scripts. |
| Attention Mask | Architecture | توصيف معياري: Binary tensor masking padded positions so variable-length batches never leak padding noise into softmax weights. |
| Chat Template (Jinja2) | Security | توصيف معياري: Deterministic serializer mapping system/user/assistant roles into special control tokens; misconfiguration enables role spoofing. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | توصيف معياري: Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | توصيف معياري: Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | توصيف معياري: Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | توصيف معياري: Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
حزمة المختبر التنفيذية (Bash / Python / OCI — محفوظة أدناه بصيغة شيفرة قياسية من اليسار إلى اليمين)
Debian 12/13 Commented Idempotent Setup & Domain Python Runner (10C)
setup.sh (Debian 12/13 Bash)
#!/usr/bin/env bash
# ==============================================================================
# SolarisK Lab Series Setup — LAB-FREE-01 (series_01_llm-foundations-transformers)
# Target OS: Latest stable Debian Linux (Debian 12 Bookworm / 13 Trixie)
# Idempotent setup with inline comments & explicit destructive-reset warning.
# ==============================================================================
set -euo pipefail
# Isolated virtual environment path so Debian system Python stays untouched
LAB_VENV="${HOME}/.venvs/solarisk-lab-free-01"
# Warn explicitly before destructive environment reset (--reset)
if [[ "${1:-}" == "--reset" ]]; then
echo "[WARNING] Destructive reset: deleting ${LAB_VENV} in 5s (Ctrl+C to cancel)..."
sleep 5
rm -rf "${LAB_VENV}"
fi
# Confirm Debian python3 & venv tooling exist before creating environment
if ! command -v python3 >/dev/null 2>&1; then
echo "[ERROR] Missing python3. Install on Debian: sudo apt-get update && sudo apt-get install -y python3 python3-venv python3-pip"
exit 1
fi
# CPU-only lab: explicitly skip CUDA/ROCm checks and cap CPU threads for predictable memory
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-4}"
echo "[INFO] CPU-only Debian mode active (OMP_NUM_THREADS=${OMP_NUM_THREADS}; zero CUDA/GPU required)."
# Idempotently create virtual environment
if [[ ! -d "${LAB_VENV}" ]]; then
echo "[SETUP] Creating Debian virtual environment at ${LAB_VENV}..."
python3 -m venv "${LAB_VENV}"
fi
# Install series-specific packages cleanly inside the isolated virtualenv
"${LAB_VENV}/bin/pip" install --quiet --upgrade pip
"${LAB_VENV}/bin/pip" install --quiet transformers tokenizers huggingface_hub safetensors
echo "[READY] Activate: source ${LAB_VENV}/bin/activate"
echo "[READY] Run self-test: ${LAB_VENV}/bin/python3 run_lab.py --check"
run_lab.py (Executable Series-Specific Python Kernel)
#!/usr/bin/env python3
"""
SolarisK Executable Lab Runner — LAB-FREE-01: Free Lab Series 01: Teaching Silicon to Read — Language Models & Tokenizers on CPU
Hugging Face Learn: https://huggingface.co/learn/llm-course
Hugging Face Docs: https://huggingface.co/docs/transformers/index
"""
import argparse, json, os, platform
from datetime import datetime, timezone
def run_domain_demo() -> dict:
"""Series-specific reproducible verification kernel (runs offline or online)."""
out = {"series_id": "LAB-FREE-01", "tier": "FREE", "uses_gpu": False}
try:
# Domain kernel preview (safe offline fallback if optional weights/packages not yet pulled)
exec_ns = {}
code = "from transformers import AutoTokenizer\ntok = AutoTokenizer.from_pretrained('HuggingFaceTB/SmolLM2-135M-Instruct')\nids = tok.encode('Accountable AI begins with verifiable tokenization.')\nprint({'tokens': len(ids), 'decoded': tok.decode(ids)})"
exec(compile(code, "<LAB-FREE-01>", "exec"), exec_ns)
out["kernel_status"] = "EXECUTED"
except Exception as exc:
out["kernel_status"] = "DEFERRED_INSTALL"
out["hint"] = f"Run ./setup.sh first to install [transformers tokenizers huggingface_hub safetensors]: {exc}"
return out
def main() -> None:
parser = argparse.ArgumentParser(description="SolarisK LAB-FREE-01 Reproducible Runner")
parser.add_argument("--check", action="store_true", help="Verify Debian/OCI runtime & run domain kernel")
args = parser.parse_args()
report = {
"series_id": "LAB-FREE-01",
"timestamp_utc": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"python": platform.python_version(),
"os": platform.platform(),
"hf_token_present": bool(os.environ.get("HF_TOKEN")),
"hf_learn": "https://huggingface.co/learn/llm-course",
"hf_docs": "https://huggingface.co/docs/transformers/index",
"domain_check": run_domain_demo(),
}
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)
# syntax=docker/dockerfile:1
# OCI-compliant multi-stage non-root Containerfile for LAB-FREE-01 (opencontainers.org)
FROM python:3.11-slim-bookworm AS builder
WORKDIR /build
RUN python3 -m venv /opt/venv && /opt/venv/bin/pip install --no-cache-dir --upgrade pip transformers tokenizers huggingface_hub safetensors
FROM python:3.11-slim-bookworm AS runtime
LABEL org.opencontainers.image.title="SolarisK LAB-FREE-01" \
org.opencontainers.image.source="https://github.com/ximad/solarisk/tree/main/lab/v126.0/free/series_01_llm-foundations-transformers" \
org.opencontainers.image.authors="Imad Soltani <bsdimad@gmail.com>"
# CPU-only OCI image: zero CUDA/NVIDIA driver dependency
RUN groupadd -g 10001 solarisk && useradd -u 10001 -g 10001 -m -s /usr/sbin/nologin solarisk
COPY --from=builder /opt/venv /opt/venv
WORKDIR /app
COPY --chown=10001:10001 run_lab.py /app/run_lab.py
ENV PATH="/opt/venv/bin:$PATH" HF_HOME="/tmp/hf_cache" PYTHONDONTWRITEBYTECODE=1
USER 10001:10001
ENTRYPOINT ["python3", "/app/run_lab.py"]
CMD ["--check"]
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-01:latest .
docker run --rm --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-free-01:latest
# 2. containerd via nerdctl (rootless OCI workflow)
nerdctl build -f Containerfile -t solarisk/lab-free-01:latest .
nerdctl run --rm --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-free-01:latest
# 3. CRI-O / Podman (Kubernetes CRI-O node verification via crictl / podman)
podman build -f Containerfile -t localhost/solarisk/lab-free-01:latest .
podman run --rm --userns=keep-id -e HF_TOKEN="$HF_TOKEN" localhost/solarisk/lab-free-01:latest
# On CRI-O cluster nodes, pull the OCI image and inspect pod sandbox via: crictl images | grep lab-free-01
Troubleshooting: Two Most Common Errors & Deterministic Fixes (10E)
Error 1: CPU RAM Pressure or Slow Cold Cache LoadCap `OMP_NUM_THREADS=4`, keep `HF_HOME` mounted on persistent disk, and prefer compact SafeTensors checkpoints—zero CUDA or GPU driver configuration is needed.
Error 2: Debian System-Python Conflict or Anonymous Rate Limit (429)Never run global `pip install` on Debian 12/13; execute strictly inside `.venv` (`./setup.sh`) or the non-root OCI container and export a free read-only `HF_TOKEN`.
No comments:
Post a Comment