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

[Bug]: 依存句法分析使用出错,提示LAC依赖,但是LAC已经安装 #9378

Open
1 task done
yunc0701 opened this issue Nov 6, 2024 · 5 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@yunc0701
Copy link

yunc0701 commented Nov 6, 2024

软件环境

- paddlepaddle:2.6.2
- paddlepaddle-gpu: 非GPU
- paddlenlp: 2.6.1

重复问题

  • I have searched the existing issues

错误描述

使用paddlenlp运行依存句法分析时报错,提示LAC依赖没有找到,但是LAC已经安装了

稳定复现步骤 & 代码

from paddlenlp import Taskflow
ddp = Taskflow("dependency_parsing", model="ddparser-ernie-gram-zh",use_pos=True)
运行之后,出现以下错误
Traceback (most recent call last):
File "D:\anaconda3\envs\py310\lib\site-packages\paddlenlp\taskflow\dependency_parsing.py", line 183, in init
from LAC import LAC
File "D:\anaconda3\envs\py310\lib\site-packages\LAC_init_.py", line 23, in
from .lac import LAC
File "D:\anaconda3\envs\py310\lib\site-packages\LAC\lac.py", line 28, in
import paddle.fluid as fluid
ModuleNotFoundError: No module named 'paddle.fluid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "D:\anaconda3\envs\py310\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 804, in init
self.task_instance = task_class(
File "D:\anaconda3\envs\py310\lib\site-packages\paddlenlp\taskflow\dependency_parsing.py", line 185, in init
raise ImportError("Please install the dependencies first, pip install LAC --upgrade")
ImportError: Please install the dependencies first, pip install LAC --upgrade

@yunc0701 yunc0701 added the bug Something isn't working label Nov 6, 2024
@wawltor
Copy link
Collaborator

wawltor commented Nov 6, 2024

看起来是paddle版本过高导致,可以降低paddle版本到2.5版本

@yunc0701
Copy link
Author

yunc0701 commented Nov 7, 2024

换到2.5版本后,解语不能用了,

print(wordtag("陈毅、项英领导的斗争经历和根据地的经济发展"))
D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\transformers\tokenizer_utils_base.py:1865: UserWarning: Truncation was not explicitly activated but max_length is provided a specific value, please use truncation=True to explicitly truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to truncation.
warnings.warn(
Traceback (most recent call last):
File "", line 1, in
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 817, in call
results = self.task_instance(inputs, **kwargs)
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\task.py", line 527, in call
outputs = self._run_model(inputs, **kwargs)
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\knowledge_mining.py", line 479, in _run_model
self.predictor.run()
ValueError: (InvalidArgument) Variable value (input) of OP(fluid.layers.embedding) expected >= 0 and < 23000, but got 3347144728220101678. Please check input value.
[Hint: Expected ids[i] < row_number, but received ids[i]:3347144728220101678 >= row_number:23000.] (at ..\paddle\phi\kernels\cpu\embedding_kernel.cc:67)
[operator < lookup_table_v2 > error]

句法分析报错

ddp = Taskflow("dependency_parsing", model="ddparser-ernie-gram-zh",use_pos=True)
result = ddp(sentence)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'sentence' is not defined
result = ddp("陈毅、项英领导的斗争经历和根据地的经济发展")
Traceback (most recent call last):
File "", line 1, in
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 817, in call
results = self.task_instance(inputs, **kwargs)
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\task.py", line 527, in call
outputs = self._run_model(inputs, **kwargs)
File "D:\anaconda3\envs\np310\lib\site-packages\paddlenlp\taskflow\dependency_parsing.py", line 305, in _run_model
self.predictor.run()
ValueError: In user code:

File "D:\tonado\nlpserver.py", line 104, in <module>
  tornado.ioloop.IOLoop.instance().start()
File "D:\anaconda3\envs\python39\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
  self.asyncio_loop.run_forever()
File "D:\anaconda3\envs\python39\lib\asyncio\windows_events.py", line 321, in run_forever
  super().run_forever()
File "D:\anaconda3\envs\python39\lib\asyncio\base_events.py", line 601, in run_forever
  self._run_once()
File "D:\anaconda3\envs\python39\lib\asyncio\base_events.py", line 1905, in _run_once
  handle._run()
File "D:\anaconda3\envs\python39\lib\asyncio\events.py", line 80, in _run
  self._context.run(self._callback, *self._args)
File "D:\anaconda3\envs\python39\lib\site-packages\tornado\web.py", line 1788, in _execute
  result = method(*self.path_args, **self.path_kwargs)
File "D:\tonado\nlpserver.py", line 65, in post
  ddp = Taskflow("dependency_parsing", model="ddparser-ernie-gram-zh",use_pos=True)
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 696, in __init__
  self.task_instance = task_class(
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\dependency_parsing.py", line 189, in __init__
  self._get_inference_model()
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\task.py", line 323, in _get_inference_model
  self._convert_dygraph_to_static()
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\task.py", line 346, in _convert_dygraph_to_static
  paddle.jit.save(static_model, self.inference_model_path)
File "D:\anaconda3\envs\python39\lib\site-packages\decorator.py", line 232, in fun
  return caller(func, *(extras + args), **kw)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\wrapped_decorator.py", line 26, in __impl__
  return wrapped_func(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\jit.py", line 649, in wrapper
  func(layer, path, input_spec, **configs)
File "D:\anaconda3\envs\python39\lib\site-packages\decorator.py", line 232, in fun
  return caller(func, *(extras + args), **kw)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\wrapped_decorator.py", line 26, in __impl__
  return wrapped_func(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\base.py", line 67, in __impl__
  return func(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\jit.py", line 927, in save
  concrete_program = static_func.concrete_program_specify_input_spec(
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 577, in concrete_program_specify_input_spec
  concrete_program, _ = self.get_concrete_program(
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 485, in get_concrete_program
  concrete_program, partial_program_layer = self._program_cache[cache_key]
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 955, in __getitem__
  self._caches[item_id] = self._build_once(item)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 939, in _build_once
  concrete_program = ConcreteProgram.from_func_spec(
File "D:\anaconda3\envs\python39\lib\site-packages\decorator.py", line 232, in fun
  return caller(func, *(extras + args), **kw)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\wrapped_decorator.py", line 26, in __impl__
  return wrapped_func(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\base.py", line 67, in __impl__
  return func(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 888, in from_func_spec
  outputs = static_func(*inputs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\models\dependency_parsing_model.py", line 48, in forward
  words, x = self.embed(words, wp)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\layers.py", line 950, in __call__
  return self._dygraph_call_func(*inputs, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\dygraph\layers.py", line 935, in _dygraph_call_func
  outputs = self.forward(*inputs, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\models\dependency_parsing_model.py", line 146, in forward
  x = paddle.reshape(
File "D:\anaconda3\envs\python39\lib\site-packages\paddlenlp\taskflow\models\dependency_parsing_model.py", line 224, in index_sample
  out = paddle.gather_nd(r_x, new_index)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\tensor\manipulation.py", line 3801, in gather_nd
  helper.append_op(
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\layer_helper.py", line 45, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\framework.py", line 4017, in append_op
  op = Operator(
File "D:\anaconda3\envs\python39\lib\site-packages\paddle\fluid\framework.py", line 2858, in __init__
  for frame in traceback.extract_stack():

InvalidArgumentError: Input(index[-1)] has wrong value, it is [55834574849]
  [Hint: Expected index_value < input_dims[j], but received index_value:55834574849 >= input_dims[j]:1.] (at ..\paddle/phi/kernels/funcs/gather.h:132)
  [operator < gather_nd > error]

@wawltor
Copy link
Collaborator

wawltor commented Nov 8, 2024

我使用2.5.2的版本是可以正常运行的
图片

@yunc0701
Copy link
Author

yunc0701 commented Nov 8, 2024

paddlepaddle和paddlenlp分别采用2.5.2,以及paddlepaddle采用2.5.2,paddleNLP采用2.6.1都会报错,目前安装在windows10上

from paddlenlp import Taskflow
D:\anaconda3\envs\rmy\lib\site-packages_distutils_hack_init_.py:31: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
warnings.warn(
wordtag = Taskflow("knowledge_mining")
E1108 21:48:05.620348 24560 analysis_config.cc:926] EnableMKLDNN() only works when IR optimization is enabled.
print(wordtag("陈毅、项英领导的斗争经历和根据地的经济发展"))
D:\anaconda3\envs\rmy\lib\site-packages\paddlenlp\transformers\tokenizer_utils_base.py:1865: UserWarning: Truncation was not explicitly activated but max_length is provided a specific value, please use truncation=True to explicitly truncate examples to max length. Defaulting to 'longest_first' truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to truncation.
warnings.warn(
Traceback (most recent call last):
File "", line 1, in
File "D:\anaconda3\envs\rmy\lib\site-packages\paddlenlp\taskflow\taskflow.py", line 817, in call
results = self.task_instance(inputs, **kwargs)
File "D:\anaconda3\envs\rmy\lib\site-packages\paddlenlp\taskflow\task.py", line 527, in call
outputs = self._run_model(inputs, **kwargs)
File "D:\anaconda3\envs\rmy\lib\site-packages\paddlenlp\taskflow\knowledge_mining.py", line 479, in _run_model
self.predictor.run()
ValueError: (InvalidArgument) Variable value (input) of OP(fluid.layers.embedding) expected >= 0 and < 23000, but got 2435706665072. Please check input value.
[Hint: Expected ids[i] < row_number, but received ids[i]:2435706665072 >= row_number:23000.] (at ..\paddle\phi\kernels\cpu\embedding_kernel.cc:67)
[operator < lookup_table_v2 > error]
exit()

@yunc0701
Copy link
Author

yunc0701 commented Nov 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants