Skip to content

IndependentScorer batch training, partitioned (Hive) datasets, and fi… - #7

Merged
shankarsankararaman merged 1 commit into
mainfrom
fix/independent-scorer-batch-training
Oct 22, 2026
Merged

shankarsankararaman merged 1 commit into
mainfrom
fix/independent-scorer-batch-training

Conversation

@shankarsankararaman

Copy link
Copy Markdown
Collaborator

IndependentScorer batch training + partitioned (Hive) datasets

IndependentScorer crashed in train() when given a dict of per-item estimators, and couldn't batch-train at all. It now can: each item trains from only its own rows.

  • Item-partitioned data (ITEM_ID=<value>/, e.g. Spark partitionBy): each item reads its own files, with no copy.
  • Other layouts: one pass splits the rows into temporary per-item parquet files under batch_chunk_dir (new constructor / scorer_config option).
  • Same checks as in-memory training: whole-dataset label check, items without interactions dropped, validation columns checked.

Datasets

  • Partitioned directories are listed recursively on local and S3; _temporary-style folders are skipped.
  • Hive key=value/ folders: ITEM_ID is restored as a column; other keys (e.g. month=) are ignored unless the client schema declares them.
  • Fixed reading a single partition file (crashed on S3; returned no columns locally with a schema).

Batch training generally

  • train() no longer loads all interactions/users up front in batch mode.
  • The recommender's outcome-column handling applies to batch reads (GCSL keeps OUTCOME_* as features).
  • recommend() no longer fails when inference input lacks training-time OUTCOME_* columns.

Behaviour changes: undeclared Hive keys are no longer returned by whole-directory reads; local partitioned datasets now include files in subfolders.

Docs updated (capability matrix, scorers, datasets, training, orchestration). Tests: test_independent_batch_training.py, test_hive_partitioning.py (incl. S3 via moto); full suite passes (1253).

…xes found along the way

IndependentScorer crashed in train() when given a dict of per-item
estimators (the coordinator asked the dict for support_batch_training), and
could never batch-train at all. Training dispatch now asks the scorer
(BaseScorer.support_batch_training), and IndependentScorer batch-trains one
estimator per item from only that item's rows:

- Interactions partitioned into ITEM_ID=<value>/ directories are trained
  from directly, with no copy.
- Otherwise one pass over the partitions writes each item's rows to
  buffered temporary parquet chunks under batch_chunk_dir (constructor
  argument or scorer_config; default: system temp directory).
- The binary-label check runs over the whole dataset, items without
  interactions are dropped, and validation columns are checked, matching
  the in-memory path. Mixing batch and in-memory estimators raises.

Datasets:
- Partitioned datasets are listed recursively (local now matches S3);
  _/. directories such as Spark's _temporary are skipped on both.
- Hive key=value/ directories: ITEM_ID is restored as a column; other keys
  (e.g. month=) are ignored unless the client schema declares them.
- Fixed reading a single partition file of a directory dataset (S3 crashed;
  local returned no columns with a client schema).
- Dataset.peek_columns() reads column names from parquet metadata.

Batch training generally:
- train() no longer loads the full interactions/users up front in batch
  mode; retrievers and GCSL load interactions on demand, and GCSL keeps them
  with the model.
- Batch readers apply the recommender's outcome-column handling (dropped by
  default, kept as features by GCSL); users are fetched once per iterator.
- recommend() no longer fails when inference input lacks training-time
  OUTCOME_* columns.
- In-memory retraining of IndependentScorer keeps the binary-label check.

Docs: capability matrix, scorers, datasets, training and orchestration.
@shankarsankararaman
shankarsankararaman marked this pull request as ready for review October 22, 2026 19:13
@shankarsankararaman
shankarsankararaman merged commit 9d11292 into main Oct 22, 2026
6 checks passed
@shankarsankararaman
shankarsankararaman deleted the fix/independent-scorer-batch-training branch October 22, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant