Upload folder using huggingface_hub
Browse filesFiles changed (18)
- .gitattributes+3
- MANIFEST.sha256Added+14
- README.mdAdded+108
- akas_es.jsonAdded
- catalog.sqliteAdded+3
- feature_vocabs.jsonAdded
- full_aux.npzAdded+3
- full_vocab_map.jsonAdded
- item_embeddings.npyAdded+3
- item_embeddings_full.npyAdded+3
- meta.jsonAdded+10
- meta_full.jsonAdded+10
- model_fp32.onnxAdded+3
- model_fp32.onnx.dataAdded+3
- model_full_fp32.onnxAdded+3
- model_full_fp32.onnx.dataAdded+3
- scripts/build_catalog.pyAdded+107
- vocab_map.jsonAdded
32 unmodified lines33343536373832 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textcatalog.sqlite filter=lfs diff=lfs merge=lfs -textmodel_fp32.onnx.data filter=lfs diff=lfs merge=lfs -textmodel_full_fp32.onnx.data filter=lfs diff=lfs merge=lfs -text12345678910111213146499646c6fdf7b6d5d88fd1c7ed0953b65632e2eedec65e9a518b2f30227a823 catalog.sqlite
af32b78680e044cd8f65513005d588e40ec50a212a0d2682e18611f8f97f0734 feature_vocabs.json
86f9c130291b6fb799685961b5b6691f95f81547fded1a917df824746c3f728f full_aux.npz
1940e1f1a495a209222f759c51587a4a6f0b56171de237bbc7bb84c405eb39d2 full_vocab_map.json
8013974fe435247132c5bc448f38c76d0eb9284511a6787b7d0d8fea0b0014ed item_embeddings_full.npy
4e00cdcbe6b633c4cbcc17d7179243bc5c3f106e281498109c7941efe7d06356 item_embeddings.npy
c1a5e720d7f5c77e6580346e77a38d5d74bb30da03d8ae3c835a583d6e7bd2a2 meta_full.json
665e05667124c17d207a819000ac29c08fae534d8f4eae0b734bc5cb015568a6 meta.json
5f605b98d542f94028999689aad4a70601f525b212ba102a7497aee909f24b2b model_fp32.onnx
f5449fa7a58fe2f3dbd3dc4562d51e9ce3299450f69a2903e75aee0615934cf6 model_fp32.onnx.data
a6f98f311a0d50ca20532ab3b15b482362c8f39ceebd149c57342831c62b1c07 model_full_fp32.onnx
6e3bd12e8c6466057d8c3fb09f8b4880a7229d30e4156e993ec310624ea4587f model_full_fp32.onnx.data
65df51b90355b7ea9af878ce6aed16a9a6fcdbe98f12bde71b4189aac3e58e53 vocab_map.json
445db02f9855f26ef4672089bce54ab74141c587306b635ad8a5e0fa961b73d5 scripts/build_catalog.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108---license: cc-by-nc-sa-4.0tags: - recommendation - sequential-recommendation - movies - series - gsasrec - onnxlanguage: - en - eslibrary_name: onnxruntimepipeline_tag: other---
# FrameLanguageLM
A language model where tokens are movies and TV series — trained on 32M viewing sequences to predict "the next film you'd love."
## Model Description
- **Architecture:** gSASRec (2-layer transformer, d=256, gBCE loss) with compositional embeddings- **Vocabulary:** ~100k titles (movies + TV series) selected by IMDb numVotes- **Training data:** MovieLens 32M sequences, enriched with IMDb/TMDB metadata- **Cold-start:** ID-dropout (p=0.2) enables recommendation of unseen titles via metadata-only embeddings- **Dual serving:** warm checkpoint (54k items with collaborative signal) + full checkpoint (100k including cold items)
## Performance
| Metric | Warm (feat) | Full (feat_iddrop) ||--------|:-----------:|:------------------:|| TEST NDCG@10 | 0.1174 | 0.1110 || TEST Recall@10 | 0.2164 | 0.2066 || TEST Recall@50 | 0.4630 | 0.4511 || Cold-start NDCG@10 | — | 0.0846 (63.7% of warm) |
Full ranking evaluation (no candidate sampling), leave-one-out temporal split. Total training cost: ~$1.25 (RTX 3090).
## How to Use
```bash# Install the CLIpip install frame-language-lm
# Import your FilmAffinity profile (auto-downloads model on first run)frame-language-lm import --filmaffinity export.zip
# Get your gaps — movies you'd love but haven't seenframe-language-lm gaps --top 50
# Check if a specific title is worth watching for youframe-language-lm worth "Stalker"
# Find similar titlesframe-language-lm similar "Mulholland Drive"
# Search the catalog with filtersframe-language-lm search --director "Park Chan-wook" --country KR```
## Files in this Repository
| File | Size | Description ||------|------|-------------|| `model_fp32.onnx` + `.data` | ~56 MB | Warm checkpoint (54k items with signal) || `model_full_fp32.onnx` + `.data` | ~101 MB | Full checkpoint (100k items, ID-dropout) || `item_embeddings.npy` | ~53 MB | Warm item embedding matrix || `item_embeddings_full.npy` | ~98 MB | Full item embedding matrix || `full_aux.npz` | ~0.2 MB | Cold-start flags (is_cold, is_movie, etc.) || `catalog.sqlite` | ~36 MB | Complete catalog with metadata || `vocab_map.json` | ~1 MB | Warm vocabulary mapping (tconst ↔ index) || `full_vocab_map.json` | ~2 MB | Full vocabulary mapping || `feature_vocabs.json` | ~2.4 MB | Compositional feature vocabularies || `meta.json` / `meta_full.json` | <1 KB each | Model configuration |
## Training Data & Licenses
- **MovieLens 32M:** F. Maxwell Harper and Joseph A. Konstan. 2015. *The MovieLens Datasets: History and Context.* ACM Transactions on Interactive Intelligent Systems (TiiS) 5, 4, Article 19. Non-commercial use; redistribution of transformations under same conditions.- **IMDb Non-Commercial Datasets:** Personal and non-commercial use only. [developer.imdb.com](https://developer.imdb.com/non-commercial-datasets/)- **TMDB API:** Metadata enrichment (country, language, budget). This product uses the TMDB API but is not endorsed, certified, or otherwise approved by TMDB.
## Limitations
- Trained on MovieLens (predominantly US/English mainstream cinema) — recommendations biased toward popular Western titles- MovieLens ends Oct 2023 — post-2023 titles are cold-start only- Series recommendations are metadata-based (no collaborative signal) — lower quality than films- Budget feature: only 20-40% coverage in TMDB
## Ethical Considerations
- No user data is collected or transmitted — all inference runs locally- Model cannot recover individual user viewing histories from training data- Recommendations reflect statistical patterns in viewing behavior, not quality judgments
## Data Provenance & Takedown
This model was trained on publicly available, non-commercial datasets:
| Source | Data used | License | How to verify ||--------|-----------|---------|---------------|| MovieLens 32M | User viewing sequences | Custom (non-commercial, redistribution OK) | [grouplens.org](https://grouplens.org/datasets/movielens/32m/) || IMDb Non-Commercial | Titles, genres, directors, cast, year | Custom (personal/non-commercial) | [developer.imdb.com](https://developer.imdb.com/non-commercial-datasets/) || TMDB API | Country, language, budget (compositional features) | TMDB API ToS | [themoviedb.org](https://www.themoviedb.org/) |
For convenience, this repository includes a pre-built catalog (`catalog.sqlite`) containing metadata derived from IMDb and TMDB. If any rights holder objects to the inclusion of this catalog, it will be removed and users can rebuild it locally using the provided `scripts/build_catalog.py` script. Model weights are a mathematical transformation that cannot reconstruct the original training data.
**Takedown requests:** if you are a rights holder and believe any artifact in this repository infringes on your terms, please contact peportmel@gmail.com. We will respond within 72 hours and can remove the affected artifact or retrain the model excluding your data source at negligible cost (~$0.30, ~90 minutes of GPU time).123version https://git-lfs.github.com/spec/v1oid sha256:6499646c6fdf7b6d5d88fd1c7ed0953b65632e2eedec65e9a518b2f30227a823size 37548032123version https://git-lfs.github.com/spec/v1oid sha256:86f9c130291b6fb799685961b5b6691f95f81547fded1a917df824746c3f728fsize 208120123version https://git-lfs.github.com/spec/v1oid sha256:4e00cdcbe6b633c4cbcc17d7179243bc5c3f106e281498109c7941efe7d06356size 55351424123version https://git-lfs.github.com/spec/v1oid sha256:8013974fe435247132c5bc448f38c76d0eb9284511a6787b7d0d8fea0b0014edsize 10240115212345678910{
"checkpoint": "sasrec_feat.pt",
"checkpoint_epoch": 50,
"valid_ndcg@10": 0.13018137636965726,
"vocab_md5": "97774e35046472f8340a1b0bb4c751da",
"vocab_md5_actual": "97774e35046472f8340a1b0bb4c751da",
"n_items": 54053,
"d": 256,
"max_len": 200
}12345678910{
"checkpoint": "sasrec_feat_iddrop.pt",
"checkpoint_epoch": 39,
"valid_ndcg@10": 0.12276953213630627,
"vocab_md5": "97774e35046472f8340a1b0bb4c751da",
"vocab_md5_actual": "97774e35046472f8340a1b0bb4c751da",
"n_items": 54053,
"d": 256,
"max_len": 200
}123version https://git-lfs.github.com/spec/v1oid sha256:5f605b98d542f94028999689aad4a70601f525b212ba102a7497aee909f24b2bsize 22808123version https://git-lfs.github.com/spec/v1oid sha256:f5449fa7a58fe2f3dbd3dc4562d51e9ce3299450f69a2903e75aee0615934cf6size 59086848123version https://git-lfs.github.com/spec/v1oid sha256:a6f98f311a0d50ca20532ab3b15b482362c8f39ceebd149c57342831c62b1c07size 22969123version https://git-lfs.github.com/spec/v1oid sha256:6e3bd12e8c6466057d8c3fb09f8b4880a7229d30e4156e993ec310624ea4587fsize 106136576123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107"""Fase 1.4: ensambla el catalogo final y las secuencias de entrenamiento.
Uso: uv run python scripts/build_catalog.pyEntrada: data/interim/vocab.parquet + data/interim/tmdb.jsonl + data/raw/ml-32m/Salida: data/catalog.sqlite + data/sequences.parquet"""
import jsonimport sqlite3import sysfrom pathlib import Path
import duckdb
ROOT = Path(__file__).resolve().parent.parentINTERIM = ROOT / "data" / "interim"RAW = ROOT / "data" / "raw"MIN_TMDB_COVERAGE = 0.80
vocab = duckdb.sql( f"SELECT * FROM read_parquet('{(INTERIM / 'vocab.parquet').as_posix()}') ORDER BY numVotes DESC").fetchall()cols = [ "tconst", "titleType", "primaryTitle", "originalTitle", "startYear", "runtimeMinutes", "genres", "averageRating", "numVotes", "directors", "cast", "tmdb_id_links",]
tmdb: dict[str, dict] = {}tmdb_path = INTERIM / "tmdb.jsonl"if tmdb_path.exists(): with tmdb_path.open(encoding="utf-8") as f: for line in f: if line.strip(): rec = json.loads(line) if "error" not in rec: tmdb[rec["tconst"]] = rec
coverage = len([1 for row in vocab if row[0] in tmdb]) / len(vocab)if coverage < MIN_TMDB_COVERAGE: sys.exit( f"cobertura TMDB insuficiente: {coverage:.1%} del vocabulario " f"(minimo {MIN_TMDB_COVERAGE:.0%}). Lanza scripts/fetch_tmdb.py hasta completar." )
db_path = ROOT / "data" / "catalog.sqlite"db_path.unlink(missing_ok=True)db = sqlite3.connect(db_path)db.execute(""" CREATE TABLE items ( tconst TEXT PRIMARY KEY, title_type TEXT NOT NULL, primary_title TEXT NOT NULL, original_title TEXT, start_year INTEGER, runtime_minutes INTEGER, genres TEXT, imdb_rating REAL, num_votes INTEGER NOT NULL, directors TEXT, "cast" TEXT, tmdb_id INTEGER, media_type TEXT, original_language TEXT, countries TEXT, budget INTEGER, keywords TEXT, poster_path TEXT, popularity REAL )""")
rows = []for row in vocab: r = dict(zip(cols, row)) t = tmdb.get(r["tconst"], {}) rows.append(( r["tconst"], r["titleType"], r["primaryTitle"], r["originalTitle"], r["startYear"], r["runtimeMinutes"], r["genres"], r["averageRating"], r["numVotes"], r["directors"], r["cast"], t.get("tmdb_id"), t.get("media_type"), t.get("original_language"), "|".join(t.get("production_countries") or []) or None, t.get("budget") or None, "|".join(t.get("keywords") or []) or None, t.get("poster_path"), t.get("popularity"), ))db.executemany(f"INSERT INTO items VALUES ({','.join('?' * 19)})", rows)db.execute("CREATE INDEX idx_items_title ON items (primary_title)")db.commit()db.close()print(f"catalog.sqlite: {len(rows):,} items (cobertura TMDB {coverage:.1%})")
seq_out = ROOT / "data" / "sequences.parquet"duckdb.sql(f""" COPY ( SELECT m.userId, v.tconst, m.rating, m.timestamp FROM read_csv_auto('{(RAW / "ml-32m" / "ratings.csv").as_posix()}') m JOIN read_csv_auto('{(RAW / "ml-32m" / "links.csv").as_posix()}') l USING (movieId) JOIN read_parquet('{(INTERIM / "vocab.parquet").as_posix()}') v ON v.tconst = printf('tt%07d', CAST(l.imdbId AS BIGINT)) ORDER BY m.userId, m.timestamp ) TO '{seq_out.as_posix()}' (FORMAT PARQUET)""")n, users = duckdb.sql( f"SELECT count(*), count(DISTINCT userId) FROM read_parquet('{seq_out.as_posix()}')").fetchone()print(f"sequences.parquet: {n:,} interacciones de {users:,} usuarios").gitattributes+3
MANIFEST.sha256Added+14
README.mdAdded+108
akas_es.jsonAdded
catalog.sqliteAdded+3
feature_vocabs.jsonAdded
full_aux.npzAdded+3
full_vocab_map.jsonAdded
item_embeddings.npyAdded+3
item_embeddings_full.npyAdded+3
meta.jsonAdded+10
meta_full.jsonAdded+10
model_fp32.onnxAdded+3
model_fp32.onnx.dataAdded+3
model_full_fp32.onnxAdded+3
model_full_fp32.onnx.dataAdded+3
scripts/build_catalog.pyAdded+107
vocab_map.jsonAdded