Skip to content

[Bug]: FSL的P-Tuning官方示例报错 #8883

@guangyunms

Description

@guangyunms

软件环境

- paddlepaddle:2.6.1 and 3.0.0Beta
- paddlepaddle-gpu: 2.6.1 and 3.0.0Beta
- paddlenlp: 3.0Beta

重复问题

  • I have searched the existing issues

错误描述

在P-Tuning官方的例子中给出了使用方法。然而运行报错。文档链接:https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/few_shot/p-tuning

Traceback (most recent call last):
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/io/dataloader/dataloader_iter.py", line 235, in _thread_loop
    batch = self._dataset_fetcher.fetch(
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/io/dataloader/fetcher.py", line 77, in fetch
    data.append(self.dataset[idx])
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddlenlp/datasets/dataset.py", line 263, in __getitem__
    return self._transform(self.new_data[idx]) if self._transform_pipline else self.new_data[idx]
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddlenlp/datasets/dataset.py", line 255, in _transform
    data = fn(data)
  File "/home/aistudio/PaddleNLP-release-3.0-beta/legacy/examples/few_shot/p-tuning/data.py", line 144, in convert_ids_to_words
    labels = paddle.index_select(token_ids, paddle.to_tensor(example.pop("label_ids")), axis=0).squeeze(0)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/tensor/search.py", line 362, in index_select
    return _C_ops.index_select(x, index, axis)
ValueError: (InvalidArgument) The 'shape' of Input(Index) must be 1-D tensor. But received: the 'shape' of Input(Index) is [], the dimension of Input(Index) is [0].
  [Hint: Expected index_dim.size() == 1 || (index_dim.size() == 2 && index_dim[1] == 1) == true, but received index_dim.size() == 1 || (index_dim.size() == 2 && index_dim[1] == 1):0 != true:1.] (at /paddle/paddle/phi/infermeta/binary.cc:1844)

稳定复现步骤 & 代码

运行命令:

python -u -m paddle.distributed.launch --gpus "0" run_train.py \ --output_dir checkpoint_eprstmt \ --task_name eprstmt \ --split_id few_all \ --prompt_path prompt/eprstmt.json \ --prompt_index 0 \ --do_train \ --do_eval \ --do_test \ --do_predict \ --do_label \ --max_steps 1000 \ --learning_rate 3e-5 \ --eval_steps 100 \ --save_steps 100 \ --logging_steps 5 \ --per_device_train_batch_size 16 \ --max_seq_length 128 \ --load_best_model_at_end \ --metric_for_best_model accuracy \ --save_total_limit 1 \ --model_name_or_path "ernie-3.0-base-zh"

官方文档链接:https://github.com/PaddlePaddle/PaddleNLP/tree/develop/legacy/examples/few_shot/p-tuning

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions