File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,22 @@ except:
5151 ),
5252 )
5353
54-
54+ 处理过长的prompt:src/agentscope/model/_ openai_model.py OpenAIChatModel 的__ call__ 函数
55+ conversations = [ {"role": msg [ "role"] , "content": msg [ "content"] [ 0] [ 'text' ] if type(msg[ "content"] ) == list else msg[ "content"] } for msg in messages]
56+ input_ids = self.tokenizer.apply_chat_template(
57+ conversations,
58+ add_generation_prompt=True,
59+ tokenize=True,
60+ )
61+
62+ while len(input_ids) > 10000: (比maxlen稍微小一点)
63+ messages[ 1] [ "content" ] [ 0] [ 'text' ] = messages[ 1] [ "content" ] [ 0] [ 'text' ] [ :150] + messages[ 1] [ "content" ] [ 0] [ 'text' ] [ 200:]
64+ conversations = [ {"role": msg [ "role"] , "content": msg [ "content"] [ 0] [ 'text' ] if type(msg[ "content"] ) == list else msg[ "content"] } for msg in messages]
65+ input_ids = self.tokenizer.apply_chat_template(
66+ conversations,
67+ add_generation_prompt=True,
68+ tokenize=True,
69+ )
5570
5671verlv0.5.0 改动
5772
Original file line number Diff line number Diff line change @@ -45,11 +45,12 @@ python -m agentlightning.verl \
4545 algorithm.use_kl_in_reward=False \
4646 trainer.default_local_dir=' /root/dataDisk/checkpoints' \
4747 trainer.rollout_data_dir=' /root/dataDisk/rollout' \
48+ trainer.resume_mode=auto \
4849 trainer.critic_warmup=0 \
4950 trainer.logger=[' console' ,' wandb' ] \
5051 trainer.project_name=${PROJECT_NAME} \
5152 trainer.experiment_name=${EXPERIMENT_NAME} \
5253 trainer.nnodes=1 \
53- trainer.save_freq=10 \
54+ trainer.save_freq=1 \
5455 trainer.test_freq=0 \
5556 trainer.total_epochs=1 $@
You can’t perform that action at this time.
0 commit comments