Git Product home page Git Product logo

lcf-atepc's Introduction

Hi there!

I am a PhD student at the University of Exeter. My research interests include biological sequence modeling, natural language processing, computer vision etc. Please find the details of my study in the following sections. Find me on GitHub or Google Scholar.

Research Topics

  • bio-RNA Sequence pretraining & modeling
  • Textual Adversarial Attack/Defense
  • Sentiment (Coherency) Analysis
  • Code language modeling
  • Diffusion models

First-author Publications

EACL 2024 Findings H Yang, K Li. Improving Implicit Sentiment Learning via Local Sentiment Aggregation

ACL 2023 Findings H Yang, K Li. Boosting Text Augmentation via Hybrid Instance Filtering Framework

EMNLP 2023 Findings H Yang, K Li. InstOptima: Evolutionary Multi-objective Instruction Optimization via Large Language Model-based Instruction Operators

CIKM 2023 H Yang, K Li. PyABSA: A Modularized Framework for Reproducible Aspect-based Sentiment Analysis

IEEE Trans. Softw. Eng. K Li, H Yang, W Visser. Evolutionary Multi-Task Injection Testing on Web Application Firewalls

J Supercomput B Zeng, H Yang, S Liu, M Xu. Learning for target-dependent sentiment based on local context-aware embedding

Neurocomputing H Yang, B Zeng, JH Yang, Y Song, R Xu. A multi-task learning model for Chinese-oriented aspect polarity classification and aspect term extraction

H Yang, K Li. Reactive Perturbation Defocusing for Textual Adversarial Defense (Preprint 2023)

B Zeng, H Yang, R Xu, W Zhou, X Han. LCF: A local context focus mechanism for aspect-based sentiment classification (Applied Sciences 2019).

K Li is my PhD's supervisor. B Zeng was my master's supervisor.

Co-authored Publications

Neurocomputing M Xu, B Zeng, H Yang, J Chi, J Chen, H Liu. Combining dynamic local context focus and dependency cluster attention for aspect-level sentiment classification

Contributions on Huggingface:

Online Demos on Huggingface Space

Pretrained Models on Huggingface Space

Open-source Repositories

Community Contribution

yangheng95

yangheng95

lcf-atepc's People

Contributors

yangheng95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lcf-atepc's Issues

你好,我试验了你们的这个多任务学习模型,有一些问题想请教。

模型在预测时候,对于方面Aspect term的抽取效果很好,但是对于语句话如果有多个aspect,且他们情感极性相反时,他的预测情感极性就会出错。我实验了很多次。比如我输入的测试句子明显带有正负向的情感倾向,如'the staff was so nice to us ,But the service was bad ',他返回的一直都是同一个情感倾向: 'aspect': ['staff', 'service'] ;'sentiment': ['Negative', 'Negative']。除了我自己训练的模型,你们预训练好的模型我也试过,针对这种情况很难预测出一句话包含多个aspect且有相反情感极性的句子。请问这个问题如何解决。
AA

The problem of the training on new dataset

Hello, I have prepared the data set according to your format, related codes: for example, the path of the data set has been modified, why can't I train it?

Error:Traceback (most recent call last):
File "train.py", line 359, in
apc_test_acc, apc_test_f1, ate_test_f1 = main(config)
File "train.py", line 95, in main
train_examples = processor.get_train_examples(args.data_dir)
File "/home/xiaojia/lcf/utils/data_utils.py", line 109, in get_train_examples
self._read_tsv(os.path.join(data_dir, "car.atepc.train.dat")), "train")
File "/home/xiaojia/lcf/utils/data_utils.py", line 90, in _read_tsv
return readfile(input_file)
File "/home/xiaojia/lcf/utils/data_utils.py", line 65, in readfile
polarity.append(int(splits[-1][:-1]))
ValueError: invalid literal for int() with base 10: ''

My data format:
位 B-ASP 2
置 I-ASP 2
上 O -1
合 O -1
最 O -1
佳 O -1
中 O -1
心 O -1
位 O -1
置 O -1

关于数据转换。

您好,我想做方面术语提取任务、想知道您的atepc- dataset格式是怎么转换的,应该看哪个py文件呢

关于模型的预测的疑问

模型预测的时候,只能获得tokens, 所以训练过程中的一些mask/weight参数无法计算,包括:

  • valid_ids
  • context dynamic mask
  • context dynamic weight

所以,在预测阶段,上述这些参数valid_ids默认全部为1cdmcdw默认为0

另外,因为预测阶段不能预先知道Aspect Term,所以数据也没办法处理成SPC的格式 [CLS] + tokens + [SEP] + aspect + [SEP],只能处理成默认的输入[CLS] + tokens + [SEP]。这个输入同时送到 Local Context Exractor 和 Global Context Extractor。

这样理解对吗?

关于valid_ids的疑问

请问valid_ids代表什么呢?我看代码只是起到一个masking的作用。但是看数据处理的逻辑,valid_ids基本上都是1,那么这种情况下它的作用是什么呢?

一个句子包含多个Aspect和情感极性的情况

我看代码实现,一个训练样本对应一个polarity类别。也就是说只能对一个aspect进行极性分类。如果一个句子中有多个aspect,每个aspect都有不同的情感极性,那么本模型是无法处理的对吗?

为什么CDM/CDW之后的MHSA层没有实现?

在lcf_atepc.py的171-174行:

 if 'cdm' in self.args.local_context_focus:
                cdm_vec = self.feature_dynamic_mask(local_context_ids, polarities)
                cdm_context_out = torch.mul(local_context_out, cdm_vec)
                cat_out = torch.cat((global_context_out, cdm_context_out), dim=-1)

if下的三行代码:

  1. 生成feature masking matrix
  2. cdm_vec与bert的输出local_context_out对应位置相乘
  3. 拼接cdm_context_out和global_context_out

第2步之后按照paper不是还有一个MHSA层吗(如下图),想问一下为什么代码里没有实现?谢谢。
微信截图_20200304144959

只有cpu可以训练吗?

你好,由于实验室设备有限,如果可以使用cu训练的话,需要改哪些地方。
只用cpu来跑通与调试程序,

想请教关于data_utils.py的

image

  1. 这个地方为什么会有一个if 判断?
  2. valid是在存什么呢?

image

  1. 这个地方为什么是max_seq_length-1 和 -2

image
这三个while为什么分开写呢?

感谢回答! 问题可能有点蠢,但是我确实没看明白,望不吝赐教[抱拳]

有领域类训练好的中英文的模型吗

bert_for_global_context-base-chinese等等模型,已经代码中的bert-base-uncased,bert-base-chinese等等模型是直接使用的Google训练好的还是自己bert-aoa中说的领域内训练的模型

pip install -U pyabsa问题

您好,为什么我在操作pip install -U pyabsa时一直报错:
ERROR: Command errored out with exit status 1:
command: /home/anaconda3/bin/python /home/anaconda3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-h286negy/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'cython>=0.25,<3.0' 'cymem>=2.0.2,<2.1.0' 'preshed>=3.0.2,<3.1.0' 'murmurhash>=0.28.0,<1.1.0' 'thinc>=8.0.7,<8.1.0' 'blis>=0.4.0,<0.8.0' pathy 'numpy>=1.15.0'
cwd: None
Complete output (125 lines):
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/a2/e1/902fbc2f61ad6243cd3d57ffa195a9eb123021ec912ec5d811acf54a39f8/setuptools-57.1.0-py3-none-any.whl
Collecting cython<3.0,>=0.25
Downloading https://files.pythonhosted.org/packages/3d/48/bbca549da0b0f636c0f161e84d30172c40aafe99552680f297da7fedf102/Cython-0.29.24-cp37-cp37m-manylinux1_x86_64.whl (2.0MB)
Collecting cymem<2.1.0,>=2.0.2
Collecting preshed<3.1.0,>=3.0.2
Using cached https://files.pythonhosted.org/packages/af/6e/0605ffc1c3861cce4d029a9724f302232f993fe9d0dc6c04fb7bc49b7852/preshed-3.0.5-cp37-cp37m-manylinux1_x86_64.whl
Collecting murmurhash<1.1.0,>=0.28.0
Using cached https://files.pythonhosted.org/packages/08/82/917eb137b3e85060e4f7c8dc991fccfafb47aa1f6f59fdd63f406159b03e/murmurhash-1.0.5-cp37-cp37m-manylinux1_x86_64.whl
Collecting thinc<8.1.0,>=8.0.7
Using cached https://files.pythonhosted.org/packages/dc/09/ec156380f339942a576887fc07ba367080386d2e5166ef70883138da8f4d/thinc-8.0.7.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /home/anaconda3/bin/python /home/anaconda3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6cn30opu/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'cython>=0.25,<3.0' 'murmurhash>=0.28.0,<1.1.0' 'cymem>=2.0.2,<2.1.0' 'preshed>=3.0.2,<3.1.0' 'blis>=0.4.0,<0.8.0' 'numpy>=1.15.0'
cwd: None
Complete output (106 lines):
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/a2/e1/902fbc2f61ad6243cd3d57ffa195a9eb123021ec912ec5d811acf54a39f8/setuptools-57.1.0-py3-none-any.whl
Collecting cython<3.0,>=0.25
Using cached https://files.pythonhosted.org/packages/3d/48/bbca549da0b0f636c0f161e84d30172c40aafe99552680f297da7fedf102/Cython-0.29.24-cp37-cp37m-manylinux1_x86_64.whl
Collecting murmurhash<1.1.0,>=0.28.0
Using cached https://files.pythonhosted.org/packages/08/82/917eb137b3e85060e4f7c8dc991fccfafb47aa1f6f59fdd63f406159b03e/murmurhash-1.0.5-cp37-cp37m-manylinux1_x86_64.whl
Collecting cymem<2.1.0,>=2.0.2
Collecting preshed<3.1.0,>=3.0.2
Using cached https://files.pythonhosted.org/packages/af/6e/0605ffc1c3861cce4d029a9724f302232f993fe9d0dc6c04fb7bc49b7852/preshed-3.0.5-cp37-cp37m-manylinux1_x86_64.whl
Collecting blis<0.8.0,>=0.4.0
Using cached https://files.pythonhosted.org/packages/b1/54/b0de9905ee80aebd64c333bc112cacfe06849a9b5a7230a02dfde73e7aad/blis-0.7.4.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Collecting numpy>=1.15.0
Using cached https://files.pythonhosted.org/packages/3f/03/c3526fb4e79a793498829ca570f2f868204ad9a8040afcd72d82a8f121db/numpy-1.21.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Building wheels for collected packages: blis
Building wheel for blis (PEP 517): started
Building wheel for blis (PEP 517): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /home/anaconda3/bin/python /home/anaconda3/lib/python3.7/site-packages/pip/_vendor/pep517/in_process.py build_wheel /tmp/tmp3na18tlb
cwd: /tmp/pip-install-xny4m0tf/blis
Complete output (73 lines):
BLIS_COMPILER? None
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/blis
copying blis/init.py -> build/lib.linux-x86_64-3.7/blis
copying blis/about.py -> build/lib.linux-x86_64-3.7/blis
copying blis/benchmark.py -> build/lib.linux-x86_64-3.7/blis
creating build/lib.linux-x86_64-3.7/blis/tests
copying blis/tests/init.py -> build/lib.linux-x86_64-3.7/blis/tests
copying blis/tests/common.py -> build/lib.linux-x86_64-3.7/blis/tests
copying blis/tests/test_dotv.py -> build/lib.linux-x86_64-3.7/blis/tests
copying blis/tests/test_gemm.py -> build/lib.linux-x86_64-3.7/blis/tests
copying blis/cy.pyx -> build/lib.linux-x86_64-3.7/blis
copying blis/py.pyx -> build/lib.linux-x86_64-3.7/blis
copying blis/init.pxd -> build/lib.linux-x86_64-3.7/blis
copying blis/cy.pxd -> build/lib.linux-x86_64-3.7/blis
running build_ext
gcc: error: unrecognized command line option ‘-fopenmp-simd’
Build options linux unix
BUILD ARCH: generic
{'NVM_DIR': '/home/matt/.nvm', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.zst=01;31:.tzst=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.wim=01;31:.swm=01;31:.dwm=01;31:.esd=01;31:.jpg=01;35:.jpeg=01;35:.mjpg=01;35:.mjpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.m4a=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.oga=00;36:.opus=00;36:.spx=00;36:.xspf=00;36:', 'HOSTTYPE': 'x86_64', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'LANG': 'C.UTF-8', 'OLDPWD': '/home/matt/repos/explosion/cython-blis-v0.7', 'NVM_CD_FLAGS': '', 'WSL_DISTRO_NAME': 'Ubuntu', 'VIRTUAL_ENV': '/home/matt/repos/explosion/spaCy/env3.8', 'USER': 'matt', 'PWD': '/home/matt/repos/explosion/cython-blis-v0.7/flame-blis', 'HOME': '/home/matt', 'NAME': 'LAPTOP-OMKOB3VM', 'XDG_DATA_DIRS': '/usr/local/share:/usr/share:/var/lib/snapd/desktop', 'TERM': 'xterm-256color', 'SHELL': '/bin/bash', 'NVM_BIN': '/home/matt/.nvm/versions/node/v10.15.3/bin', 'SHLVL': '2', 'PYTHONPATH': '/home/matt/repos/explosion/cython-blis-v0.7', 'LOGNAME': 'matt', 'PATH': '/home/matt/repos/explosion/spaCy/env3.8/bin:/home/matt/.nvm/versions/node/v10.15.3/bin:/tmp/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Users/matt/Documents/cmder/vendor/conemu-maximus5/ConEmu/Scripts:/mnt/c/Users/matt/Documents/cmder/vendor/conemu-maximus5:/mnt/c/Users/matt/Documents/cmder/vendor/conemu-maximus5/ConEmu:/mnt/c/Python37/Scripts/:/mnt/c/Python37/:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS/:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/LLVM/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/Intel/WiFi/bin/:/mnt/c/Program Files/Common Files/Intel/WirelessCommon/:/mnt/c/Users/matt/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/matt/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/matt/AppData/Roaming/npm:/snap/bin', 'NVM_INC': '/home/matt/.nvm/versions/node/v10.15.3/include/node', 'WSLENV': '', 'LESSOPEN': '| /usr/bin/lesspipe %s', '
': '/home/matt/repos/explosion/spaCy/env3.8/bin/python'}
[COMMAND] gcc -c /tmp/pip-install-xny4m0tf/blis/blis/_src/config/generic/bli_cntx_init_generic.c -o /tmp/tmpwe_b8pqk/bli_cntx_init_generic.o -O3 -fPIC -std=c99 -fvisibility=hidden -D_POSIX_C_SOURCE=200112L -DBLIS_VERSION_STRING="0.7.0" -DBLIS_IS_BUILDING_LIBRARY -Iinclude/linux-generic -I./frame/3/ -I./frame/ind/ukernels/ -I./frame/3/ -I./frame/1m/ -I./frame/1f/ -I./frame/1/ -I./frame/include -I/tmp/pip-install-xny4m0tf/blis/blis/_src/include/linux-generic
[COMMAND] gcc -c /tmp/pip-install-xny4m0tf/blis/blis/_src/ref_kernels/bli_cntx_ref.c -o /tmp/tmpwe_b8pqk/bli_cntx_generic_ref.o -O3 -fPIC -std=c99 -fvisibility=hidden -D_POSIX_C_SOURCE=200112L -DBLIS_VERSION_STRING="0.7.0" -DBLIS_CNAME=generic -DBLIS_IS_BUILDING_LIBRARY -Iinclude/linux-generic -I./frame/3/ -I./frame/ind/ukernels/ -I./frame/3/ -I./frame/1m/ -I./frame/1f/ -I./frame/1/ -I./frame/include -I/tmp/pip-install-xny4m0tf/blis/blis/_src/include/linux-generic
[COMMAND] gcc -c /tmp/pip-install-xny4m0tf/blis/blis/_src/ref_kernels/1/bli_addv_ref.c -o /tmp/tmpwe_b8pqk/bli_addv_generic_ref.o -O3 -funsafe-math-optimizations -ffp-contract=fast -fPIC -std=c99 -fopenmp-simd -fvisibility=hidden -D_POSIX_C_SOURCE=200112L -DBLIS_VERSION_STRING="0.7.0" -DBLIS_CNAME=generic -DBLIS_IS_BUILDING_LIBRARY -Iinclude/linux-generic -I./frame/3/ -I./frame/ind/ukernels/ -I./frame/3/ -I./frame/1m/ -I./frame/1f/ -I./frame/1/ -I./frame/include -I/tmp/pip-install-xny4m0tf/blis/blis/_src/include/linux-generic
Traceback (most recent call last):
File "/home/anaconda3/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in
main()
File "/home/anaconda3/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/anaconda3/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 141, in build_wheel
metadata_directory)
File "/tmp/pip-build-env-6vo0xr6r/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 222, in build_wheel
wheel_directory, config_settings)
File "/tmp/pip-build-env-6vo0xr6r/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 207, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-6vo0xr6r/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, file, 'exec'), locals())
File "setup.py", line 327, in
"Topic :: Scientific/Engineering",
File "/tmp/pip-build-env-6vo0xr6r/overlay/lib/python3.7/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/home/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-6vo0xr6r/normal/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/home/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/anaconda3/lib/python3.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "setup.py", line 105, in build_extensions
objects = self.compile_objects(platform_name, arch, OBJ_DIR)
File "setup.py", line 221, in compile_objects
objects.append(self.build_object(env=env, **spec))
File "setup.py", line 235, in build_object
subprocess.check_call(command, cwd=BLIS_DIR)
File "/home/anaconda3/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gcc', '-c', '/tmp/pip-install-xny4m0tf/blis/blis/_src/ref_kernels/1/bli_addv_ref.c', '-o', '/tmp/tmpwe_b8pqk/bli_addv_generic_ref.o', '-O3', '-funsafe-math-optimizations', '-ffp-contract=fast', '-fPIC', '-std=c99', '-fopenmp-simd', '-fvisibility=hidden', '-D_POSIX_C_SOURCE=200112L', '-DBLIS_VERSION_STRING="0.7.0"', '-DBLIS_CNAME=generic', '-DBLIS_IS_BUILDING_LIBRARY', '-Iinclude/linux-generic', '-I./frame/3/', '-I./frame/ind/ukernels/', '-I./frame/3/', '-I./frame/1m/', '-I./frame/1f/', '-I./frame/1/', '-I./frame/include', '-I/tmp/pip-install-xny4m0tf/blis/blis/_src/include/linux-generic']' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for blis
Running setup.py clean for blis
Failed to build blis
ERROR: Could not build wheels for blis which use PEP 517 and cannot be installed directly
----------------------------------------
ERROR: Command errored out with exit status 1: /home/anaconda3/bin/python /home/anaconda3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6cn30opu/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'cython>=0.25,<3.0' 'murmurhash>=0.28.0,<1.1.0' 'cymem>=2.0.2,<2.1.0' 'preshed>=3.0.2,<3.1.0' 'blis>=0.4.0,<0.8.0' 'numpy>=1.15.0' Check the logs for full command output.

ERROR: Command errored out with exit status 1: /home/anaconda3/bin/python /home/anaconda3/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-h286negy/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'cython>=0.25,<3.0' 'cymem>=2.0.2,<2.1.0' 'preshed>=3.0.2,<3.1.0' 'murmurhash>=0.28.0,<1.1.0' 'thinc>=8.0.7,<8.1.0' 'blis>=0.4.0,<0.8.0' pathy 'numpy>=1.15.0' Check the logs for full command output.

def get_ids_for_local_context_extractor

Hi
Thanks a lot for sharing this work
I have Question, please
I do not understand this function("def get_ids_for_local_context_extractor(self, text_indices): ") and how it works??
and why you use ==102 in this line and 5 in get labels function
" sep_index = np.argmax((text_ids[text_i] == 102)"

"def get_ids_for_local_context_extractor(self, text_indices): # convert BERT-SPC input to BERT-BASE format text_ids = text_indices.detach().cpu().numpy() for text_i in range(len(text_ids)): sep_index = np.argmax((text_ids[text_i] == 102)) text_ids[text_i][sep_index + 1:] = 0 return torch.tensor(text_ids).to(self.args.device)"

Regrad loss function

Hello
the loss function in this work for multi-task learning (loss = loss_ate + loss_apc) if I want to find just aspect polarity using SPC , should I change the loss function to loss= loss_apc??
Also if I wand find just aspect term the loss function will be changed into loss= loss_ate?
Thnaks

dataset

Hi,

could u give us a description about the dataset format?

thank u

Possible error in the project code?

Hello.

Thanks fot your work.

In your article (https://arxiv.org/pdf/1912.07976v1.pdf) you talk about that you have a different inputs (Figure 5) for 2 models.

But, in fact, there is only one input: [CLS] token_0 token_1 ... token_i [SEP] aspect tokens [SEP] (https://github.com/yangheng95/LCF-ATEPC/blob/master/utils/data_utils.py#L183), because, in this method only text_a was used.

It's a very strange, it turns out that you pass to ATE model information about tokens, which have target classes: [CLS] token_0 token_1 ... token_i [SEP] --> aspect tokens [SEP] <-- I talking about this part.

There are no any masking: https://github.com/yangheng95/LCF-ATEPC/blob/master/model/lcf_atepc.py#L126 attention_mask is input_mask, which mark non-padding postions with 1.

Thus, it becomes clear why only a linear classifier + bert outputs gives such high quality.

We can go further. Suppose we wanted to apply a trained ATE model to new data. We do not know the terms. Therefore, we simply duplicate the sequence itself. Example: [CLS] The bread is top notch as well . [SEP ] The bread is top notch as well . [SEP] If you do this on test data, you will see that quality is not 99% :(

Is it possible that I'm wrong?

跑不出论文的最佳效果

Yang Heng:

您好!

我尝试直接运行改项目的代码,使用huggingface提供的bert-case-uncased预训练模型,不管是有没有使用bert-spc,在SemEval-14两个数据集上都无法达到论文中的最佳效果。

使用bert-base(laptop):
image

使用bert-spc(laptop):
image

请问是有其他需要注意的事项吗?

盼回复,万分感谢!

请教关于lcf_atepc.py相关细节?

def forward(self, input_ids_spc, token_type_ids=None, attention_mask=None, labels=None, polarities=None, valid_ids=None, attention_mask_label=None):

    if not self.args.use_bert_spc:  # args.use_bert_spc=false
        input_ids_spc = self.get_ids_for_local_context_extractor(input_ids_spc)
        labels = self.get_batch_token_labels_bert_base_indices(labels)

    global_context_out, _ = self.bert(input_ids_spc, token_type_ids, attention_mask)  
    polarity_labels = self.get_batch_polarities(polarities)  

问题1:
use_bert_spc = False,已经将convert BERT-SPC input to BERT-BASE format,如果一个句子包含了多个aspect,但是 BERT-BASE format得到的句子表示都是一样的,在ATE任务时,怎么区分出不同的aspect?
self.bert(input_ids_spc, token_type_ids, attention_mask)
但是此处的token_type_ids, attention_mask,并没有做任何修改,可以在计算attention的时候包含了第一个[SEP]后面的aspect的信息? 可以这么理解吗?,

问题2:
readme.md中,BERT-SPC不能被用于训练和测试ATE任务,这句话怎么理解?

问题3:
在做ATE任务的时候 ,为什么labels=["O", "B-ASP", "I-ASP", "[CLS]", "[SEP]"],为什么要加上cls和sep? 以及为什么num_labels = len(label_list) + 1 不太理解?

问题4:
report = classification_report(y_true, y_pred, digits=4)
tmps = report.split()
ate_result = round(float(tmps[7]) * 100, 2)

report 是各个类别评价指标,这里为什么只取tmps[7])?只取第一个类别? 这段代码该怎么理解?
不好意思,我看错了 from seqeval.metrics 这个函数直接算的就是f1?

问题有点多,还请不吝赐教!
谢谢啦

求加一个推断的例子

convert_examples_to_features.py 202行,在将example转feature的时候,需要知道当前句子的aspect。
但是在推断的时候,是不知道aspect是什么的,难道说推断的时候需要分两阶段运行?先跑ate任务,再跑apc任务?
希望作者加一个推断的示例函数,谢谢

BERT-SPC model.

In original paper https://arxiv.org/pdf/1902.09314.pdf results of BERT-SPC model on restaurants (senteval2014, subtask 2) are: acc=0.8446, f1_marco=0.7698.

But in your work I see results: acc=85.54. f1_macro=79.19.

Can you explain this, please?

pool function

Hi,

First, thank u for sharing ur code with us. Could u please tell me why did you use the pool function before the output

Screen Shot 2023-01-18 at 6 15 03 AM

Many thanks in advance

Regard Dataset

Hello
in the restaurant dataset, I find 4 tags for B-ASP and I-ASP I understand that 0 is negative, -1 is natural, 2 is positive what about 1
such as Food B-ASP 1?
and why camera dataset has just 3 labels 0 , -1, and 2?
to reformat my dataset (semeval 2016) in another language what should I follow?

Hello, how can I solve this problem? thank you very much

File "D:\my_python\LCF-ATEPC\utils\Pytorch_GPUManager.py", line 33, in
to_numberic = lambda v: float(v.upper().strip("\t").replace('MIB', '').replace('W', '')) # 带单位字符串去掉单位
ValueError: could not convert string to float: ' [N/A]'

怎样加载模型预测单条语句?

楼主您好!我在加载训练好的模型用于预测时,出现了如下的报错,还请您指点一二:

from model.lcf_atepc import LCF_ATEPC
from pytorch_transformers.tokenization_bert import BertTokenizer
from pytorch_transformers.modeling_bert import BertModel,BertConfig,BertForTokenClassification

args = {'dropout':0,
        'device':'cuda',
        'use_unique_bert':True,
        'SRD':5,
        'max_seq_length':80,
        'use_bert_spc':False,
        'local_context_focus':"fusion"
           }


bert_model = r'output\laptop_fusion_apcacc_74.53_apcf1_67.79_atef1_79.97'

tokenizer = BertTokenizer.from_pretrained(bert_model, do_lower_case=True)
    
bert_base_model = BertForTokenClassification.from_pretrained(bert_model)

model = LCF_ATEPC.from_pretrained(bert_model, args=args)

RuntimeError Traceback (most recent call last)
in
3 tokenizer = BertTokenizer.from_pretrained(bert_model, do_lower_case=True)
4
----> 5 bert_base_model = BertForTokenClassification.from_pretrained(bert_model)

d:\anaconda20190415\lib\site-packages\pytorch_transformers\modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
534
535 # Instantiate model.
--> 536 model = cls(config, *model_args, **model_kwargs)
537
538 if state_dict is None and not from_tf:

d:\anaconda20190415\lib\site-packages\pytorch_transformers\modeling_bert.py in init(self, config)
1124 self.num_labels = config.num_labels
1125
-> 1126 self.bert = BertModel(config)
1127 self.dropout = nn.Dropout(config.hidden_dropout_prob)
1128 self.classifier = nn.Linear(config.hidden_size, config.num_labels)

d:\anaconda20190415\lib\site-packages\pytorch_transformers\modeling_bert.py in init(self, config)
649 super(BertModel, self).init(config)
650
--> 651 self.embeddings = BertEmbeddings(config)
652 self.encoder = BertEncoder(config)
653 self.pooler = BertPooler(config)

d:\anaconda20190415\lib\site-packages\pytorch_transformers\modeling_bert.py in init(self, config)
232 def init(self, config):
233 super(BertEmbeddings, self).init()
--> 234 self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=0)
235 self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size)
236 self.token_type_embeddings = nn.Embedding(config.type_vocab_size, config.hidden_size)

~\AppData\Roaming\Python\Python36\site-packages\torch\nn\modules\sparse.py in init(self, num_embeddings, embedding_dim, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse, _weight)
107 self.scale_grad_by_freq = scale_grad_by_freq
108 if _weight is None:
--> 109 self.weight = Parameter(torch.Tensor(num_embeddings, embedding_dim))
110 self.reset_parameters()
111 else:

RuntimeError: Trying to create tensor with negative dimension -1: [-1, 768]

请问,我该如何正确的加载训练好的模型?谢谢!

LCF-ATEPC for AE and APC

Hi,

based on the results, described in the paper, this model works better for both ATE and APC, compared to the LCF-BERT.

I would like to know if it's possible to use this model for ATE for a new dataset. We have a gold dataset for cellphone and we want to see how this model performs. Do you have any idea how to use the trained model for new data points?

Best,
Vahid

关于aspect term抽取的问题

您好,对论文有些不太明白。BERT-SPC Input输入已经包含了aspect term,为什么还要抽取aspect term?还是只是为了辅助极性的抽取?这篇文章做的是aspect term和polarity的联合抽取嘛?谢谢

AE affects APC

Hi,

thank u for sharing ur code with us. As I understand, the results of APC are affected by those of AE aren t they ?
you use the extracted aspect terms to identify the sentiment polarities instead of using gold terms but what if the results of AE are very low and they hardly affect the APC performance?

Thank u

数据集标签问题

你好,兄弟。数据集极性为什么会有 {0,-1, 1, 2}这四种类别,我想知道分别表示什么? 还有为什么 非aspect的单词也有极性标签标注?感谢你的回答。

训练模型数据转换错误

image

1.数据集转换失败
Quick Start 中 Convert APC datasets to ATEPC datasets
执行失败:其中convert_apc_set_to_atepc未能成功导入。找了一下pyabsa 未找到
from pyabsa import convert_apc_set_to_atepc

convert_apc_set_to_atepc(r'../apc_usages/datasets/restaurant16')
2.此外 以下 train_atepc 方法也未找到
from pyabsa import train_atepc

see hyper-parameters in pyabsa/main/training_configs.py

evaluation

Hello
Please, I need to print recall and precision in the output.
also get the confusion matrix
could help me, please?

LCF

hello

I am confused about the words which are considered in the local context of the aspect? it based only on the index/position or do you use MHSA to choose the more relative word in semantic, not only based on the index/position? for example if the SRD= 5 the local context is Only five adjacent words
hope my Q is clear
thank in advance

Evaluation

I have question related to evaluation, why you evaluate the model for every 20 steps?
Also, what is the difference in each train (seed from1-5)? what happened on each train?

predicited lable

Hello
How can I print the original label and predicted labels?
Thanks

掩码长度问题

作者您好,在运行evaluate代码时,发现掩码长度和输入不一致的问题,举个例子如下:
输入:而 且 操 作 容 易 掌 握 8个字
input_ids_spc=tensor([[ 101],[5445],[ 684],[3082],[ 868],[2159],[3211],[2958],[2995],[ 102],[0]...] 排除0,10个字
attention_mask=tensor([[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[0]...],排除0,13个字,
这里13个字是因为对 “而且操作容易掌握[SEP]操作”做了掩码操作。
global_context_out = self.bert_for_global_context(input_ids_spc, token_type_ids, attention_mask)['last_hidden_state']

这里有个疑问,在预测ate的时候,我是不知道“操作”这个词要被预测出来的,多加了三个字([SEP]操作)的掩码,这里是不是有信息泄露的嫌疑?我试着将掩码改回10个,并测试了camera数据集,发现性能下降很多:
改之前指标为:
{'max_apc_test_acc': 94.25, 'max_apc_test_f1': 92.71}
atef1:86.55
改之后指标为:
{'max_apc_test_acc': 94.25, 'max_apc_test_f1': 92.71}
atef1:41.03

atef1下降了很多。
是我的理解有什么问题吗?
期待您的回复。

请教关于data_utils.py的若干问题

for m in range(len(token)):
if m == 0:
labels.append(label_1)
polarities.append(polarity_1)
valid.append(1)
label_mask.append(1)
else:
valid.append(0)

  1. 这个地方为什么会有一个if 判断?
  2. valid是在存什么呢?

if len(tokens) >= max_seq_length - 1:
tokens = tokens[0:(max_seq_length - 2)] # num = max_seq_length-2
polarities = polarities[0:(max_seq_length - 2)]
labels = labels[0:(max_seq_length - 2)]
valid = valid[0:(max_seq_length - 2)]
label_mask = label_mask[0:(max_seq_length - 2)]

  1. 这个地方为什么是max_seq_length-1 和 -2

while len(input_ids_spc) < max_seq_length:
input_ids_spc.append(0)
input_mask.append(0)
segment_ids.append(0)
label_ids.append(0)
valid.append(1)
label_mask.append(0)

while len(label_ids) < max_seq_length:
label_ids.append(0)
label_mask.append(0)

while len(polarities) < max_seq_length:
polarities.append(-1)
这三个while为什么分开写呢?

感谢回答! 问题可能有点蠢,但是我确实没看明白,望不吝赐教[抱拳]

cross validation

Hi
I need to use cross-validation. in which part of the code can I modify?

用我的数据集做预测时,遇到了一个问题

我有一个只有正负情感标注的数据集,在模型预测情感时常常结果完全相反:
image
正向的句子argmax后结果总是0(负向),而负向的结果总是1,然而我的数据集正向的样本远多于负向。

列举几个改动:
数据标注:
image
同中文的几个数据集,做0/2标注。训练测试八二分,训练行数33w行左右。

模型保存与加载:
image
image

预测输出:
image

在用公开数据集的时候,预测结果比较正常,然而换成我自己的数据集,情感预测非常不正常。困扰了几天,没想出来是哪里出了问题,请教您一下。

关于中文数据集

您好,请问您对于中文数据集是怎么样进行训练集和测试集的划分的?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.