{"id":31138587,"url":"https://github.com/djo/query-context-aware-learning-to-rank","last_synced_at":"2025-09-18T10:42:37.124Z","repository":{"id":313328996,"uuid":"962712784","full_name":"djo/query-context-aware-learning-to-rank","owner":"djo","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-05T09:18:08.000Z","size":76,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-05T11:24:15.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-08T15:02:46.000Z","updated_at":"2025-09-05T09:18:12.000Z","dependencies_parsed_at":"2025-09-05T11:25:38.886Z","dependency_job_id":"5ddf1138-029d-449f-b4f8-4f5b5d8390b9","html_url":"https://github.com/djo/query-context-aware-learning-to-rank","commit_stats":null,"previous_names":["djo/query-context-aware-learning-to-rank"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/djo/query-context-aware-learning-to-rank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fquery-context-aware-learning-to-rank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fquery-context-aware-learning-to-rank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fquery-context-aware-learning-to-rank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fquery-context-aware-learning-to-rank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djo","download_url":"https://codeload.github.com/djo/query-context-aware-learning-to-rank/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djo%2Fquery-context-aware-learning-to-rank/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275754499,"owners_count":25522748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-18T10:42:35.956Z","updated_at":"2025-09-18T10:42:37.114Z","avatar_url":"https://github.com/djo.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Query Context-Aware Sequential Ranking\n\nThis project, implemented by the authors for the paper [Efficient and Effective Query Context-Aware Learning-to-Rank Model for Sequential Recommendation](https://arxiv.org/abs/2507.03789), provides the implementation and evaluation of a query-context-aware learning-to-rank model for sequential recommendation. The model enhances recommendation accuracy by incorporating the user's target query context into the ranking with the CLM modeling.\n\n## Folder structure\n\n```\n├── datasets/                # Contains preprocessing notebooks\n│   ├── {preprocessing notebooks for Taobao and RetailRocket}\n├── files/                   # Stores processed dataset files\n├── model.py                 # Model definition\n├── train_model.py           # Script for model training\n└── README.md                # Documentation\n```\n\n## Data\n\nThe notebooks in the `datasets` directory contain code to automatically download and preprocess the datasets.\nAfter running these notebooks, the processed training and test data will be saved as Parquet files in the `files` directory.\n\n## Training procedure\n\nThe entry point to start training the model is the `train_model.py`.\n\nParameters:\n\n* `--dataset`: either `taobao` or `retailrocket`, to select the respective dataset\n* `--train_path`: path to the local folder, storing the training datasets\n* `--test_path`: path to the local folder, storing the training datasets\n* `--output_data_path`: path for saving the resulting model artifact\n* `--integration`: one of the following options (default: NO_QUERY_CONTEXT):\n  - `NO_QUERY_CONTEXT` for no query context (the respective input will be ignored, and only the items sequence will be used)\n  - `OUTSIDE` for query context outside the transformer blocks\n  - `IN_INPUT` for implementation where query context is concatenated with the preceding item representation in the input\n  - `LAST_LAYER_AND_OUTSIDE` for query context included in the last layer's query position and outside the transformer blocks\n* `--num_epochs`: number of training epochs (default: 30)\n* `--num_samples`: number of samples to use from dataset; use -1 for all samples (default: -1)\n* `--seq_len`: maximum sequence length for input data (default: 100)\n* `--batch_size`: batch size for training (default: 128)\n* `--past_query_context_in_test`: whether to use past query context information during evaluation (0=only the current context is used, 1=historical context is used as well, default: 0)\n* `--query_context_dropout_rate`: dropout rate for query context information; applicable only for `IN_INPUT` integration type (default: 0.0)\n* `--query_context_dropout_in_train`: whether to apply query context dropout during training; applicable only for `IN_INPUT` integration typ (0=disabled, 1=enabled, default: 0)\n\n\n## Usage\n\nBelow are example commands for training the model with different integration types and options. Replace paths as needed.\n\n**Quick experiment with a small subset:**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration IN_INPUT --num_epochs 2 --num_samples 10000 --batch_size 32\n```\n\n**No query context (NO_QUERY_CONTEXT):**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration NO_QUERY_CONTEXT\n```\n\n**Query context outside transformer blocks (OUTSIDE):**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration OUTSIDE\n```\n\n**Query context concatenated in input (IN_INPUT):**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration IN_INPUT\n```\n\n**IN_INPUT with query context dropout (rate 0.25, enabled during training):**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration IN_INPUT --query_context_dropout_rate 0.25 --query_context_dropout_in_train 1\n```\n\n**IN_INPUT using historical query context during evaluation:**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration IN_INPUT --past_query_context_in_test 1\n```\n\n**Query context in last layer and outside transformer blocks (LAST_LAYER_AND_OUTSIDE):**\n```bash\npython train_model.py --dataset taobao --train_path datasets/files --test_path datasets/files --output_data_path ./model_output --integration LAST_LAYER_AND_OUTSIDE\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Fquery-context-aware-learning-to-rank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjo%2Fquery-context-aware-learning-to-rank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjo%2Fquery-context-aware-learning-to-rank/lists"}