diff --git a/README.md b/README.md index 71b7ddc89b791699834582bf12c00e7c8de8f0db..bd2b39c5d1dc0ffcc72725086a7d52192843a6f1 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ pipe = pipeline( model="Baichuan/Baichuan2_7b_chat_pt", framework="pt", backend="transformers", - trust_remote_code=True, + trust_remote_code=True, # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 device="npu:0", ) output = pipe("Give three tips for staying healthy.") diff --git a/docs/zh/api_reference/apis/cli_api.md b/docs/zh/api_reference/apis/cli_api.md index 01149d56e299e7f89fdf5172aee9a1795a287abe..00b47bcb24b815bc87d448d6658f9c1c6c566c58 100644 --- a/docs/zh/api_reference/apis/cli_api.md +++ b/docs/zh/api_reference/apis/cli_api.md @@ -387,19 +387,21 @@ Push to your_organization/your_repo finished - ai2_arc ``` -****接口调用示例**** +**接口调用示例** + +为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性。 - 使用`ai2_arc`数据集评估`Baichuan/Baichuan2_7b_chat_pt`精度。 ```bash - openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --device 0 --tasks arithmetic --batch_size 64 + openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --device 0 --tasks arithmetic --batch_size 64 --trust_remote_code True ``` - 使用`ai2_arc`数据集,单机多卡评估`Baichuan/Baichuan2_7b_chat_pt`精度。 ```bash export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 - openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --tasks ai2_arc --batch_size 64 + openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --tasks ai2_arc --batch_size 64 --trust_remote_code True ``` - 打印当前支持的任务(评估集)。 @@ -429,7 +431,7 @@ Push to your_organization/your_repo finished - **--backend** (`str`,*可选*,默认为`lmeval`):指定评估使用的后端。 - **--device**(`str`/`int`, *可选*,默认为0):单卡评估时使用的加速卡,可选值为"cpu"或者0/1/2../7。在单机多卡评估场景下,不需要指定此参数,通过环境变量`ASCEND_RT_VISIBLE_DEVICES`控制使用的npu卡数。`ASCEND_RT_VISIBLE_DEVICES`用法请参考[环境变量说明](https://www.hiascend.com/document/detail/zh/canncommercial/800/apiref/envvar/envref_07_0028.html)。 - **--limit**(`int`,*可选*,默认为`None`):指定每个任务使用的样本数,此参数只用于限定样本数减少评估时间,用于验证功能是否正常,不支持评估模型能力。 -- **--trust_remote_code**(`str`,*可选*,默认为`True`):指定是否允许执行openMind Hub上定义的模型等代码。 +- **--trust_remote_code**(`str`,*可选*,默认为`False`):指定是否允许执行openMind Hub上定义的模型等代码。 - **--batch_size**(`str`,*可选*,默认为`1`):指定评估模型时的`batch_size`。 - **--fp16**(`bool`,*可选*,默认为`False`):模型加载是否使用fp16格式。 - **--bf16**(`bool`,*可选*,默认为`False`):模型加载是否使用bf16格式。 diff --git a/docs/zh/basic_tutorial/cli.md b/docs/zh/basic_tutorial/cli.md index dc07e2ec79c22a92df1807131ecc398abb02374e..4df53c1bdaff300e1fbd5c5a71fb959435bbbf45 100644 --- a/docs/zh/basic_tutorial/cli.md +++ b/docs/zh/basic_tutorial/cli.md @@ -302,19 +302,19 @@ run_chat( - ai2_arc:这个任务是一个需要模型进行深入推理和解决问题的任务,它通常包含科学问题和需要复杂推理的问题。当你需要评估模型在解决需要深入推理和背景知识的问题上的能力时,可以使用这个任务。 -接口调用示例如下。 +接口调用示例如下(为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性)。 - 使用`ai2_arc`数据集评估`Baichuan/Baichuan2_7b_chat_pt`精度。 ```bash - openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --device 0 --tasks arithmetic --batch_size 64 + openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --device 0 --tasks arithmetic --batch_size 64 --trust_remote_code True ``` - 使用`ai2_arc`数据集,单机多卡评估`Baichuan/Baichuan2_7b_chat_pt`精度。 ```bash export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 - openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --tasks ai2_arc --batch_size 64 + openmind-cli eval --model_name_or_path Baichuan/Baichuan2_7b_chat_pt --tasks ai2_arc --batch_size 64 --trust_remote_code True ``` - 显示当前支持的任务(评估集) @@ -352,6 +352,7 @@ run_eval( tasks="gsm8k", batch_size=64, limit=1, + trust_remote_code=True, # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 ) ``` diff --git a/docs/zh/basic_tutorial/distributed_launch/distributed_launch_ms.md b/docs/zh/basic_tutorial/distributed_launch/distributed_launch_ms.md index 243f693bd902c1e465c4d1c32dee4356b04384a0..aa878fe10efc6b0498bc031e64eb55ae9aa2b62c 100644 --- a/docs/zh/basic_tutorial/distributed_launch/distributed_launch_ms.md +++ b/docs/zh/basic_tutorial/distributed_launch/distributed_launch_ms.md @@ -18,7 +18,7 @@ MindSpore支持**数据并行**,**半自动并行**和**全自动并行**三 - **半自动并行**:在半自动并行模式下,并行逻辑和算法逻辑解耦,用户只需要按单卡串行的方式写算法代码,并配置并行策略来实现自动并行切分;用户无需感知模型切片的调度及集群拓扑。 - **全自动并行**:用户只需要写单卡串行算法,通过搜索算法来自动生成较优的切分策略。 -MindSpore分布式并行介绍请参考:[MindSpore分布式并行原生](https://www.mindspore.cn/docs/zh-CN/master/design/distributed_training_design.html) +MindSpore分布式并行介绍请参考:[MindSpore分布式并行原生](https://www.mindspore.cn/docs/zh-CN/r2.3.1/design/distributed_training_design.html) MindSpore分布式并行教程请参考:[MindSpore分布式并行总览](https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.1/parallel/overview.html) @@ -129,7 +129,7 @@ def main(): # 传入并行配置,初始化模型 model = AutoModelForCausalLM.from_pretrained("MindSpore-Lab/your_awesome_model", - trust_remote_code=True, + trust_remote_code=True, # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 parallel_config=get_parallel_config(training_args)) trainer = Trainer(args=training_args, diff --git a/docs/zh/basic_tutorial/fused_ops.md b/docs/zh/basic_tutorial/fused_ops.md index 6c348d376e1c0896555bc044afa5ca1ab8cf4fa1..e7f9bf23e6bb931157a4da1ce7fff7f1f943b299 100644 --- a/docs/zh/basic_tutorial/fused_ops.md +++ b/docs/zh/basic_tutorial/fused_ops.md @@ -124,7 +124,7 @@ pipe = pipeline( model="AI-Research/Qwen2.5-7B", framework="pt", backend="transformers", - trust_remote_code=True, + trust_remote_code=True, # 为保证代码安全,配置默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 device="npu:0", ) output = pipe("Give three tips for staying healthy.") diff --git a/docs/zh/basic_tutorial/load_dataset.md b/docs/zh/basic_tutorial/load_dataset.md index 0eb1d8c4ec474f0442bb38548888bc98d259116d..e1ab1567c9daadbf5a581722a5483480cba286c7 100644 --- a/docs/zh/basic_tutorial/load_dataset.md +++ b/docs/zh/basic_tutorial/load_dataset.md @@ -203,7 +203,7 @@ def _split_generators(self, dl_manager): ] ``` -从相关代码中可见,涉及下载对应文件时,URL指定了第三方站点。可尝试以下用例进行下载,请注意使用python脚本下载数据集文件时需要添加参数`trust_remote_code=True`。 +从相关代码中可见,涉及下载对应文件时,URL指定了第三方站点。可尝试以下用例进行下载,请注意使用python脚本下载数据集文件时需要添加参数`trust_remote_code=True`,用户需确保自己下载的模型和数据的安全性。 ```python data = OmDataset.load_dataset("modeltesting/test_py_github", trust_remote_code=True) @@ -446,7 +446,7 @@ print(data) ### 配置`trust_remote_code`参数 -如果下载python文件进行数据集下载时,脚本中涉及复杂的处理逻辑或远程自定义代码,需要设置该参数。如果python脚本仅仅加载了对应的json等文件时(不进一步处理),可以忽略该参数。 +如果下载python文件进行数据集下载时,脚本中涉及复杂的处理逻辑或远程自定义代码,需要设置该参数,并且确保自己下载的模型和数据的安全性。如果python脚本仅仅加载了对应的json等文件时(不进一步处理),可以忽略该参数。 ```python OmDataset.load_dataset(path="repo_name/dataset_name", trust_remote_code=True) diff --git a/docs/zh/basic_tutorial/pipeline.md b/docs/zh/basic_tutorial/pipeline.md index 464a3ee31189ec148458c29b449b008dc3194ba3..831c0a587ad71a2ce90c01bcdd6d123032a29a0c 100644 --- a/docs/zh/basic_tutorial/pipeline.md +++ b/docs/zh/basic_tutorial/pipeline.md @@ -77,7 +77,7 @@ openMind Library `pipeline`方法支持PyTorch和MindSpore两种框架。此外 model="Baichuan/Baichuan2_7b_chat_pt", framework="pt", backend="transformers", - trust_remote_code=True, + trust_remote_code=True, # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 device="npu:0", ) output = pipe("Give three tips for staying healthy.") @@ -118,11 +118,13 @@ openMind Library `pipeline`方法支持PyTorch和MindSpore两种框架。此外 ms.set_context(mode=0, device_id=0, jit_config={"jit_level": "O0", "infer_boost": "on"}) - pipe = pipeline(task="text-generation", - model='MindSpore-Lab/Qwen2_5-7B-Instruct', - framework='ms', - model_kwargs={"use_past": True}, - trust_remote_code=True) + pipe = pipeline( + task="text-generation", + model='MindSpore-Lab/Qwen2_5-7B-Instruct', + framework='ms', + model_kwargs={"use_past": True}, + trust_remote_code=True # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 + ) outputs = pipe("Give me some advice on how to stay healthy.") print(outputs) ``` diff --git a/docs/zh/best_practice/baichuan_m1.md b/docs/zh/best_practice/baichuan_m1.md index 4cbda30f6788a99eb8de1b90a44a64dfc486f3e4..b4380d2478f82ce828ae7ba7710124ed4870d2ff 100644 --- a/docs/zh/best_practice/baichuan_m1.md +++ b/docs/zh/best_practice/baichuan_m1.md @@ -73,7 +73,7 @@ openMind提供了低代码配置化的方式启动训练流程,只需要编写 ```yaml model_name_or_path: /data/Baichuan_M1_14B_Instruct/ -trust_remote_code: True +trust_remote_code: True # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 # method stage: sft @@ -130,7 +130,7 @@ ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 openmind-cli train baichuan_m1_full_sa model_name_or_path: /data/Baichuan_M1_14B_Instruct adapter_models: saves/baichuan_m1_lora output_dir: target_path -trust_remote_code: True +trust_remote_code: True # 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 ``` 这里定义了原始的权重路径,微调的LoRA权重路径,合并后的目标保存路径 diff --git a/docs/zh/best_practice/deepseek_r1.md b/docs/zh/best_practice/deepseek_r1.md index 54f6b5e76745570a2a24b82717b263b27b5d4106..b9ec79a3f4e641d6b796142719a91ef05c36dbb9 100644 --- a/docs/zh/best_practice/deepseek_r1.md +++ b/docs/zh/best_practice/deepseek_r1.md @@ -195,6 +195,7 @@ template: deepseek_r1 finetuning_type: lora output_dir: target_path trust_remote_code: True +# 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 ``` 这里定义了原始的权重路径,微调的LoRA权重路径,合并后的目标保存路径 diff --git a/docs/zh/best_practice/opencompass.md b/docs/zh/best_practice/opencompass.md index 770890eb2ebb0b51d7c161d93b85edada91bc2ff..2d7d67f5b0cc373db7afe5bde1228278aa8ea9fe 100644 --- a/docs/zh/best_practice/opencompass.md +++ b/docs/zh/best_practice/opencompass.md @@ -74,6 +74,7 @@ python run.py \ --min-out-len 16 \ --batch-size 32 \ --max-num-workers 4 +# 为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性 ``` - datasets中可以传入多个数据集,从而一次评估多个数据集。 diff --git a/docs/zh/task/nlp/text_generation.md b/docs/zh/task/nlp/text_generation.md index ac7a35de83a57b300e5ba719e7122e12f85dc12c..f5c743ed90b75c1c109eb936d32226768c3124fa 100644 --- a/docs/zh/task/nlp/text_generation.md +++ b/docs/zh/task/nlp/text_generation.md @@ -185,7 +185,7 @@ build_context(training_args) ### 模型初始化 -在使用MindSpore框架时,您的任务会基于半自动并行模式进行训练,需要实例化模型并行配置,并将其作为入参传入`AutoModelForCausalLM`以初始化带并行配置的模型。 +在使用MindSpore框架时,您的任务会基于半自动并行模式进行训练,需要实例化模型并行配置,并将其作为入参传入`AutoModelForCausalLM`以初始化带并行配置的模型(为保证代码安全,配置trust_remote_code默认为False,用户需要设置为True,并且确保自己下载的模型和数据的安全性)。 ::: code-group diff --git a/examples/features/chat/chat_demo.yaml b/examples/features/chat/chat_demo.yaml index 2af053755d6fa87d42f0c965d5d416f9b580f206..5e586d70958b721140e48a568c08cc9085d98f97 100644 --- a/examples/features/chat/chat_demo.yaml +++ b/examples/features/chat/chat_demo.yaml @@ -1,5 +1,4 @@ model_name_or_path: AI-Research/internlm2_5-7b-chat -trust_remote_code: True template: internlm2 bf16: True device: 0 \ No newline at end of file diff --git a/examples/features/deploy/deploy_demo_sdk.py b/examples/features/deploy/deploy_demo_sdk.py index 59a535ecabb85ba0a2bd58508859f4160dbde4c7..21d0a4e782031e484d44635ad74d817df64276f8 100644 --- a/examples/features/deploy/deploy_demo_sdk.py +++ b/examples/features/deploy/deploy_demo_sdk.py @@ -3,6 +3,5 @@ from openmind import run_deploy run_deploy( model_name_or_path="AI_Connect/Qwen2_0.5B", backend="lmdeploy", - device=2, - trust_remote_code=True + device=2 ) \ No newline at end of file diff --git a/examples/features/eval/eval_demo.yaml b/examples/features/eval/eval_demo.yaml index bcc30341f79ce7bee2c1565c9dfb3b5ea371fe5a..e45863d17e0cfce99a9a74ca8173d5fbf68e1a67 100644 --- a/examples/features/eval/eval_demo.yaml +++ b/examples/features/eval/eval_demo.yaml @@ -3,5 +3,4 @@ model_name_or_path: AI_Connect/Qwen2_0.5B device: 0 tasks: gsm8k batch_size: 64 -trust_remote_code: True limit: 1 diff --git a/examples/features/train/train_rm_lora.yaml b/examples/features/train/train_rm_lora.yaml index 9c25e53d11948d18a4d91d3e90b8b1d90d0b189f..a501b07c2c2174d710428e87c7110e34a05a389c 100644 --- a/examples/features/train/train_rm_lora.yaml +++ b/examples/features/train/train_rm_lora.yaml @@ -9,8 +9,6 @@ template: qwen deepspeed: examples/deepspeed/ds_z2_config.json -trust_remote_code: True - # dataset dataset: rlhf-reward-datasets cutoff_len: 1024 diff --git a/examples/glm4/train_sft_lora_glm_4_9b_chat.yaml b/examples/glm4/train_sft_lora_glm_4_9b_chat.yaml index 20aaaf3b6e68b4120d2cf6e4935324aa375c29b9..2654915de41fa992ea0c6cebea470a8af3c87db2 100644 --- a/examples/glm4/train_sft_lora_glm_4_9b_chat.yaml +++ b/examples/glm4/train_sft_lora_glm_4_9b_chat.yaml @@ -1,6 +1,5 @@ # model model_id: Glm-4-9b-chat -trust_remote_code: true # fusion operator: use_npu_fusion_attention: false diff --git a/examples/internlm2/train_sft_lora_internlm2_7b.yaml b/examples/internlm2/train_sft_lora_internlm2_7b.yaml index 1badeb6ef0eb27f18ca9d45b163ec42a5cc1e779..5c6ac571c6c5eca9cbda392d2d962dea522f7937 100644 --- a/examples/internlm2/train_sft_lora_internlm2_7b.yaml +++ b/examples/internlm2/train_sft_lora_internlm2_7b.yaml @@ -1,6 +1,5 @@ # model model_id: Internlm2-7B -trust_remote_code: true # method stage: sft diff --git a/examples/internlm3/train_sft_full_internlm3_8b_chat.yaml b/examples/internlm3/train_sft_full_internlm3_8b_chat.yaml index 0551ea88df9c06f7692e817525ef01398d90c9db..db87a1a6d34005df9797a9601c6c370db81a4990 100644 --- a/examples/internlm3/train_sft_full_internlm3_8b_chat.yaml +++ b/examples/internlm3/train_sft_full_internlm3_8b_chat.yaml @@ -1,6 +1,5 @@ # model model_id: Internlm3-8B-Chat -trust_remote_code: true # method stage: sft diff --git a/examples/internlm3/train_sft_lora_internlm3_8b_chat.yaml b/examples/internlm3/train_sft_lora_internlm3_8b_chat.yaml index 2e8bcebddfdefa2fa5621003dd778c5778d086fa..dc67fff1c6f2b33704da62c4f2e0d65b8c4a260d 100644 --- a/examples/internlm3/train_sft_lora_internlm3_8b_chat.yaml +++ b/examples/internlm3/train_sft_lora_internlm3_8b_chat.yaml @@ -1,6 +1,5 @@ # model model_id: Internlm3-8B-Chat -trust_remote_code: true # method stage: sft diff --git a/examples/internlm3/train_sft_qlora_internlm3_8b_chat.yaml b/examples/internlm3/train_sft_qlora_internlm3_8b_chat.yaml index 996b3b0378311b524810081e536a51c9aadbc9a9..89bd45484e9c4e46a9f2fa70228a7bda39f91cf5 100644 --- a/examples/internlm3/train_sft_qlora_internlm3_8b_chat.yaml +++ b/examples/internlm3/train_sft_qlora_internlm3_8b_chat.yaml @@ -1,6 +1,5 @@ # model model_id: Internlm3-8B-Chat -trust_remote_code: true load_in_4bit: True use_npu_fusion_attention: false use_fused_rms_norm: false diff --git a/src/openmind/flow/eval/lmeval.py b/src/openmind/flow/eval/lmeval.py index 25ddfd21a06b8c7b59b3563f92449fd9d755abb9..e31de6acf25d022eb2088d9290452d71d29d3eec 100644 --- a/src/openmind/flow/eval/lmeval.py +++ b/src/openmind/flow/eval/lmeval.py @@ -82,10 +82,6 @@ class LMEval: path = dataset_map[path] break - # Add trust_remote_code if not exists - if "trust_remote_code" not in kwargs: - kwargs["trust_remote_code"] = True - return load_datasets_func(path, *args, **kwargs) return wrapper