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

How to use it in Python script instead of shell script. #22

Open
mirfan899 opened this issue Jul 31, 2021 · 2 comments
Open

How to use it in Python script instead of shell script. #22

mirfan899 opened this issue Jul 31, 2021 · 2 comments

Comments

@mirfan899
Copy link

Is there a way to use the model in Python script. I'm trying to do it but having lots of errors with modules importing etc.

@mirfan899
Copy link
Author

I have run the predict.py script successfully. But it seems there is a bug in the predictor.
Here are parameters.

--data_path /home/irfan/PycharmProjects/disambiguate/model/model_wsd_train_sc_wngt_dev_random4000_clear_compress_bert_large_cased_transformer_2048_single --weights /home/irfan/PycharmProjects/disambiguate/model/model_wsd_train_sc_wngt_dev_random4000_clear_compress_bert_large_cased_transformer_2048_single/model_weights_wsd0

But when I type on the console and press enter it throws the following error.

he walked the dog

Traceback (most recent call last):
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predict.py", line 31, in <module>
    main()
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predict.py", line 27, in main
    predicter.predict(text)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 67, in predict
    self.predict_and_output(ensemble, batch_x, batch_z, self.data_config.input_clear_text)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 104, in predict_and_output
    batch_wsd = Predicter.generate_wsd_on_batch(output_wsd, batch_z)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 166, in generate_wsd_on_batch
    batch_wsd.append(Predicter.generate_wsd_on_sample(output[i], batch_z[0][i]))
IndexError: index 1 is out of bounds for dimension 0 with size 1

Process finished with exit code 1

@thornad
Copy link

thornad commented Feb 5, 2022

Same issue. How do I use it from Python to disambiguate a simple sentence like 'he walked the dog' ?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants