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 make predictions deterministic? #18

Open
abdulmeral opened this issue Mar 18, 2024 · 5 comments
Open

How to make predictions deterministic? #18

abdulmeral opened this issue Mar 18, 2024 · 5 comments
Labels
FAQ Frequently asked question

Comments

@abdulmeral
Copy link

Hello everyone,
how to prevent it from changing new predictions after each training?
Of course it is a LLM, but it is problem that changing every time. for example; my mape value is changing rapidly, bad or better..
have any recommend?

thank you already now.
abdül

@lostella lostella changed the title Seed Number .. How to make predictions deterministic? Mar 19, 2024
@lostella
Copy link
Contributor

@abdulmeral since the models are based on PyTorch, you can refer to PyTorch documentation about reproducibility.

In particular, setting the random number generation seed with

import torch
torch.manual_seed(0) # or some other number

before doing predictions, should make the behavior deterministic.

Another option to stabilize predictions (at least the "central tendencies" like mean and median) is to increase the number of samples by passing in num_samples when calling .predict (default is 20): this however will come at the cost of slower predictions.

@lostella lostella added the FAQ Frequently asked question label Mar 19, 2024
@abdulfatir
Copy link
Contributor

@lostella I think it maybe better to use transformers.set_seed for seeding. It seeds everything under the sun, so you will have consistent results.

@abdulmeral
Copy link
Author

thank you very much guys. both ideas are working.
and also my colleague recommends that making predictions with different seed numbers so we can get more generic results.

@abdulfatir
Copy link
Contributor

@abdulmeral glad that it helped. On another note, you should probably stop using MAPE because it's not a good metric. Checkout something like MASE, if you're working with point forecasts.

@lostella
Copy link
Contributor

@lostella I think it maybe better to use transformers.set_seed for seeding. It seeds everything under the sun, so you will have consistent results.

TIL

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

No branches or pull requests

3 participants