bert-pytorch
Use BERT-pytorch for corpus preparation, vocabulary building, and tiny BERT pretraining workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- bert-pytorch
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use BERT-pytorch for corpus preparation, vocabulary building, and tiny BERT pretraining workflows.
- disable-model-invocation
- true
02 资源文件 7
- 参考文档references/api-reference.md3.4 KB
- 参考文档references/cli-reference.md3.7 KB
- 参考文档references/repo-provenance.md1.1 KB
- 参考文档references/repo-routing-metadata.json433 B
- 参考文档references/troubleshooting.md3.5 KB
- 脚本scripts/check_install.py4.3 KB
- 脚本scripts/make_tiny_corpus.py1.2 KB
03 SKILL.md 正文
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-pytorchif it is not already available in your Python environment. - Run
python scripts/check_install.pyto 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.txtwhen you need a stable two-line fixture.
Route map
sub-skills/data-preparation/SKILL.md: build or load vocabularies, validate corpus format, inspectBERTDataset, and diagnose pickle or row-format problems.sub-skills/training/SKILL.md: instantiateBERT,BERTLM, andBERTTrainer; 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-vocabandbertare the documented console commands.BERThidden size must be divisible by the number of attention heads.- The
bertCLI parses some boolean flags withtype=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.mdbefore guessing about missing files, malformed rows, or device failures.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).