model-training
Train, resume, tune, inspect, serialize, score, and troubleshoot LightFM recommendation models.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-training
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Train, resume, tune, inspect, serialize, score, and troubleshoot LightFM recommendation models.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md9.2 KB
- 参考文档references/troubleshooting.md8.2 KB
- 参考文档references/workflows.md10.8 KB
- 脚本scripts/tiny_lightfm_smoke.py7.2 KB
03 SKILL.md 正文
LightFM model training sub-skill
Use this sub-skill when the task is to train or operate a lightfm.LightFM model: choose a loss, fit or resume training, score items, inspect embeddings, serialize the model, tune regularization or schedules, use sample weights, or export representations for nearest-neighbour retrieval.
Route map
- Use this sub-skill for:
LightFM(...),fit,fit_partial,predict,predict_rankusage notes,get_user_representations,get_item_representations, sample weights,random_state,num_threads, pickling, sklearn-style parameters, and optional ANN indexing from trained embeddings. - Route dataset mappings and feature matrices to:
../data-features/SKILL.md. This includesDataset, raw user/item ids, identity features, metadata features, and feature-shape preparation. - Route metrics and splits to:
../evaluation-splitting/SKILL.md. This includesprecision_at_k,auc_score, train/test split construction, and evaluation leakage checks. This sub-skill only notes when model APIs feed evaluation. - Route build, Cython, OpenMP, and packaging maintenance to:
../repo-development/SKILL.md.
Fast workflow
- Prepare
interactionsas a SciPy sparse user-item matrix. Use../data-features/SKILL.mdif raw ids or feature matrices are involved. - Pick a loss:
warpfor implicit top-k ranking, often a strong default.bprfor implicit ranking/AUC-style objectives and usually faster epochs than WARP.logisticwhen interactions include both positive1and negative-1labels.warp-kosfor k-order statistic WARP experiments; do not combine it withsample_weight.
- Train with
model.fit(...)for a fresh model ormodel.fit_partial(...)to resume from current weights. - Score candidate pairs with
model.predict(user_ids, item_ids, ...); pass repeated user ids when ranking many items for one user. - Inspect/export representations with
get_item_representations(...)andget_user_representations(...); preserve the same feature schema used at training time. - Use
references/workflows.mdfor concrete snippets andscripts/tiny_lightfm_smoke.pyfor a no-network smoke run.
Decision points
- Fresh versus resumed training:
fitresets existing learned state;fit_partialkeeps state and advances training. Usefit_partialfor epoch-by-epoch validation, checkpointing, and warm starts. - Feature shape continuity: when resuming or predicting with side features, the feature matrices must have compatible rows and the same feature-column meaning as training.
- Regularization: if train quality is high but validation quality degrades, try lower
no_components, early stopping, or smallitem_alpha/user_alpha. If learned weights collapse toward zero, regularization may be too strong. - Threads: LightFM is CPU-only.
num_threadsmust be at least1; keep it no larger than physical cores and use1when reproducibility/debugging matters. - ANN retrieval: approximate nearest-neighbour libraries are optional operational add-ons. Build indexes only after extracting trained item/user embeddings; keep exact
predictas the correctness fallback.
References
references/api-reference.md: signatures, parameter tables, returns, and gotchas.references/workflows.md: minimal in-memory, implicit, explicit, tuning, resume, representation, ANN, sample-weight, pickling, and sklearn snippets.references/troubleshooting.md: common exceptions, shape mismatches, NaNs/divergence, WARP speed, popularity collapse, threads, CPU-only, and optional ANN imports.scripts/tiny_lightfm_smoke.py: deterministic local smoke script with no downloads.
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).