facebookresearch / esm

Evolutionary Scale Modeling (esm): Pretrained language models for proteins
MIT License
3.16k stars 627 forks source link

fix a bug of undefined Alphabet.toks #106

Closed cutecutecat closed 3 years ago

cutecutecat commented 3 years ago

Fix error attribute 'toks' into 'standard_toks'

  File "/home/xxx/test_esm.py", line 11, in <module>
    print(model_alphabet.to_dict())
  File "/home/xxx/anaconda3/envs/fasthit/lib/python3.9/site-packages/fair_esm-0.3.1-py3.9.egg/esm/data.py", line 129, in to_dict
AttributeError: 'Alphabet' object has no attribute 'toks'
facebook-github-bot commented 3 years ago

Hi @cutecutecat!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

facebook-github-bot commented 3 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

tomsercu commented 3 years ago

Thanks for finding this and submitting a fix! But actually this method doesn't make too much sense and isn't used in the codebase, maybe you could instead replace it with returning the token to idx mapping: return self.tok_to_idx.copy() Thx!

cutecutecat commented 3 years ago

Thank you for your review! As I see, self.tok_to_idx is a map from all_toks, which equals prepend_toks+standard_toks. If we use self.tok_to_idx in to_dict, than from_dict can no longer get standard_toks. Therefore, it cannot work any more. I have searched in the project and ensured there is nowhere require Alphabet.from_dict. If from_dict is also deprecated as well? Can I remove from_dict together?

tomsercu commented 3 years ago

Ah now I see where you're coming from - yes you can remove both! Thank you!