Sachin19 / mucoco

Official Code for the papers: "Controlled Text Generation as Continuous Optimization with Multiple Constraints" and "Gradient-based Constrained Sampling from LMs"
MIT License
59 stars 5 forks source link

Conda environment related issue #5

Closed hayleyson closed 1 year ago

hayleyson commented 1 year ago

Hi @Sachin19! Thank you for sharing the code for your exciting work!

I was trying to create conda environment following the readme file, and the environment creation would fail due to package version conflicts. Could you please check if the issue occurs in your setting as well?

Here are some settings I've been creating environment at:

Operating System: Ubuntu 20.04.4 LTS Kernel: Linux 5.4.0-100-generic Architecture: x86-64 Python 3.9.12 conda version 23.1.0

Here is a screenshot of intermediate outputs I got while waiting for the environment to be created. After several attempts to resolve conflicts after this, the whole creation process aborted. Screen Shot 2023-02-26 at 2 01 19 AM

Thank you in advance!

Sachin19 commented 1 year ago

Hi Hayley, I hope you were able to resolve this issue since I saw you have a pull request.

It is not clear to me what the issue is from this log. One suggestion I would make is to specify the python version to be 3.8. I have had some versioning issues with 3.9. I will update the readme to reflect this.

hayleyson commented 1 year ago

Hi @Sachin19! Sorry for the delay in my part! After seeing your response, I added python: 3.8 to the conda environment.yml file and retried but ran into the same version conflict error! :(

The way I went about "solving" this issue is below. It'd be helpful if you could see if the below way would be okay. (It did not cause overt errors, but I'm afraid I'm not correctly replicating your environment.)

I installed packages below in a Python 3.9.12 based virtual (conda) env. (conda ver: 23.1.0)

In terms of package versions, I quite arbitrarily specified versions based on environment.yml if I could find the versions there. And for transformers, I couldn't find it in the file, so I just specified the minimum version from your readme file. Thanks again!

transformers>=4.5.1 # copied from github
torch==1.11.0 # copied from environment.yml
sacrebleu==1.5.1 # copied from environment.yml
sacremoses==0.0.47 # copied from environment.yml
sacrerouge==0.2.3 # copied from environment.yml
sentence-transformers # <- added on 17/03/23 after running decoding script
bot # <- added on 17/03/23 after running decoding script
google-api-python-client # <- added on 17/03/23 after running decoding script
nltk
perspective
click
pandas
pytreebank

edited on 17/03/23

Sachin, I got past the classification training part, and upon running decoding script, ran into this error. There wasn't a package named "perspective_api" in your environment yaml, so I found this script after googling. Is this the right way to fix this problem? If so, I think you should add the script in the repository. If not, please let me know!

Traceback (most recent call last):
  File "/home/hayley/mucoco/./evaluation/prompted_sampling/evaluate.py", line 25, in <module>
    from perspective_api import PerspectiveWorker, unpack_scores
ModuleNotFoundError: No module named 'perspective_api'
Sachin19 commented 1 year ago

Hi Hayley,

Apologies about the versioning and library issues, I will update the README today to reflect the missing libraries.

As per your update: You can comment out line 25, it is part of an older version of the code that is not used anymore. However, you do need to make an account on Perspective API and get an API key to evaluate the generated outputs' toxicity. You can find those instructions here: https://developers.google.com/codelabs/setup-perspective-api#0 and then add the API key in line 753 of evaluation/prompted_sampling/evaluate.py.

hayleyson commented 1 year ago

Sachin, Thanks for the quick response! I will look into the solution you suggested. (Applied for the perspective API and waiting for the reply!)

hayleyson commented 1 year ago

I tried the way you suggested (inserting API key) and it worked! Thanks for your help. :)