-
Notifications
You must be signed in to change notification settings - Fork 109
Update the RecLM-cgen, Named RecLM-uni #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request renames RecLM-cgen to RecLM-uni and introduces significant new functionality for RecLM-token support, which uses RQ-VAE to encode items as special token sequences. The PR also adds GRPO training support and a plugin system for reward functions used in title rewrite training.
Changes:
- Renamed RecLM-cgen directory to RecLM-uni and updated references
- Added RecLM-token support with item code mapping and token registration
- Introduced index/ module for RQ-VAE training and codebook generation
- Added GRPO reinforcement learning training capabilities
- Implemented plugin.py with reward functions for title rewrite training
- Updated documentation and added new configuration guides
Reviewed changes
Copilot reviewed 23 out of 47 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| RecLM-uni/trainer.py | Added item code mapping loading for RecLM-token support |
| RecLM-uni/train_utils/utils.py | Added load_item_code_mapping function and ITEM_CODE_FIELD constant |
| RecLM-uni/train_utils/model.py | Added register_item_tokens method for dynamic token registration |
| RecLM-uni/train_utils/dataset.py | Integrated token sequence retrieval in get_item_index |
| RecLM-uni/plugin.py | Reward functions for title rewrite training with performance optimizations |
| RecLM-uni/grpo_train.py | GRPO training implementation for policy optimization |
| RecLM-uni/GRPO/rl_dataset.py | RL dataset builder for GRPO training |
| RecLM-uni/index/* | Complete RQ-VAE module for item encoding to token sequences |
| RecLM-uni/task_test_tokenizer.py | Test script for RecLM-token evaluation |
| RecLM-uni/README.md | Comprehensive documentation for all three methods |
| RecLM-uni/PLUGIN_CONFIG.md | Configuration guide for plugin reward functions |
| RecLM-cgen/README.md | Removed old README (directory renamed) |
| README.md | Updated citation to RecLM-uni |
Comments suppressed due to low confidence (1)
RecLM-uni/trainer.py:61
- There's a trailing whitespace at the end of line 61. This should be removed for code cleanliness.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # --- 全局配置与客户端 --- | ||
| # 建议将这些配置项在顶层统一定义 | ||
| import os |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement for 'os' should be placed with the other imports at the top of the file (lines 1-19), not after the logger initialization. This violates PEP 8 import ordering conventions.
| from datasets import EmbDataset | ||
| from models.rqvae import RQVAE |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'datasets' and 'models.rqvae' imports are relative imports that should specify the package they're relative to, or use absolute imports. In a script file run directly, these relative imports will fail. They should be 'from index.datasets import EmbDataset' and 'from index.models.rqvae import RQVAE', or the script should be run as a module.
| from datasets import EmbDataset | |
| from models.rqvae import RQVAE | |
| from index.datasets import EmbDataset | |
| from index.models.rqvae import RQVAE |
| from datasets import EmbDataset | ||
| from models.rqvae import RQVAE | ||
| from trainer import Trainer |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same import issue: 'datasets', 'models.rqvae', and 'trainer' should use relative imports (from .datasets, from .models.rqvae, from .trainer) since this is within the index package.
| from datasets import EmbDataset | |
| from models.rqvae import RQVAE | |
| from trainer import Trainer | |
| from .datasets import EmbDataset | |
| from .models.rqvae import RQVAE | |
| from .trainer import Trainer |
|
|
||
| ### 4.2. Step 2: Train RQ-VAE Model | ||
|
|
||
| Train the Residual Quantized Variational AutoEncoder(RQ-VAE) to learn item codebook mappings using the `index/` module from RecLM-LC1 or RecLM-cgen: |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation refers to "RecLM-LC1" which appears to be a typo or outdated reference. This should likely be "RecLM-uni" to be consistent with the PR's renaming effort.
| Train the Residual Quantized Variational AutoEncoder(RQ-VAE) to learn item codebook mappings using the `index/` module from RecLM-LC1 or RecLM-cgen: | |
| Train the Residual Quantized Variational AutoEncoder(RQ-VAE) to learn item codebook mappings using the `index/` module from RecLM-uni or RecLM-cgen: |
| time.sleep(50) | ||
| return None |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When all vLLM endpoints fail, the function sleeps for 50 seconds before returning None. This is a very long blocking sleep that could hang the entire application. Consider reducing this timeout or using exponential backoff with a maximum retry limit instead. Additionally, this should probably raise an exception rather than silently returning None after such a long wait.
| time.sleep(50) | |
| return None | |
| raise RuntimeError(f"All vLLM chat endpoints failed for source '{source}'.") |
| @@ -0,0 +1,104 @@ | |||
| import numpy as np | |||
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'np' is not used.
| import numpy as np |
| @@ -0,0 +1,193 @@ | |||
| import argparse | |||
| import copy | |||
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'copy' is not used.
| from train_utils.utils import ( | ||
| save_json, | ||
| get_ctrl_item, | ||
| rm_idx, | ||
| load_json, | ||
| load_pickle, | ||
| side_tokenizer, | ||
| process_train_sample, | ||
| load_item_code_mapping, | ||
| ITEM_CODE_FIELD, | ||
| ) |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'load_pickle' is not used.
| color_set = ["black", "red", "green", "yellow", "blue", "pink", "cyan", "white"] | ||
| try: | ||
| index = color_set.index(color) | ||
| except: |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
| except: | |
| except ValueError: |
| model_init = get_peft_model(base_model, lora_config) | ||
| try: | ||
| model_init.print_trainable_parameters() | ||
| except AttributeError: |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.
| except AttributeError: | |
| except AttributeError: | |
| # Some PEFT models do not implement `print_trainable_parameters`; ignore if unavailable. |
Description
Checklist: