Architecture and Loading
Use this sub-skill when the user asks to load or inspect Baichuan-7B model code, reason about BaiChuanConfig defaults, construct BaiChuanForCausalLM, run a tiny local forward smoke, understand generate()/cache preparation, or debug attention/head shape constraints.
Route here for
- Loading Baichuan-7B or compatible local weights with Hugging Face
AutoTokenizer / AutoModelForCausalLM and trust_remote_code=True.
- Inspecting the local classes
BaiChuanConfig, Model, Attention, DecoderLayer, and BaiChuanForCausalLM.
- Running a safe config-only smoke that needs no official 7B weights, no datasets, and no network.
- Explaining generation preparation:
past_key_values, attention_mask, position_ids, use_cache, and newer Transformers generation warnings.
- Diagnosing invalid
hidden_size / num_attention_heads combinations or direct attention-mask shape errors.
Do not route here for
- C-Eval/MMLU benchmark data, scoring commands, or result files: use sibling
evaluation-workflows.
- DeepSpeed pretraining, corpus shards, tokenizer placement for training, hostfiles, or cluster launch commands: use sibling
pretraining-and-deepspeed.
- General package installation decisions that affect multiple workflows: start at the parent root skill and shared troubleshooting.
Operating map
- For a quick answer, read workflows first.
- For local source verification, run scripts/local_model_smoke.py with
--repo-root /path/to/Baichuan-7B.
- For known failures, read local troubleshooting, then escalate cross-cutting install/backend issues to shared troubleshooting.
- For broader API placement, use the parent Baichuan-7B repo skill and shared API reference.
Minimal safe smoke
python sub-skills/architecture-and-loading/scripts/local_model_smoke.py --repo-root /path/to/Baichuan-7B
Expected coverage: local source import, tiny BaiChuanConfig, eval-mode BaiChuanForCausalLM forward, logits shape (1, 4, 32), finite causal-LM loss, cache-aware prepare_inputs_for_generation, invalid head-divisibility failure, and has_generate reporting.
Add --cuda only when the user explicitly wants a CUDA availability/allocation check; it does not download or run the real 7B model.
1---2name: architecture-and-loading3description: "Operate Baichuan-7B architecture, local source loading, tiny4 synthetic forward checks, Hugging Face inference loading, and generation/cache5 preparation."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/architecture-and-loading9 disco-role: operating10license: Apache 2.011---1213# Architecture and Loading1415Use this sub-skill when the user asks to load or inspect Baichuan-7B model code, reason about `BaiChuanConfig` defaults, construct `BaiChuanForCausalLM`, run a tiny local forward smoke, understand `generate()`/cache preparation, or debug attention/head shape constraints.1617## Route here for1819- Loading Baichuan-7B or compatible local weights with Hugging Face `AutoTokenizer` / `AutoModelForCausalLM` and `trust_remote_code=True`.20- Inspecting the local classes `BaiChuanConfig`, `Model`, `Attention`, `DecoderLayer`, and `BaiChuanForCausalLM`.21- Running a safe config-only smoke that needs no official 7B weights, no datasets, and no network.22- Explaining generation preparation: `past_key_values`, `attention_mask`, `position_ids`, `use_cache`, and newer Transformers generation warnings.23- Diagnosing invalid `hidden_size` / `num_attention_heads` combinations or direct attention-mask shape errors.2425## Do not route here for2627- C-Eval/MMLU benchmark data, scoring commands, or result files: use sibling `evaluation-workflows`.28- DeepSpeed pretraining, corpus shards, tokenizer placement for training, hostfiles, or cluster launch commands: use sibling `pretraining-and-deepspeed`.29- General package installation decisions that affect multiple workflows: start at the parent root skill and shared troubleshooting.3031## Operating map32331. For a quick answer, read [workflows](references/workflows.md) first.342. For local source verification, run [scripts/local_model_smoke.py](scripts/local_model_smoke.py) with `--repo-root /path/to/Baichuan-7B`.353. For known failures, read [local troubleshooting](references/troubleshooting.md), then escalate cross-cutting install/backend issues to [shared troubleshooting](../../references/troubleshooting.md).364. For broader API placement, use the parent [Baichuan-7B repo skill](../../SKILL.md) and shared [API reference](../../references/api-reference.md).3738## Minimal safe smoke3940```bash41python sub-skills/architecture-and-loading/scripts/local_model_smoke.py --repo-root /path/to/Baichuan-7B42```4344Expected coverage: local source import, tiny `BaiChuanConfig`, eval-mode `BaiChuanForCausalLM` forward, logits shape `(1, 4, 32)`, finite causal-LM loss, cache-aware `prepare_inputs_for_generation`, invalid head-divisibility failure, and `has_generate` reporting.4546Add `--cuda` only when the user explicitly wants a CUDA availability/allocation check; it does not download or run the real 7B model.