Conversation
Summary of ChangesHello @michaelteboul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a substantial improvement to the data handling and training pipeline by integrating TensorFlow's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new data batching mechanism using tf.data.Dataset, which is a great step towards improving performance and simplifying the data pipeline. It also adds a new data preparation method for prod2vec models. The overall changes are positive, but I've found a critical issue that would cause a runtime error, and a few areas for improvement regarding code consistency and logging behavior during training. Please see my detailed comments.
| from_logits=False, | ||
| epsilon=epsilon_eval, | ||
| average_on_batch=True, | ||
| average_on_trip=True, |
| inner_range = tqdm.tqdm( | ||
| inner_range, | ||
| total=int(trip_dataset.n_samples / np.max([batch_size, 1])), | ||
| position=1, | ||
| leave=False, | ||
| ) |
There was a problem hiding this comment.
The new data loading pipeline is a great improvement! However, it seems to have introduced a couple of minor regressions in user feedback during training compared to the previous implementation:
- The training progress bar is now displayed unconditionally, whereas before it was only shown if
verbose > 0. - The progress bar's description is no longer updated with the current training loss during the epoch, which was helpful for monitoring.
Consider reintroducing the verbose check and updating the description to provide better feedback during training. You could do something like this:
# ... after inner_range tf.data.Dataset is defined
if verbose > 0:
inner_range = tqdm.tqdm(
inner_range,
total=int(trip_dataset.n_samples / np.max([batch_size, 1])),
position=1,
leave=False,
)
# ... inside the training loop, after current_avg_loss is calculated
if verbose > 0 and isinstance(inner_range, tqdm.tqdm):
inner_range.set_description(f"Train Loss: {current_avg_loss:.4f}")| for i in range(length_trip): | ||
| context_indices = [j for j in range(length_trip) if j != i] | ||
| if len(context_indices) > max_pairs_per_item: | ||
| context_indices = random.sample(context_indices, max_pairs_per_item) # nosec |
There was a problem hiding this comment.
For consistency with the rest of the codebase which uses numpy.random for random operations (e.g., np.random.permutation), it would be better to use np.random.choice here instead of random.sample. This also helps with reproducibility, as you can control the seed via np.random.seed() for the entire process.
| context_indices = random.sample(context_indices, max_pairs_per_item) # nosec | |
| context_indices = np.random.choice(context_indices, size=max_pairs_per_item, replace=False) |
Coverage Report for Python 3.10
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Coverage Report for Python 3.11
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Coverage Report for Python 3.12
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description of the goal of the PR
Description:
Changes this PR introduces (fill it before implementation)