The above command will output validation checks performed on the files provided and will output information similar to the following:
17:46:45.790 INFO ai.metarank.config.Config$ - api conf block is not defined: using default ApiConfig(Hostname(localhost),Port(8080))
17:46:45.793INFOai.metarank.config.Config$ -stateconfblockisnotdefined:usingdefaultMemoryStateConfig()17:46:45.798 INFO ai.metarank.config.Config$ - Loaded config file, state=memory, features=[popularity,vote_avg,vote_cnt,budget,release_date,runtime,title_length,genre,ctr,liked_genre,liked_actors,liked_tags,liked_director,visitor_click_count,global_item_click_count,day_item_click_count], models=[xgboost]
17:46:45.874INFOai.metarank.FeatureMapping-optimizedschema:removed6unusedfeatures17:46:46.023INFOai.metarank.main.command.Validate$ -Datasetvalidationisenabled17:46:46.024 INFO ai.metarank.main.command.Validate$ - Validation loads all events to RAM, so use --validation=false to skip in case of OOM
17:46:46.085INFOai.metarank.source.FileEventSource-path=events.jsonl.gzisafile17:46:46.144 INFO ai.metarank.source.FileEventSource - file events.jsonl.gz selected=true (timeMatch=true formatMatch=true)
17:46:46.146INFOai.metarank.source.FileEventSource-readingfileevents.jsonl.gz (with gzipdecompressor)17:46:55.240INFOai.metarank.main.command.Validate$ -Validationdone17:46:55.280INFOa.m.v.checks.EventOrderValidation$ -Eventorderingcheck=PASS (58437 eventssortedbytimestamp)17:46:55.351 INFO a.m.v.checks.EventTypesValidation$ - event types check = PASS (2512 item events, 9800 rankings, 46125 interactions)
17:46:55.441 INFO a.m.v.c.FeatureOverMissingFieldValidation$ - field reference check = PASS (16 features referencing existing 12 event fields)
17:46:55.509 INFO a.m.v.c.InteractionKeyValidation$ - interaction-ranking join key check = PASS (9800 rankings, all interactions reference existing ones)
17:46:55.603 ERROR a.m.v.c.InteractionMetadataValidation$ - Interaction metadata check: FAIL (96 interaction happened on never seen items)
17:46:55.604 ERROR a.m.v.c.InteractionMetadataValidation$ - examples: List(ecc0c55e-8e30-4f7d-8c7e-26f05951300b, 22dda925-8dec-46e0-98d2-bc6a32dcdaec, 40342ea0-1575-417f-8c3d-d3e8dcdfa7f5, 1c0504a5-8e2c-4a0d-be92-b9930df8d041, bb9a79b2-689c-492b-b758-9f1ce0fade09, c2b5d050-3dae-4b24-a7ba-1652d6f4b2e2, 0689b95a-4532-4d05-b87d-e69daed6c910, 5592ff1e-cccd-4157-8c7e-052242c56d0b, d9d1fd91-0629-4623-af2d-1a0682ee62a7, 0d9ef491-ef19-4003-9f20-09d0daea481a)
17:46:55.827 INFO a.m.v.c.InteractionPositionValidation$ - interaction positions check = PASS (int distribution: [2435,2309,2199,2068,2005,2008,1970,2003,1890,1925,1933,1847,1807,1778,1790,1781,1787,1778,1713,1783,1745,1789,1791,1991]
17:46:55.858 INFO a.m.v.c.InteractionTypeValidation$ - interaction type check = PASS (46125 interactions have known types: Set(click))
17:46:55.859INFOai.metarank.main.Main$ -Myjobisdone,exiting.
Historical data sorting
Metarank expects your historical data to be ordered by the timestamp in the ascending order. If for any reason, you cannot generate a sorted file, the sort sub-command can do the job for you.
You can sort both single files and folders with multiple files. In case of folders, sort command will merge all data into one sorted file.
If you don't know what features to include in the configuration file, the autofeature sub-command can generate the configuration for you based on the historical data you have.
if the --model <name> option is not given, then Metarank will train all the defined models sequentially.
While training the model, Metarank will split your data into train/validation datasets with the following supported splitting strategies:
random: shuffle all the training samples and take N% as a training part. May result in an implicit model leakage, when information about the future was leaked in the training set.
An example: on Christmas items with Santa are selling much better (and not selling at all afterwards), and leaking this knowledge into your training set will result in better offline scores (as model knows that Christmas is coming). In production, it will behave significantly worse, as there is no way to predict the future out of the training data anymore.
time: sort all training samples by timestamp and pick first N% as training set (the default option).
hold_last: group all samples by user, and sort per-user samples by timestamp. N% first samples within each user are picked into the training dataset.
Has the same issue with future leaking in the model, but optimizes the train dataset to focus on last user click.
The format of split strategy CLI flag is --strategy name=ratio%. For example:
random with 90% ratio: --split random=90%
random with a default 80% ratio: --split random
Dataset export
Metarank can emit CSV/LibSVM formatted datasets and corresponding config files for LightGBM and XGBoost, so you can later perform a hyper-parameter optimization using your favourite tool:
Metarank export format is dependent on model backend type:
For XGBoost, we export a LibSVM-encoded train/test files with embedded qid. This format is not compatible with the LightGBM LibSVM reader implementation (and we were unable to make it work with both). An example:
for LightGBM, we export a CSV-encoded train/test files with header. XGBoost (as for version 1.70) cannot load query information from CSV files, so it cannot be used for LambdaMART. Example:
For both booster implementations Metarank also emits a corresponding config file with all default values filled in. You can just run the lightgbm/xgboost cli tool externally to replicate what's Metarank is doing.
$> ls-ltotal39740-rw-r--r--1shuttyshutty219Nov213:01lightgbm.conf-rw-r--r--1shuttyshutty6845983Nov213:01test.csv-rw-r--r--1shuttyshutty28453327Nov213:01train.csv$> catlightgbm.confobjective=lambdarankdata=train.csvvalid=test.csvnum_iterations=5learning_rate=0.1seed=0max_depth=8header=truelabel_column=name:labelgroup_column=name:grouplambdarank_truncation_level=10metric=ndcgeval_at=10$> lightgbmconfig=lightgbm.conf[LightGBM] [Info] Warning: last line of lightgbm.conf has no end of line, still using this line[LightGBM] [Warning] Accuracy may be bad since you didn't explicitly set num_leaves OR 2^max_depth > num_leaves. (num_leaves=31).
[LightGBM] [Info] Finished loading parameters[LightGBM] [Info] Using column label as label[LightGBM] [Info] Using column group as group/query id[LightGBM] [Info] Construct bin mappers from text data time 0.14 seconds[LightGBM] [Info] Finished loading data in 0.279901 seconds[LightGBM] [Warning] Auto-choosing row-wise multi-threading, the overhead of testing was 0.020266 seconds.Youcanset`force_row_wise=true`toremovetheoverhead.Andifmemoryisnotenough,youcanset`force_col_wise=true`.[LightGBM] [Info] Total Bins 1837[LightGBM] [Info] Number of data points in the train set: 164232, number of used features: 29[LightGBM] [Info] Finished initializing training[LightGBM] [Info] Started training...[LightGBM] [Info] Iteration:1, valid_1 ndcg@10 : 0.561739[LightGBM] [Info] 0.009204 seconds elapsed, finished iteration 1[LightGBM] [Info] Iteration:2, valid_1 ndcg@10 : 0.572802[LightGBM] [Info] 0.017980 seconds elapsed, finished iteration 2[LightGBM] [Info] Iteration:3, valid_1 ndcg@10 : 0.576812[LightGBM] [Info] 0.032011 seconds elapsed, finished iteration 3[LightGBM] [Info] Iteration:4, valid_1 ndcg@10 : 0.582428[LightGBM] [Info] 0.045455 seconds elapsed, finished iteration 4[LightGBM] [Info] Iteration:5, valid_1 ndcg@10 : 0.582633[LightGBM] [Info] 0.052650 seconds elapsed, finished iteration 5[LightGBM] [Info] Finished training
Metarank supports the same train/test split strategies for export subcommand as for the train one.
BM25 term frequencies dictionary
To use the BM25 score in the field_match, you need to compute a bit of statistics over your textual information.
The same dictionary can be used for multiple field_match extractors, for example when you want to have separate BM25 scores for query-title and query-description matches.
Environment variables
Config file can be passed to the Metarank not only as a command-line argument, but also as an environment variable. This is typically used in docker and k8s-based deployments:
METARANK_CONFIG: path to config file, for example s3://bucket/prefix/config.yml