bert-pytorch
Use this skill when the user mentions BERT-pytorch, bert, bert-vocab, WordVocab, BERTDataset, BERT, BERTLM, or BERTTrainer.
Quick start
- Install the package with
python -m pip install bert-pytorch if it is not already available in your Python environment.
- Run
python scripts/check_install.py to confirm the package import, public exports, and console commands.
- If the task is about corpus layout, vocabulary files, or dataset rows, go to
sub-skills/data-preparation/SKILL.md.
- If the task is about model construction, training, device choice, or checkpoints, go to
sub-skills/training/SKILL.md.
- Use
python scripts/make_tiny_corpus.py --output /tmp/bert-pytorch-corpus.txt when you need a stable two-line fixture.
Route map
sub-skills/data-preparation/SKILL.md: build or load vocabularies, validate corpus format, inspect BERTDataset, and diagnose pickle or row-format problems.
sub-skills/training/SKILL.md: instantiate BERT, BERTLM, and BERTTrainer; train on a tiny corpus/vocab pair; pick CPU or CUDA; and save checkpoints.
Shared facts
- The corpus format is two sentences per line separated by a tab.
- Tokenization happens before the package; BERT-pytorch does not tokenize raw text for you.
bert-vocab and bert are the documented console commands.
BERT hidden size must be divisible by the number of attention heads.
- The
bert CLI parses some boolean flags with type=bool; use the bundled smoke scripts or the Python API when you need an explicit CPU run or streaming mode.
Shared references
references/repo-provenance.md: source commit, package version, and evidence snapshot.
references/repo-routing-metadata.json: router metadata for managed import.
references/api-reference.md: public classes, functions, and object relationships.
references/cli-reference.md: command names, flags, defaults, and safety notes.
references/troubleshooting.md: cross-cutting install, import, CLI, corpus, and device issues.
Shared scripts
scripts/check_install.py: verify imports, API exports, and CLI help.
scripts/make_tiny_corpus.py: create a deterministic two-line corpus fixture.
When in doubt
- Start with the sub-skill that matches the first concrete noun in the request: corpus/vocab/data rows -> data preparation; model/training/checkpoint/device -> training.
- If the task mixes both, build the vocabulary first, then move to training.
- Read
references/troubleshooting.md before guessing about missing files, malformed rows, or device failures.
1---2name: bert-pytorch3description: "Use BERT-pytorch for corpus preparation, vocabulary building, and4 tiny BERT pretraining workflows."5disable-model-invocation: true6metadata:7 source: https://skillmd.com/skills/vectorspacelab/bert-pytorch8 disco-role: operating9license: Apache 2.010---1112# bert-pytorch1314Use this skill when the user mentions BERT-pytorch, `bert`, `bert-vocab`, `WordVocab`, `BERTDataset`, `BERT`, `BERTLM`, or `BERTTrainer`.1516## Quick start17181. Install the package with `python -m pip install bert-pytorch` if it is not already available in your Python environment.192. Run `python scripts/check_install.py` to confirm the package import, public exports, and console commands.203. If the task is about corpus layout, vocabulary files, or dataset rows, go to `sub-skills/data-preparation/SKILL.md`.214. If the task is about model construction, training, device choice, or checkpoints, go to `sub-skills/training/SKILL.md`.225. Use `python scripts/make_tiny_corpus.py --output /tmp/bert-pytorch-corpus.txt` when you need a stable two-line fixture.2324## Route map2526- `sub-skills/data-preparation/SKILL.md`: build or load vocabularies, validate corpus format, inspect `BERTDataset`, and diagnose pickle or row-format problems.27- `sub-skills/training/SKILL.md`: instantiate `BERT`, `BERTLM`, and `BERTTrainer`; train on a tiny corpus/vocab pair; pick CPU or CUDA; and save checkpoints.2829## Shared facts3031- The corpus format is two sentences per line separated by a tab.32- Tokenization happens before the package; BERT-pytorch does not tokenize raw text for you.33- `bert-vocab` and `bert` are the documented console commands.34- `BERT` hidden size must be divisible by the number of attention heads.35- The `bert` CLI parses some boolean flags with `type=bool`; use the bundled smoke scripts or the Python API when you need an explicit CPU run or streaming mode.3637## Shared references3839- `references/repo-provenance.md`: source commit, package version, and evidence snapshot.40- `references/repo-routing-metadata.json`: router metadata for managed import.41- `references/api-reference.md`: public classes, functions, and object relationships.42- `references/cli-reference.md`: command names, flags, defaults, and safety notes.43- `references/troubleshooting.md`: cross-cutting install, import, CLI, corpus, and device issues.4445## Shared scripts4647- `scripts/check_install.py`: verify imports, API exports, and CLI help.48- `scripts/make_tiny_corpus.py`: create a deterministic two-line corpus fixture.4950## When in doubt5152- Start with the sub-skill that matches the first concrete noun in the request: corpus/vocab/data rows -> data preparation; model/training/checkpoint/device -> training.53- If the task mixes both, build the vocabulary first, then move to training.54- Read `references/troubleshooting.md` before guessing about missing files, malformed rows, or device failures.