[go: nahoru, domu]

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

[Question]: 对ERNIE模型进行微调时,报错Pointer C should not be null. #8665

Open
jjy260782149 opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels
question Further information is requested

Comments

@jjy260782149
Copy link
jjy260782149 commented Jun 26, 2024

请提出你的问题

使用ERNIE模型,进行微调时,出现错误:
Traceback (most recent call last):
File "D:\1.地下空间数据获取\netBuild\ERNIE\train.py", line 95, in
logits = model(input_ids, token_type_ids)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 709, in forward
outputs = self.ernie(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\ernie\modeling.py", line 357, in forward
encoder_outputs = self.encoder(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 304, in _transformer_encoder_fwd
layer_outputs = mod(
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddlenlp\transformers\model_outputs.py", line 83, in _transformer_encoder_layer_fwd
attn_outputs = self.self_attn(src, src, src, src_mask, cache)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\layers.py", line 1429, in call
return self.forward(*inputs, **kwargs)
File "D:\app\python38\lib\site-packages\paddle\nn\layer\transformer.py", line 432, in forward
out = tensor.matmul(weights, v)
File "D:\app\python38\lib\site-packages\paddle\tensor\linalg.py", line 239, in matmul
return _C_ops.matmul(x, y, transpose_x, transpose_y)
ValueError: (InvalidArgument) Pointer C should not be null.
[Hint: C should not be null.] (at ..\paddle/phi/kernels/funcs/blas/blas_impl.h:1373)

微调代码为:
model = ErnieForTokenClassification.from_pretrained("ernie-1.0", num_classes=len(labelVocab))
step = 0
for epoch in range(50):
for idx, (input_ids, token_type_ids, length, labels) in enumerate(train_loader):
logits = model(input_ids, token_type_ids)
loss = paddle.mean(loss_fn(logits, labels))
loss.backward()
optimizer.step()
optimizer.clear_grad()
step += 1
print("epoch:%d - step:%d - loss: %f" % (epoch, step, loss))
evaluate(model, metric, dev_loader)

我之前用一套训练数据运行成功了,换了一套训练数据就报错了,昨天觉得是数据本身或者预处理不当导致出现问题,但今天是在预训练到第三轮才报的错,应该不是数据本身或者预处理的问题。没有什么解决思路,希望能给与解答,谢谢。

@jjy260782149 jjy260782149 added the question Further information is requested label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants