squad-qa
Operate XLNet SQuAD 1.1/2.0 preprocessing, fine-tuning, prediction, and threshold evaluation workflows through run_squad.py.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- squad-qa
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Operate XLNet SQuAD 1.1/2.0 preprocessing, fine-tuning, prediction, and threshold evaluation workflows through run_squad.py.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/cli-reference.md7.8 KB
- 参考文档references/data-formats.md6.4 KB
- 参考文档references/troubleshooting.md6.9 KB
- 参考文档references/workflows.md7.8 KB
- 脚本scripts/build_squad_command.py15.6 KB
03 SKILL.md 正文
XLNet SQuAD QA operating sub-skill
Use this sub-skill when the task is span-extraction question answering with XLNet through run_squad.py: SQuAD JSON preprocessing, SQuAD 1.1/2.0 fine-tuning, prediction, prediction-cache management, n-best span decoding, or SQuAD 2.0 no-answer threshold evaluation.
Route elsewhere
- RACE or other four-choice reading-comprehension tasks ->
race-reading-comprehension. - GLUE, IMDB, Yelp, or general classification/regression ->
classification. - Direct graph/API changes, custom losses, or checkpoint internals ->
model-api.
Minimal inputs to collect
- XLNet runtime with legacy TensorFlow 1.x, SentencePiece, and
run_squad.pyavailable. - Model artifacts:
xlnet_config.json,spiece.model, and a checkpoint for training (--init_checkpoint) or a fine-tuned checkpoint under--model_dirfor prediction-only. - SQuAD-style JSON: training JSON for preprocessing/fine-tuning and prediction JSON for dev/test prediction.
- Separate directories for feature cache (
--output_dir), fine-tuned checkpoints (--model_dir), and prediction JSON outputs (--predict_dir). - Backend choice: GPU base fallback, Cloud TPU large recipe, or prediction-only.
Operating flow
- Confirm the data shape in data-formats.md. For training, each QA must include
is_impossible; SQuAD 1.1 data usually needs this field added withfalse. - Generate a command with scripts/build_squad_command.py. The builder prints commands only and never executes them.
- Run preprocessing first when training:
--do_prepro=Truewrites training TFRecords into--output_dir. Use--num_proc/--proc_idor the builder's--emit-all-proc-idsfor parallel preprocessing. - Run GPU or TPU fine-tuning/evaluation, or
predict-onlyagainst a fine-tuned--model_dir. Prediction creates or reuses eval TFRecord/feature cache in--output_dirand writespredictions.json,nbest_predictions.json, andnull_odds.jsonin--predict_dir. - Read the logged SQuAD metrics.
run_squad.pycomputes best SQuAD 2.0 thresholds fromnull_odds.jsonand reports keys such asbest_exact,best_f1,best_*_thresh,has_ans_exact, andhas_ans_f1.
Quick command-builder examples
Preprocess one SQuAD training split:
python sub-skills/squad-qa/scripts/build_squad_command.py \
--mode prepro \
--spiece-model-file xlnet_cased/spiece.model \
--train-file data/squad/train-v2.0.json \
--output-dir proc_data/squad
Generate the GPU base training/prediction recipe:
python sub-skills/squad-qa/scripts/build_squad_command.py \
--mode gpu-base \
--model-config-path xlnet_cased_base/xlnet_config.json \
--spiece-model-file xlnet_cased_base/spiece.model \
--init-checkpoint xlnet_cased_base/xlnet_model.ckpt \
--output-dir proc_data/squad \
--model-dir experiment/squad_base \
--train-file data/squad/train-v2.0.json \
--predict-file data/squad/dev-v2.0.json \
--predict-dir predictions/squad_base
Generate a TPU large recipe when TPU and GCS are available:
python sub-skills/squad-qa/scripts/build_squad_command.py \
--mode tpu-large \
--tpu my-tpu \
--model-config-path xlnet_cased_large/xlnet_config.json \
--spiece-model-file xlnet_cased_large/spiece.model \
--init-checkpoint gs://bucket/xlnet_cased_large/xlnet_model.ckpt \
--output-dir gs://bucket/proc_data/squad \
--model-dir gs://bucket/experiment/squad_large \
--train-file data/squad/train-v2.0.json \
--predict-file data/squad/dev-v2.0.json \
--predict-dir gs://bucket/predictions/squad_large
For detailed recipes, CLI flags, and failure recovery, use:
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).