Skip to content
Back to skills

Lightfm

ASecurity

"Operate LightFM recommendation models, data/feature matrices,

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
toolspythonbashapidatabase

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill lightfm --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lightfm?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lightfm
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-lightfm/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-lightfm)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: lightfm
description: "Operate LightFM recommendation models, data/feature matrices,
  evaluation metrics, and repository maintenance workflows."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# LightFM repo skill

Use this skill when a task involves the `lightfm` Python package: building hybrid recommendation inputs, training or scoring `LightFM` models, evaluating ranking metrics, or maintaining the LightFM source checkout.

LightFM is a CPU-only recommender-system package. It implements hybrid matrix-factorization models for implicit and explicit feedback, including `logistic`, `bpr`, `warp`, and `warp-kos` losses. It can combine user/item identity features with side metadata so models can handle cold-start or metadata-aware recommendations when the feature schema is planned correctly.

## Start here

1. Install the package in an isolated Python environment:

   ```bash
   python -m pip install lightfm
   # or, for conda users
   conda install -c conda-forge lightfm
   ```

   For source checkout maintenance, use the [`repo-development`](sub-skills/repo-development/SKILL.md) route instead of the end-user install path.

2. Run a minimal import and CPU smoke check:

   ```bash
   python scripts/check_lightfm_environment.py --tiny-run
   ```

3. Choose the route below based on the user's task. Read the nearest sub-skill before giving detailed commands or API advice.

## Route map

| User task or signal | Read this |
| --- | --- |
| Train a `LightFM` model, choose `warp`/`bpr`/`logistic`, resume with `fit_partial`, predict recommendations, inspect embeddings, handle sample weights, tune regularization, serialize a model, or use optional ANN indexes from representations. | [`sub-skills/model-training/SKILL.md`](sub-skills/model-training/SKILL.md) |
| Convert raw user/item ids, interactions, weights, metadata, or built-in MovieLens/StackExchange data into LightFM sparse matrices and feature mappings; design cold-start user/item features. | [`sub-skills/data-features/SKILL.md`](sub-skills/data-features/SKILL.md) |
| Split interactions, compute `precision_at_k`, `recall_at_k`, `auc_score`, `reciprocal_rank`, use `predict_rank`, preserve user rows, or debug train/test intersection leakage. | [`sub-skills/evaluation-splitting/SKILL.md`](sub-skills/evaluation-splitting/SKILL.md) |
| Work on the LightFM repository itself: editable install, compiled extension/OpenMP/no-OpenMP behavior, Cython regeneration, focused tests, docs, lint, CI, or build failures. | [`sub-skills/repo-development/SKILL.md`](sub-skills/repo-development/SKILL.md) |

## Common package workflow

1. Build or load a SciPy sparse interactions matrix. If raw ids or metadata are involved, use [`data-features`](sub-skills/data-features/SKILL.md) to create stable mappings and feature matrices.
2. Instantiate `LightFM(...)`. Use `loss="warp"` for many implicit top-k tasks, `loss="bpr"` for implicit pairwise ranking/AUC-style objectives, and `loss="logistic"` when explicit positive and negative labels are represented in `interactions.data`.
3. Fit with `model.fit(...)` for a fresh model or `model.fit_partial(...)` for resumed/epoch-by-epoch training. Pass `user_features` and/or `item_features` consistently whenever the model was trained with side features.
4. Score items with `model.predict(user_ids, item_ids, ...)` or rank sparse held-out interactions with `predict_rank`/evaluation utilities.
5. Evaluate with a disjoint train/test split and `train_interactions=train` so known positives are excluded from test rankings.

## Important constraints

- There is no GPU implementation. OpenMP is only CPU multithreading; do not install CUDA packages or promise GPU acceleration for LightFM.
- Feature column schemas are model state. Adding new user/item feature names after training changes the embedding dimensions and normally requires retraining or a deliberate model-resize workflow.
- `Dataset.build_interactions` returns both an interactions matrix and a weights matrix. If using `sample_weight`, the weight COO entries must have the same shape and entry order as the interactions COO matrix.
- Evaluation treats non-zero test entries as positives. Remove negative labels before ranking metrics unless you intentionally evaluate on the training labels.
- Built-in dataset fetchers may download public data. For offline or deterministic checks, use the bundled tiny scripts instead of MovieLens/StackExchange downloads.

## Bundled references and scripts

- [`references/troubleshooting.md`](references/troubleshooting.md): cross-cutting install/import, CPU/OpenMP, dataset download, feature schema, and evaluation leakage guidance.
- [`references/repo-provenance.md`](references/repo-provenance.md): source snapshot and refresh baseline for this generated skill.
- [`scripts/check_lightfm_environment.py`](scripts/check_lightfm_environment.py): package import/version/compiled-extension/tiny-fit diagnostic.

## When not to use this skill

- The task is about a different recommender package such as implicit, Surprise, LensKit, RecBole, Cornac, or a deep-learning recommender framework without LightFM APIs.
- The task is pure database/product ranking design with no `lightfm` package usage.
- The user asks to export this generated repo skill into another agent tool; use the managed repo-skill import/export workflow instead.

Files in this skill

  • SKILL.md5.3 KB
  • references/repo-provenance.md2.2 KB
  • references/repo-routing-metadata.json311 B
  • references/troubleshooting.md4.3 KB
  • scripts/check_lightfm_environment.py6.6 KB
  • sub-skills/data-features/SKILL.md2.9 KB
  • sub-skills/data-features/references/api-reference.md8.3 KB
  • sub-skills/data-features/references/data-formats.md7.3 KB
  • sub-skills/data-features/references/troubleshooting.md6.8 KB
  • sub-skills/data-features/scripts/build_lightfm_dataset.py27.5 KB
  • sub-skills/evaluation-splitting/SKILL.md3.6 KB
  • sub-skills/evaluation-splitting/references/api-reference.md7.9 KB
  • sub-skills/evaluation-splitting/references/troubleshooting.md8 KB
  • sub-skills/evaluation-splitting/references/workflows.md7.5 KB
  • sub-skills/evaluation-splitting/scripts/evaluate_lightfm_fixture.py8.5 KB
  • sub-skills/model-training/SKILL.md4.2 KB
  • sub-skills/model-training/references/api-reference.md9.2 KB
  • sub-skills/model-training/references/troubleshooting.md8.2 KB
  • sub-skills/model-training/references/workflows.md10.8 KB
  • sub-skills/model-training/scripts/tiny_lightfm_smoke.py7.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.