Conversation
Increases LoRA rank from 4 to 16 in example and default configurations. This aims to improve model fine-tuning effectiveness. Adjusts per-device batch size and gradient accumulation steps. This maintains the same effective batch size while potentially reducing memory usage. Standardizes LoRA dropout to 0.25 across configurations. Updates READMEs to clarify model performance expectations.
Ensures the ID field for generated QA items is always a string. This provides type consistency for downstream consumers.
Ensures a specific PII test data file is tracked by Git, enabling its use in related tests.
Updates pre-commit hooks. Previously, the cleaning pipeline was entirely disabled for datasets containing image messages. Image conversations now receive a default score, bypassing text-focused LLM cleaning. This enables partial cleaning for mixed datasets and prevents pipeline failures.
Reduces the default LoRA rank in training configuration templates from 16 to 8. This change aims to optimize resource usage and potentially accelerate training.
Introduces a new 'enable_thinking' configuration for LLM interactions. This allows dynamic control of thinking behavior in both offline inference and the data cleaning process. When thinking is enabled for cleaning, the maximum number of new tokens is increased to accommodate longer reasoning outputs. Also reduces the repetition penalty in the cleaning strategy for improved response diversity and skips data entries containing images during the LLM cleaning process to avoid irrelevant processing.
Ensures that files with a .gif extension are correctly identified and categorized as animated expressions or stickers based on the platform. This improves the accuracy of media type classification during data processing.
Updates the Qwen3 model in test configurations from 4B to the smaller 0.6B version. This change helps improve test performance and reduce resource requirements.
Upgrades openai, vllm, torch, transformers, and triton to their latest versions. This ensures compatibility, incorporates recent bug fixes, and leverages performance improvements across the project.
This release introduces the ability to control the offline cleaning process through the `enable_thinking` configuration parameter.
Refactors dataset management to consistently append '-vl' for vision-language datasets and dynamically name cleaned datasets (e.g., 'dataset-cleaned'). Enforces vLLM as a strict dependency for LLM-based data cleaning, exiting if unavailable. Integrates 'enable_thinking' option for LLM cleaning and enables cleaning by default in relevant test configurations. Adds torchvision dependency for vision models and streamlines the cleaning call in training to centralize decision-making.
审阅者指南此 PR 通过添加图像模态支持和可配置的 LLM 推理,改进了数据清洗和推理工作流;重构了配置模型,以实现动态数据集命名和后处理;提升了项目和依赖版本;增强了 QA 解析;简化了训练入口点;更新了 pre-commit 钩子;并完善了文档。 支持图像模态和
|
| 更改 | 详情 | 文件 |
|---|---|---|
| 增强清洗策略以处理基于图像的 QA 和可配置的 LLM 推理 |
|
weclone/data/clean/strategies.pyweclone/core/inference/offline_infer.py |
| 重构配置模型以支持可选适配器和动态数据集命名 |
|
weclone/utils/config_models.pyweclone/utils/config.py |
| 提升项目版本并更新依赖 |
|
pyproject.toml |
| 改进 QA 生成器数据处理和错误路径 |
|
weclone/data/qa_generator.py |
| 简化训练入口点以始终应用清洗 |
|
weclone/train/train_sft.py |
| 更新 pre-commit 钩子版本 |
|
.pre-commit-config.yaml |
| 重新措辞文档以提高清晰度 |
|
README.mdREADME_zh.md |
可能关联的问题
- #0: 此 PR 更新了数据清洗逻辑、数据集命名和相关依赖,直接解决了该问题的数据预处理失败。
提示和命令
与 Sourcery 互动
- 触发新审查: 在拉取请求上评论
@sourcery-ai review。 - 继续讨论: 直接回复 Sourcery 的审查评论。
- 从审查评论生成 GitHub Issue: 通过回复 Sourcery 的审查评论,要求其从评论中创建 Issue。您也可以回复审查评论并输入
@sourcery-ai issue来创建 Issue。 - 生成拉取请求标题: 在拉取请求标题中的任意位置写入
@sourcery-ai,即可随时生成标题。您也可以在拉取请求上评论@sourcery-ai title来随时(重新)生成标题。 - 生成拉取请求摘要: 在拉取请求正文的任意位置写入
@sourcery-ai summary,即可随时在您想要的位置生成 PR 摘要。您也可以在拉取请求上评论@sourcery-ai summary来随时(重新)生成摘要。 - 生成审阅者指南: 在拉取请求上评论
@sourcery-ai guide,即可随时(重新)生成审阅者指南。 - 解决所有 Sourcery 评论: 在拉取请求上评论
@sourcery-ai resolve,以解决所有 Sourcery 评论。如果您已处理所有评论且不想再看到它们,这会很有用。 - 驳回所有 Sourcery 审查: 在拉取请求上评论
@sourcery-ai dismiss,以驳回所有现有 Sourcery 审查。如果您想从头开始进行新的审查,这尤其有用——别忘了评论@sourcery-ai review来触发新的审查!
自定义您的体验
访问您的 仪表板 以:
- 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
- 更改审查语言。
- 添加、删除或编辑自定义审查说明。
- 调整其他审查设置。
获取帮助
Original review guide in English
Reviewer's Guide
This PR refines the data cleaning and inference workflows by adding image‐modality support and configurable LLM reasoning, restructures config models for dynamic dataset naming and post‐processing, bumps project and dependency versions, enhances QA parsing, simplifies the training entry point, updates pre‐commit hooks, and polishes documentation.
Sequence diagram for LLM cleaning with image-modality support and enable_thinking
sequenceDiagram
participant TrainSft as train_sft.py
participant Cleaner as LLMCleaningStrategy
participant Infer as vllm_infer
TrainSft->>Cleaner: clean()
Cleaner->>Infer: vllm_infer(inputs, enable_thinking)
Infer-->>Cleaner: parsed_scores, failed_indexs
Cleaner-->>TrainSft: cleaned_dataset_name
ER diagram for updated dataset naming and image-modality flag
erDiagram
WCTrainSftConfig {
string dataset
string output_dir
}
WCMakeDatasetConfig {
string dataset
}
WCTrainSftConfig ||--o{ CleanDatasetConfig : has
CleanDatasetConfig {
bool enable_clean
string clean_strategy
LLMCleanConfig llm
}
LLMCleanConfig {
int accept_score
bool enable_thinking
}
Class diagram for updated config models with dynamic dataset naming
classDiagram
class CommonMethods {
+_parse_dataset_name() str
}
class WCTrainSftConfig {
+output_dir: Optional[str]
+dataset: str
+process_config()
}
class WCMakeDatasetConfig {
+process_config()
+dataset: str
}
CommonMethods <|.. WCTrainSftConfig
CommonMethods <|.. WCMakeDatasetConfig
WCTrainSftConfig --|> CommonArgs
WCTrainSftConfig --|> TrainSftArgs
WCMakeDatasetConfig --|> CommonArgs
WCMakeDatasetConfig --|> MakeDatasetArgs
class LLMCleanConfig {
+accept_score: int
+enable_thinking: bool
}
class CleanDatasetConfig {
+enable_clean: bool
+clean_strategy: CleanStrategy
+llm: LLMCleanConfig
}
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Enhanced cleaning strategy to handle image-based QA and configurable LLM reasoning |
|
weclone/data/clean/strategies.pyweclone/core/inference/offline_infer.py |
| Refactored config models for optional adapters and dynamic dataset naming |
|
weclone/utils/config_models.pyweclone/utils/config.py |
| Bumped project version and updated dependencies |
|
pyproject.toml |
| Improved QA generator data handling and error paths |
|
weclone/data/qa_generator.py |
| Simplified training entry point to always apply cleaning |
|
weclone/train/train_sft.py |
| Updated pre-commit hook versions |
|
.pre-commit-config.yaml |
| Rephrased documentation for clarity |
|
README.mdREADME_zh.md |
Possibly linked issues
- #0: The PR updates data cleaning logic, dataset naming, and related dependencies, which directly address the issue's data preprocessing failure.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
There was a problem hiding this comment.
你好 - 我已审阅你的更改 - 以下是一些反馈意见:
- 在
judge方法中,跳过基于图像的问答对而不调整输入到输出的索引映射,可能会导致 vLLM 推理结果和分数错位——请考虑保留占位符输入或重新映射索引以保持解析分数同步。 train_sft.main的清理步骤现在无条件地运行清理器,即使enable_clean为 false 或包含图像模态;如果这不是故意的,请重新引入防护或记录行为更改。- 新的
CommonMethods._parse_dataset_name和adapter_name_or_path以及include_type的动态移除似乎在配置类中重复——请考虑整合此逻辑,以避免 output_dir/数据集初始化中的不一致。
AI 代理提示
请解决此代码审查中的评论:
## 总体评论
- 在 `judge` 方法中,跳过基于图像的问答对而不调整输入到输出的索引映射,可能会导致 vLLM 推理结果和分数错位——请考虑保留占位符输入或重新映射索引以保持解析分数同步。
- `train_sft.main` 的清理步骤现在无条件地运行清理器,即使 `enable_clean` 为 false 或包含图像模态;如果这不是故意的,请重新引入防护或记录行为更改。
- 新的 `CommonMethods._parse_dataset_name` 和 `adapter_name_or_path` 以及 `include_type` 的动态移除似乎在配置类中重复——请考虑整合此逻辑,以避免 output_dir/数据集初始化中的不一致。
## 单独评论
### 评论 1
<location> `weclone/train/train_sft.py:34` </location>
<code_context>
f"Dataset file '{data_path}' does not exist, please check if make-dataset was executed"
)
- if not dataset_config.clean_dataset.enable_clean or "image" in dataset_config.include_type:
- logger.info("Data cleaning is not enabled or images are included, will use the original dataset.")
- else:
- cleaner = LLMCleaningStrategy(make_dataset_config=dataset_config)
- train_config.dataset = cleaner.clean()
+ cleaner = LLMCleaningStrategy(make_dataset_config=dataset_config)
+ train_config.dataset = cleaner.clean()
</code_context>
<issue_to_address>
移除条件清理可能会导致意外清理图像数据集。
考虑恢复条件或添加明确处理以防止清理不支持的图像数据集。
</issue_to_address>帮助我更有用!请在每条评论上点击 👍 或 👎,我将利用反馈改进你的评论。
Original comment in English
Hey there - I've reviewed your changes - here's some feedback:
- In the
judgemethod, skipping image-based QA pairs without adjusting the input‐to‐output index mapping can misalign vLLM inference results and scores—consider preserving placeholder inputs or remapping indices to keep parsed scores in sync. - The
train_sft.maincleanup step now unconditionally runs the cleaner even whenenable_cleanis false or image modalities are included; if that wasn’t intentional, reintroduce the guard or document the behavior change. - The new
CommonMethods._parse_dataset_nameand the dynamic removal ofadapter_name_or_pathandinclude_typeseem duplicated across config classes—consider consolidating this logic to avoid inconsistencies in output_dir/dataset initialization.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `judge` method, skipping image-based QA pairs without adjusting the input‐to‐output index mapping can misalign vLLM inference results and scores—consider preserving placeholder inputs or remapping indices to keep parsed scores in sync.
- The `train_sft.main` cleanup step now unconditionally runs the cleaner even when `enable_clean` is false or image modalities are included; if that wasn’t intentional, reintroduce the guard or document the behavior change.
- The new `CommonMethods._parse_dataset_name` and the dynamic removal of `adapter_name_or_path` and `include_type` seem duplicated across config classes—consider consolidating this logic to avoid inconsistencies in output_dir/dataset initialization.
## Individual Comments
### Comment 1
<location> `weclone/train/train_sft.py:34` </location>
<code_context>
f"Dataset file '{data_path}' does not exist, please check if make-dataset was executed"
)
- if not dataset_config.clean_dataset.enable_clean or "image" in dataset_config.include_type:
- logger.info("Data cleaning is not enabled or images are included, will use the original dataset.")
- else:
- cleaner = LLMCleaningStrategy(make_dataset_config=dataset_config)
- train_config.dataset = cleaner.clean()
+ cleaner = LLMCleaningStrategy(make_dataset_config=dataset_config)
+ train_config.dataset = cleaner.clean()
</code_context>
<issue_to_address>
Removing conditional cleaning may lead to unintended cleaning of image datasets.
Consider restoring the conditional or adding explicit handling to prevent cleaning unsupported image datasets.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Allow `vllm_infer` to return `None` for failed JSON parsing results, clarifying the sequence index for such failures. This enables `LLMCleaningStrategy` to robustly align parsed LLM scores with original data, correctly handling examples where JSON parsing failed by assigning a default score of 0. Adds an option to disable data cleaning during training setup.
There was a problem hiding this comment.
Pull Request Overview
This release updates WeClone to version 0.3.02, introducing configurable "thinking" functionality for offline LLM cleaning and improving multimodal data handling. The update enhances the data processing pipeline by allowing more control over LLM behavior during dataset cleaning operations.
- Added configurable
enable_thinkingflag to control LLM cleaning behavior with adjustable parameters - Improved handling of images and GIFs in QA processing with automatic scoring and conversion features
- Refactored configuration models to use dynamic dataset naming and cleaner field management
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| weclone/utils/config_models.py | Added enable_thinking field and refactored config models with dynamic dataset naming |
| weclone/data/clean/strategies.py | Enhanced LLM cleaning to handle images automatically and pass thinking configuration |
| weclone/core/inference/offline_infer.py | Updated vLLM inference to support thinking mode and improved error handling |
| weclone/data/qa_generator.py | Added GIF-to-sticker conversion and improved CSV processing |
| weclone/train/train_sft.py | Removed image-based exclusion from LLM cleaning workflow |
| pyproject.toml | Updated dependencies and bumped version to 0.3.02 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| prompt_value = prompt_template.invoke({"id": qa.id, "messages": messages_str.strip()}) | ||
| inputs.append(prompt_value.to_string()) | ||
| if qa.images: | ||
| qa.score = 6 |
There was a problem hiding this comment.
The hardcoded score value of 6 should be defined as a named constant or configuration parameter to improve maintainability and make the scoring logic more transparent.
| qa.score = 6 | |
| qa.score = self.IMAGE_SCORE |
| chat_template_kwargs={"enable_thinking": enable_thinking}, | ||
| ) # type: ignore | ||
|
|
||
| del llm |
There was a problem hiding this comment.
Explicitly deleting the LLM object may not immediately free GPU memory. Consider using proper context management or calling torch.cuda.empty_cache() after deletion to ensure GPU memory is released.
| del llm | |
| del llm | |
| torch.cuda.empty_cache() |
| for i in df.index: | ||
| if df.loc[i, "type_name"].lower() in ["文本", "text"]: | ||
| continue | ||
| if df.loc[i, "src"].lower().endswith(".gif"): |
There was a problem hiding this comment.
Calling .lower() on every iteration is inefficient. Consider preprocessing the data or using a case-insensitive comparison method to improve performance when processing large datasets.
Adds a call to empty the CUDA cache immediately after the LLM object is deleted, ensuring prompt release of GPU memory. This helps prevent out-of-memory issues and improves resource utilization for subsequent operations.
Sourcery 总结
在离线清理中启用可配置的“思考”功能,改进问答处理中的图像和 GIF 处理,重构配置模型以实现更清晰的数据集命名,并为发布 v0.3.02 提升版本和依赖项。
新功能:
enable_thinking标志以控制离线清理行为改进:
cleaned_dataset_name以从原始数据集动态派生enable_thinking传递给 vLLM 推理管道,并相应调整repetition_penalty和max_new_tokensCommonMethods以解析带有模态后缀的数据集名称,并移除已弃用的配置字段save_result中将 QA id 转换为字符串以保持一致性pyjson5.load切换到loads,并为训练配置填充include_type构建:
openai至 1.87.0,vllm至 0.10.0,torch至 2.7.1,添加torchvision,transformers至 4.53.2,以及triton至 3.3.1CI:
pre-commit-hooks升级至 v6.0.0,ruff升级至 v0.12.8文档:
Original summary in English
Summary by Sourcery
Enable configurable thinking in offline cleaning, improve image and gif handling in QA processing, refactor configuration models for cleaner dataset naming, and bump versions and dependencies for release v0.3.02
New Features:
Enhancements:
Build:
CI:
Documentation: