Skip to content

Commit 2264d42

Browse files
authored
Update model porting guidelines in CONTRIBUTING.md (keras-team#2596)
* Update model porting guidelines * Address comments
1 parent 98358c7 commit 2264d42

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,45 @@ pre-commit run --all-files
235235

236236
KerasHub uses [Ruff](https://docs.astral.sh/ruff/) to format the code.
237237

238+
## Model Porting Guidelines
239+
240+
We welcome contributions for new models! To ensure a smooth process, please follow these guidelines when porting a model to KerasHub.
241+
242+
### Finding and Proposing Models
243+
244+
- **Finding Work**: Check the [Issues tab](https://github.com/keras-team/keras-hub/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22stat%3Acontributions%20welcome%22) for open model porting tasks. These are often tagged for visibility.
245+
- **Proposing Models**: If you want to port a model that isn't listed, please [open an issue](https://github.com/keras-team/keras-hub/issues/new) to discuss it first. The team will review the proposal to ensure it fits the project roadmap.
246+
- **Licensing**: **Strict Requirement**: We currently only accept models with **Apache 2.0**, **MIT**, **Llama Community License** or **Gemma** licenses. Please verify the license of the original model before starting.
247+
248+
### Implementation Tools
249+
250+
We have tools to help you port models from other frameworks:
251+
252+
- **[Co-working with the Gemini CLI](#co-working-with-the-gemini-cli)**: Use the Gemini CLI to help generate code, unit tests, and conversion scripts.
253+
- **[Using the Model Porter Tool](#using-the-model-porter-tool)**: Automate the porting process using LLMs to generate files in the correct order.
254+
255+
### Implementation Checklist
256+
257+
A complete model port typically includes the following components:
258+
259+
1. **Model Implementation**: The core model code (Backbone, Tokenizer, Task layers, Preprocessing).
260+
2. **Unit Tests**: Standard Keras unit tests for all components to ensure basic functionality and shape inference.
261+
3. **Conversion Script**: A script to convert weights from the original framework (e.g. Hugging Face Safetensors) to KerasHub.
262+
4. **Numeric Verification**: Use a verification script (or notebook) to check output alignment with the reference model.
263+
- **Requirement**: Verify numerical outputs against the original implementation (e.g., Hugging Face Transformers).
264+
- **Parameter Count**: The parameter count of the KerasHub model must match the original model exactly.
265+
- **Process**: This verification is required for the PR to be approved.
266+
- **Evidence**: Your PR **must** include a Colab notebook or screenshots showing outputs match within an acceptable tolerance (1e-4 or lower) after a forward pass for both original and converted model.
267+
268+
**Reference**: See [PR #2384 (GPT-OSS Model Port)](https://github.com/keras-team/keras-hub/pull/2384) for an example of a successful model porting PR.
269+
270+
### Post-Merge Process
271+
272+
Once your PR is reviewed and merged:
273+
1. The Keras team will handle the full weight conversion using the checkpoint conversion script from your PR.
274+
2. The team will upload the weights to [Kaggle Models](https://www.kaggle.com/models?publisher=keras).
275+
3. The team will register the new Presets to KerasHub.
276+
238277
## Co-working with the Gemini CLI
239278

240279
Let's accelerate the development with Gemini CLI.

0 commit comments

Comments
 (0)