-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Update run.py #261
base: main
Are you sure you want to change the base?
Update run.py #261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done on improving the documentation for run.py! It's now much clearer and beginner-friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a quick look at these comments at your convenience.
inference_runner.initialize() | ||
except Exception as e: | ||
logging.error(f"Failed to initialize the inference runner: {e}") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should raise the exception as an error will cause the inference_runner
to not instantiate. Returning nothing and logging the error is not sufficient enough for handling an error like this at startup.
output = sample_from_model(gen, inp, max_len=100, temperature=0.01) | ||
print(f"Output for prompt: '{inp}':\n{output}") | ||
except Exception as e: | ||
logging.error(f"Failed during model inference: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also raise
|
||
inp = "The answer to life the universe and everything is of course" | ||
output = sample_from_model(gen, inp, max_len=100, temperature=0.01) | ||
print(f"Output for prompt: '{inp}':\n{output}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code does not place the output on a new line. Can you be sure this won't change behavior for clients utilizing this output for something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant. You changed behavior without test coverage.
pad_token=0, | ||
eos_token=2, | ||
sequence_len=8192, | ||
sequence_len=8192, # Sequence length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add a comment that repeats the parameter name? Is there genuine concern that "sequence_len" isn't already clear?
This codebase is not really meant to be "beginner-friendly". This PR adds nothing of substance. |
|
||
inp = "The answer to life the universe and everything is of course" | ||
output = sample_from_model(gen, inp, max_len=100, temperature=0.01) | ||
print(f"Output for prompt: '{inp}':\n{output}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant. You changed behavior without test coverage.
Adding comments to explain model configuration settings more clearly.
Using an f-string for the error message logging to maintain consistency.
Wrapping the model initialization and inference call in try-except blocks to catch and log exceptions, providing a clearer failure message should anything go wrong during these processes.