bjascob / amrlib

A python library that makes AMR parsing, generation and visualization simple.
MIT License
216 stars 33 forks source link

Two questions for parse_xfm_bart_large #47

Closed 14H034160212 closed 2 years ago

14H034160212 commented 2 years ago

Hi,

I got one question for the reference paper for parse_xfm_bart_large. Can you post the reference paper for that? Many thanks. https://github.com/bjascob/amrlib-models#sentence-to-graph-models

The second question is I cannot load the parse_xfm_bart_large using stog = amrlib.load_stog_model("./models/model_parse_xfm_bart_large-v0_1_0"). I got the following error.

Traceback (most recent call last):
  File "/data/qbao775/amrlib/reclor_if_then_xfm_t5wtense.py", line 36, in <module>
    stog = amrlib.load_stog_model("./models/model_parse_xfm_bart_large-v0_1_0")
  File "/data/qbao775/amrlib/amrlib/__init__.py", line 35, in load_stog_model
    stog_model = load_inference_model(model_dir, **kwargs)
  File "/data/qbao775/amrlib/amrlib/models/model_factory.py", line 62, in load_inference_model
    model_class = dynamic_load(module_name=meta['inference_module'], class_name=meta['inference_class'])
  File "/data/qbao775/amrlib/amrlib/models/model_factory.py", line 13, in dynamic_load
    module = importlib.import_module(module_name, package=package)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'amrlib.models.parse_xfm'
bjascob commented 2 years ago

I didn't write papers for any of the models. If you're wondering how to cite it, just google for "How to site a GitHub Repo". Other papers that have used amrlib have simply posted a link to the repo as their reference.

The load above works fine for me. Be sure you're using the latest (version 0.7.x) code as parse_xfm was only added a few months ago (it subsumes the old models.parse_t5 code).

14H034160212 commented 2 years ago

Many thanks!

14H034160212 commented 2 years ago

I updated the amrlib package to 0.7.1, but it is still not working. I am using the following code to load the xfm model. Am I right?

import amrlib
stog = amrlib.load_stog_model("./models/model_parse_xfm_bart_large-v0_1_0")

Traceback (most recent call last):
  File "reclor_if_then_xfm_t5wtense.py", line 36, in <module>
    stog = amrlib.load_stog_model("./models/model_parse_xfm_bart_large-v0_1_0")
  File "/data/qbao775/amrlib/amrlib/__init__.py", line 35, in load_stog_model
    stog_model = load_inference_model(model_dir, **kwargs)
  File "/data/qbao775/amrlib/amrlib/models/model_factory.py", line 62, in load_inference_model
    model_class = dynamic_load(module_name=meta['inference_module'], class_name=meta['inference_class'])
  File "/data/qbao775/amrlib/amrlib/models/model_factory.py", line 13, in dynamic_load
    module = importlib.import_module(module_name, package=package)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'amrlib.models.parse_xfm'
bjascob commented 2 years ago

This works on my system (Ubuntu 20.04 / python 3.8). It could be something about dynamic module loading that's not working on your setup (let me know what OS/python/anaconda? you have). Try the following. It's equivalent to the above statement but manually specifies which Inference module to load instead of loading it dynamically based on the model meta-data...

from amrlib.models.parse_xfm.inference import Inference
stog = Inference("./models/model_parse_xfm_bart_large-v0_1_0")

If for some reason the import (first) line fails, you'll have to debug your installation to see why imports are failing. --> Based on the line number that's failing, it looks like you're using an older version of amrlib and not the 0.7.x release.

import amrlib
print(amrlib.__version__)
14H034160212 commented 2 years ago

I just downloaded the latest project and create a new virtual environment and it works now.