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

Adaptation of LM_scoring.py #186

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

anthdr
Copy link

@anthdr anthdr commented Jan 15, 2025

The LM_scoring.py script returns an error when called:

Traceback (most recent call last):
  File "/nas-labs/MT/pytorchwork/Recipes/toy-antoine/eole/eole/bin/main.py", line 38, in <module>
    main()
  File "/nas-labs/MT/pytorchwork/Recipes/toy-antoine/eole/eole/bin/main.py", line 34, in main
    bin_cls.run(args)
  File "/nas-labs/MT/pytorchwork/Recipes/toy-antoine/eole/eole/bin/tools/LM_scoring.py", line 68, in run
    config = PredictConfig(**config)
  File "/usr/local/lib/python3.10/dist-packages/pydantic/main.py", line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 3 validation errors for PredictConfig
bin
  Extra inputs are not permitted [type=extra_forbidden, input_value='tools', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden
sub_bin
  Extra inputs are not permitted [type=extra_forbidden, input_value='LM_scoring', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden
config
  Extra inputs are not permitted [type=extra_forbidden, input_value='inference.yaml', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/extra_forbidden

(config.update(stuff_to_update) adds {'bin': 'tools', 'sub_bin': 'LM_scoring', 'config': 'inference.yaml'} which are unnecessary args for scoring)

I adapted the loading of the model, the vocab new logic and the computation of the loss as well.
To test it, I'm using a LM built with the wiki-103 recipe, I only changed training data (https://github.com/eole-nlp/eole/blob/main/recipes/wiki_103/wiki_103.yaml)

@anthdr anthdr changed the title ppl is not exact yet Adaptation of LM_scoring.py Jan 15, 2025
@vince62s
Copy link
Contributor

you need to install last versions of black, flake8, pyproject-flake8 like here:
https://github.com/eole-nlp/eole/blob/main/.github/workflows/push.yml#L28-L35

@anthdr
Copy link
Author

anthdr commented Jan 17, 2025

I did not call the script correctly, there is an error when called properly (modified initial comment accordingly).
While this script needed adaptation (pad_token retrieval, lambda opts are now elsewhere in the config, loss function now returns estims), I had to also modify loss computation mainly because one expected dimension is not there anymore, which made me realize I maybe overgeneralized loss/ppl computation to the specific case of wiki103 type of model.
Should loss computation use reduction="sum" to handle tensors of different dimensions ?

reduction="sum",

Moreover, I do not replicate the valid perplexity observed in my training and I don't know why yet:
tensorboard: 20.9643 (3.0428 loss)
lm_scoring: 22.34 (3.11 loss)

@anthdr anthdr marked this pull request as draft January 17, 2025 17:31
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

Successfully merging this pull request may close these issues.

2 participants