Skip to content

Llama doc fix#2286

Closed
maitry63 wants to merge 3 commits intokeras-team:masterfrom
maitry63:llama_doc_fix
Closed

Llama doc fix#2286
maitry63 wants to merge 3 commits intokeras-team:masterfrom
maitry63:llama_doc_fix

Conversation

@maitry63
Copy link
Copy Markdown
Contributor

This PR for adding the missing method in the llama_backbone.
Fixes: keras-team/keras-hub#2587

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @maitry63, 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 enhances the siamese_contrastive example by refactoring its embedding network definition and adjusting the Siamese model's output to directly provide distance measurements, coupled with a new custom accuracy metric for improved evaluation. Concurrently, it addresses a documentation gap by adding a missing method to the LlamaBackbone API listing, ensuring comprehensive and up-to-date documentation.

Highlights

  • Siamese Network Example Refactoring: The siamese_contrastive example was significantly refactored to define the embedding network as a dedicated function, improving code organization and readability.
  • Siamese Model Architecture Update: The Siamese model's output layer was modified to directly return the Euclidean distance between embeddings, removing the final BatchNormalization and Dense layers that previously produced a sigmoid-activated probability.
  • Custom Accuracy Metric Implementation: A new, custom accuracy function was introduced and integrated into the Siamese model's compilation, providing a more appropriate evaluation metric for the updated model output.
  • LlamaBackbone Documentation Fix: The get_layout_map method was added to the API documentation for keras_hub.models.LlamaBackbone, addressing a missing entry.
  • Metadata and Output Refresh: The "Last modified" dates in the example files were updated, and the training logs and image references in the notebook and markdown versions were refreshed to reflect the changes.

🧠 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
  • examples/vision/ipynb/siamese_contrastive.ipynb
    • Updated last modified date in notebook metadata.
    • Added keras.layers import.
    • Refactored the embedding network definition into a dedicated function create_embedding_network with a docstring.
    • Modified the Siamese model construction to output the Euclidean distance directly, removing subsequent BatchNormalization and Dense layers.
    • Introduced a new accuracy function and updated the model compilation to use this custom metric.
    • Refreshed training logs and image paths within the notebook.
  • examples/vision/md/siamese_contrastive.md
    • Updated last modified date.
    • Added keras.layers import.
    • Refactored the embedding network definition into a dedicated function create_embedding_network with a docstring.
    • Modified the Siamese model construction to output the Euclidean distance directly, removing subsequent BatchNormalization and Dense layers.
    • Introduced a new accuracy function and updated the model compilation to use this custom metric.
    • Refreshed training logs and image paths in the markdown file.
  • examples/vision/siamese_contrastive.py
    • Updated last modified date.
    • Added keras.layers import.
    • Refactored the embedding network definition into a dedicated function create_embedding_network with a docstring.
    • Modified the Siamese model construction to output the Euclidean distance directly, removing subsequent BatchNormalization and Dense layers.
    • Introduced a new accuracy function and updated the model compilation to use this custom metric.
  • scripts/hub_master.py
    • Added keras_hub.models.LlamaBackbone.get_layout_map to the list of documented methods.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@maitry63 maitry63 closed this Feb 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two main changes. First, it adds the get_layout_map method to the LlamaBackbone documentation, which aligns with the PR's description. Second, it significantly refactors and improves the Siamese network example (siamese_contrastive). The model creation is now encapsulated in a function, making the code more modular. More importantly, the model and loss have been corrected to properly use contrastive loss on the Euclidean distance, and a custom accuracy metric has been added to reflect this change. These are excellent improvements that fix a correctness issue in the example.

I've only found a minor issue regarding the 'Last modified' date in the example files, which appears to be set to a future date.

"**Author:** Mehdi<br>\n",
"**Date created:** 2021/05/06<br>\n",
"**Last modified:** 2022/09/10<br>\n",
"**Last modified:** 2026/01/28<br>\n",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Last modified' date is set to a future date. Please update it to the current date.

**Author:** Mehdi<br>
**Date created:** 2021/05/06<br>
**Last modified:** 2022/09/10<br>
**Last modified:** 2026/01/28<br>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Last modified' date is set to a future date. Please update it to the current date.

Author: Mehdi
Date created: 2021/05/06
Last modified: 2022/09/10
Last modified: 2026/01/28
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Last modified' date is set to a future date. Please update it to the current date.

@maitry63 maitry63 deleted the llama_doc_fix branch March 12, 2026 02:30
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.

get_layout_map() is not documented for Llama backbone

2 participants