Skip to content
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

[llm]support dpo pp #9039

Merged
merged 10 commits into from
Sep 20, 2024
Merged

[llm]support dpo pp #9039

merged 10 commits into from
Sep 20, 2024

Conversation

lugimzzz
Copy link
Contributor

@lugimzzz lugimzzz commented Aug 28, 2024

PR types

New features

PR changes

APIs

Description

  1. 重构DPOTrainer与原版逐位对齐loss、metric
  2. 重构DPOTrainer能够支持pp & vpp
  3. 支持LoRA和多种DPO变体(包含KTO、DPO、ORPO、Simpo)
  4. 新增支持多个开源模型

Copy link

paddle-bot bot commented Aug 28, 2024

Thanks for your contribution!

@lugimzzz lugimzzz changed the title [llm]support dpo/kto pp WIP [llm]support dpo/kto pp Aug 28, 2024
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 9.36281% with 697 lines in your changes missing coverage. Please review.

Project coverage is 53.07%. Comparing base (90cef20) to head (69ad7cf).
Report is 41 commits behind head on develop.

Files with missing lines Patch % Lines
paddlenlp/transformers/tensor_parallel_utils.py 5.55% 255 Missing ⚠️
paddlenlp/trl/dpo_trainer.py 5.72% 214 Missing ⚠️
paddlenlp/trl/dpo_criterion.py 9.09% 140 Missing ⚠️
paddlenlp/transformers/sequence_parallel_utils.py 17.50% 66 Missing ⚠️
paddlenlp/utils/infohub.py 26.66% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9039      +/-   ##
===========================================
- Coverage    53.26%   53.07%   -0.20%     
===========================================
  Files          652      656       +4     
  Lines       105607   106095     +488     
===========================================
+ Hits         56254    56309      +55     
- Misses       49353    49786     +433     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lugimzzz lugimzzz changed the title WIP [llm]support dpo/kto pp WIP [llm]support dpo pp Aug 30, 2024
paddlenlp/trl/dpo_criterion.py Outdated Show resolved Hide resolved
paddlenlp/trl/dpo_criterion.py Show resolved Hide resolved
paddlenlp/trl/dpo_criterion.py Outdated Show resolved Hide resolved
paddlenlp/trl/dpo_criterion.py Show resolved Hide resolved
paddlenlp/trl/dpo_criterion.py Show resolved Hide resolved
paddlenlp/trl/dpo_trainer.py Show resolved Hide resolved
paddlenlp/trl/dpo_trainer.py Show resolved Hide resolved
Comment on lines +279 to +301
for key in batch.keys():
if key not in "response_indexs":
concatenated_inputs[key] = [
batch[key][i * per_device_train_batch_size : (i + 1) * per_device_train_batch_size]
for i in range(gradient_accumulation_steps)
]
else:
concatenated_inputs["response_indexs"] = [[] for _ in range(gradient_accumulation_steps)]
for i in range(gradient_accumulation_steps):
for response_index in batch[key]:
if response_index[0] in list(
range(i * per_device_train_batch_size, (i + 1) * per_device_train_batch_size)
):
response_index[0] -= i * per_device_train_batch_size
concatenated_inputs["response_indexs"][i].append(response_index)
concatenated_inputs["response_indexs"][i] = paddle.stack(concatenated_inputs["response_indexs"][i])
if model._layers.config.use_sparse_head_and_loss_fn:
last_batch_response_length = concatenated_inputs["response_indexs"][i][0, 1]
concatenated_inputs["response_indexs"][i][:, 1:] -= last_batch_response_length

concatenated_inputs["reference_chosen_logps"] = None
concatenated_inputs["reference_rejected_logps"] = None

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议这一大堆,封装成一个函数。

paddlenlp/trl/dpo_trainer.py Outdated Show resolved Hide resolved
paddlenlp/trl/dpo_trainer.py Show resolved Hide resolved
@lugimzzz lugimzzz changed the title WIP [llm]support dpo pp [llm]support dpo pp Sep 13, 2024
llm/config/qwen/AdvertiseGen/w8a8_ptq_argument.json Outdated Show resolved Hide resolved
llm/run_finetune.py Show resolved Hide resolved
paddlenlp/transformers/gemma/modeling.py Show resolved Hide resolved
paddlenlp/transformers/yuan/configuration.py Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Sep 20, 2024

CLA assistant check
All committers have signed the CLA.

get_last_checkpoint,
set_seed,
from dpo_argument import (
DPOConfig,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DPOConfig,DPOTrainingArguments 这些看是否加到主repo?

Copy link
Collaborator

@ZHUI ZHUI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ZHUI ZHUI merged commit bc55104 into PaddlePaddle:develop Sep 20, 2024
4 of 12 checks passed
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.

3 participants