Skip to content

docs: improve documentation on exporting models from Colab - #4247

Merged
danielhanchen merged 1 commit into
mainfrom
dh/recover-4184-colab-export-docs
Sep 8, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
dh/recover-4184-colab-export-docs

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Replacement for #4184 due to Studio rebasing

Summary

  • Adds a comprehensive guide at docs/exporting_models_from_colab.md covering all model export methods from Google Colab
  • Documents saving to Google Drive, pushing to HuggingFace Hub, and GGUF export for Ollama/llama.cpp
  • Includes comparison tables for save methods and quantization options
  • Covers common issues: disk space, credential errors, runtime disconnects
  • Adds link to the new guide from README.md

Closes #1615

What's covered

  1. Save LoRA adapters (fastest, smallest)
  2. Save merged model (full weights)
  3. Export to GGUF (for Ollama, llama.cpp)
  4. Push directly to HuggingFace Hub
  5. Save to Google Drive

Re-opening — previous PR #4152 was closed when the fork was accidentally deleted. Changes are identical.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 crucial new documentation guide aimed at helping users effectively persist and export their fine-tuned models from Google Colab environments. Recognizing the ephemeral nature of Colab instances, the guide provides detailed, step-by-step instructions and best practices for various export scenarios, ensuring users can reliably save their work and integrate it with other platforms or local inference tools.

Highlights

  • New Documentation Guide: A comprehensive guide has been added at docs/exporting_models_from_colab.md detailing various methods for exporting fine-tuned models from Google Colab.
  • Export Methods Covered: The guide covers saving to Google Drive, pushing to Hugging Face Hub, and GGUF export for tools like Ollama and llama.cpp, including options for LoRA adapters and merged models.
  • Troubleshooting and Best Practices: The documentation includes comparison tables for save methods and quantization options, along with solutions for common issues such as disk space limitations, credential errors, and Colab runtime disconnects.
  • README Update: The README.md file has been updated to include a direct link to the newly created model export guide.
Changelog
  • README.md
    • Added a link to the new model export guide.
  • docs/exporting_models_from_colab.md
    • Created a new comprehensive guide on exporting fine-tuned models from Google Colab.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
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. ↩

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

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.

Code Review

This pull request introduces a comprehensive and well-structured guide on exporting models from Google Colab. The new documentation is a valuable addition, covering various methods and common troubleshooting steps. The changes are clear and the guide is easy to follow. I've provided a few minor suggestions to improve clarity and consistency in the new documentation file.

Comment thread docs/exporting_models_from_colab.md Outdated
Comment on lines +154 to +155
# Create a Modelfile
echo 'FROM ./my_model_gguf/<base-model-name>.Q4_K_M.gguf' > Modelfile

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 placeholder <base-model-name> can be confusing. It refers to the filename of the GGUF file (without the quantization suffix), which is derived from the original model's name. Using a more descriptive placeholder like your-model-name and adding a comment to guide the user would improve clarity.

Suggested change
# Create a Modelfile
echo 'FROM ./my_model_gguf/<base-model-name>.Q4_K_M.gguf' > Modelfile
# Create a Modelfile (replace your-model-name with your actual model name)
echo 'FROM ./my_model_gguf/your-model-name.Q4_K_M.gguf' > Modelfile

Comment thread docs/exporting_models_from_colab.md Outdated

```python
from google.colab import files
files.download("my_model_gguf/<model-name>.Q4_K_M.gguf")

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

For consistency with other parts of the document (like the Ollama section), consider using a more descriptive placeholder like your-model-name instead of <model-name>. This helps maintain a uniform and clear style throughout the guide.

Suggested change
files.download("my_model_gguf/<model-name>.Q4_K_M.gguf")
files.download("my_model_gguf/your-model-name.Q4_K_M.gguf")

Comment thread docs/exporting_models_from_colab.md Outdated
# Split into 2 GB chunks
subprocess.run([
"split", "-b", "2G",
"my_model_gguf/<model-name>.Q4_K_M.gguf",

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

To maintain consistency across the document's examples, it would be beneficial to use the same placeholder format. Replacing <model-name> with your-model-name would align this example with others and improve overall clarity.

Suggested change
"my_model_gguf/<model-name>.Q4_K_M.gguf",
"my_model_gguf/your-model-name.Q4_K_M.gguf",

Comment thread docs/exporting_models_from_colab.md Outdated
system and cached model weights. Saving a merged 16-bit model can temporarily
require 2x the model size in disk space.

**Solutions:**

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

For better document structure and consistency, it's recommended to use Markdown headings (e.g., ###) instead of bolded text for section titles like 'Solutions'. This improves readability and allows for easier navigation if a table of contents is generated.

Suggested change
**Solutions:**
### Solutions

Comment thread docs/exporting_models_from_colab.md Outdated
Large model exports can take 10-30 minutes. Colab may disconnect during this
time.

**Solutions:**

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

To maintain a consistent heading structure throughout the document, consider changing this bolded title to a Markdown heading (### Solutions). This will also ensure it's treated as a proper section header.

Suggested change
**Solutions:**
### Solutions

Comment thread docs/exporting_models_from_colab.md Outdated
GGUF conversion requires merging LoRA into 16-bit first, which temporarily uses
significant memory.

**Solutions:**

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

Using a Markdown heading (###) here instead of bolded text would align with standard Markdown practices for section titles and improve the document's overall structural consistency.

Suggested change
**Solutions:**
### Solutions

@Sagargupta16

Sagargupta16 commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Looks good -- glad the guide is making it in. I noticed the GGUF section covers q4_k_m as the default recommendation. Would it be worth adding a note about q8_0 for users who need higher accuracy and have the disk space? That was one of the things I cleaned up in #4184 (the quantization consistency between examples).

@danielhanchen
danielhanchen force-pushed the dh/recover-4184-colab-export-docs branch from 888c08f to 405e038 Compare March 12, 2026 23:10
@nidhishgajjar

This comment was marked as low quality.

1 similar comment
@nidhishgajjar

This comment was marked as low quality.

@danielhanchen danielhanchen added diff-reduce# Shrink to an empty diff and squash-merge so a first-time contributor is credited superseded# labels Sep 8, 2026
Squashed from 3 commit(s); reduced to an empty diff so the contribution is credited on merge.
@danielhanchen
danielhanchen force-pushed the dh/recover-4184-colab-export-docs branch from 405e038 to a081e3f Compare September 8, 2026 10:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T10:23:28.449386Z a081e3f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

Thanks for the PR! Sorry on the delay as well - we superseded the PR, but we merged the PR for now - appreciate the contribution!

@danielhanchen
danielhanchen merged commit 8c101fd into main Sep 8, 2026
9 checks passed
@danielhanchen
danielhanchen deleted the dh/recover-4184-colab-export-docs branch September 8, 2026 10:54
danielhanchen pushed a commit that referenced this pull request Sep 8, 2026
Empty commit crediting the contribution; the change was superseded on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts# diff-reduce# Shrink to an empty diff and squash-merge so a first-time contributor is credited non-studio# superseded#

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs Improvement] Improve documentation on how to export model from Colab

3 participants