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

Update run.py #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update run.py #261

wants to merge 1 commit into from

Conversation

SleepTheGod
Copy link

@SleepTheGod SleepTheGod commented Mar 21, 2024

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.

Copy link

@Madhav-MKNC Madhav-MKNC left a 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.

Copy link

@Aareon Aareon left a 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
Copy link

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}")
Copy link

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}")
Copy link

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?

Copy link
Author

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?

Copy link

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
Copy link

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?

@Aareon
Copy link

Aareon commented Apr 5, 2024

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}")
Copy link

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.

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.

4 participants