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

Cannot use trained model for validation or prediction #5

Open
khusainovaidar opened this issue Feb 15, 2022 · 5 comments
Open

Cannot use trained model for validation or prediction #5

khusainovaidar opened this issue Feb 15, 2022 · 5 comments

Comments

@khusainovaidar
Copy link

Hi, thank you for this repo! I'm trying to reproduce results for different language, so I'm using multilingual-bert fine-tuned to my language dataset.
Everything goes well during preprocessing and training, the resuls are comparable with those for English and French (97-99% for case and punctuation).

But when I try to use trained model, it gives very poor results even for sentences from training dataset. It works, sometimes it puts capital letters or dots, but it's rare and mostly model can't handle.
Also when I try to evaluate model with command from the README (also tried it for already used validation sets, for instance with command python recasepunc.py eval bertugan_casepunc.24000 valid.case+punc.x valid.case+punc.y) it gives error:

File "recasepunc.py", line 220, in batchify
x = x[:(len(x) // max_length) * max_length].reshape(-1, max_length)
TypeError: unhashable type: 'slice'

Sorry for pointing to two different problems in one Issue, but I though maybe it can be one common mistake for both cases.

@khusainovaidar
Copy link
Author

Seems that it must be this code for line 388 (with addition of punctuation label):

print(cased_token + punctuation_syms[punc_label], end='')

Maybe this is also the case for #3

@benob
Copy link
Owner

benob commented Feb 21, 2022

Thanks for reporting those issues.

For the first one, could you be more specific about the sequence of commands you have run and the data you used. Do you observe the same problem with the released models?

For the second one, the error is cryptic. It looks like x is not a tensor. Can you add a line with print(type(x)) or print(x) to check the type of x?

@caiolibanio
Copy link

caiolibanio commented Aug 9, 2022

For the second one, the error is cryptic. It looks like x is not a tensor. Can you add a line with print(type(x)) or print(x) to check the type of x?

Hello! Thanks for this repository! I'm facing the same issue when tying to evaluate the model. The code reports the error just like:
"...in batchify
x = x[:(len(x) // max_length) * max_length].reshape(-1, max_length)
TypeError: unhashable type: 'slice'"

When I print the "x", I've found that the x is of type <class 'dict'>. Any suggestions regarding this issue?
Thanks again!

@CoffeePerry
Copy link
Contributor

@khusainovaidar and @caiolibanio It could be an arguments order problem, try rewriting the command like this:

python recasepunc.py eval valid.case+punc.x valid.case+punc.y bertugan_casepunc.24000

If that works, please tell me so I fix the eval usage example into the file README.md.

@caiolibanio
Copy link

@khusainovaidar and @caiolibanio It could be an arguments order problem, try rewriting the command like this:

python recasepunc.py eval valid.case+punc.x valid.case+punc.y bertugan_casepunc.24000

If that works, please tell me so I fix the eval usage example into the file README.md.

Yes! That works! It was an arguments order problem as you said. Thanks!

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

4 participants