Skip to content

docs: improve documentation on exporting models from Colab#4184

Open
Sagargupta16 wants to merge 2 commits intounslothai:mainfrom
Sagargupta16:docs/improve-colab-export-guide
Open

docs: improve documentation on exporting models from Colab#4184
Sagargupta16 wants to merge 2 commits intounslothai:mainfrom
Sagargupta16:docs/improve-colab-export-guide

Conversation

@Sagargupta16
Copy link

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.

Sagargupta16 and others added 2 commits March 4, 2026 07:55
Add comprehensive guide covering how to save fine-tuned models from Google
Colab, including saving to Google Drive, pushing to Hugging Face Hub, GGUF
export for Ollama/llama.cpp, and downloading large files.

Closes unslothai#1615

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use ### headings instead of bold text for subheadings
- Fix save_pretrained_gguf argument (use "my_model" not "my_model_gguf")
- Replace hardcoded GGUF filename with <model-name> placeholder

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
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 significantly enhances the project's documentation by introducing a detailed guide on exporting fine-tuned models from Google Colab. This new resource provides users with critical information and best practices for persisting their models, preventing data loss due to Colab's ephemeral nature, and facilitating deployment to various platforms like Hugging Face Hub or local inference engines. The guide addresses common challenges and offers practical solutions, making the model export process more robust and user-friendly.

Highlights

  • New Documentation Guide: A comprehensive guide docs/exporting_models_from_colab.md was added, detailing all methods for exporting fine-tuned models from Google Colab.
  • Export Methods Covered: The guide covers saving LoRA adapters, merged models (16-bit), exporting to GGUF format for Ollama/llama.cpp, pushing directly to Hugging Face Hub, and saving to Google Drive.
  • Troubleshooting and Best Practices: It includes comparison tables for save methods and quantization options, covers common issues like disk space, credential errors, and runtime disconnects, and provides solutions.
  • README Update: The README.md file was updated to include a direct link to the new model export guide.
Changelog
  • README.md
    • Added a link to the new "Exporting Models from Colab" guide.
  • docs/exporting_models_from_colab.md
    • Created a new comprehensive guide detailing various methods for saving and exporting fine-tuned models from Google Colab, including LoRA adapters, merged models, GGUF format, Hugging Face Hub integration, and Google Drive saving.
    • Included sections on downloading large files, common issues, troubleshooting, and a quick reference for recommended workflows.
Activity
  • No human activity (comments, reviews, etc.) 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.

Copy link
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 adds a comprehensive and well-written guide on exporting models from Google Colab. The documentation is clear, detailed, and covers a wide range of methods and common issues, which will be very helpful for users. I've made a few minor suggestions to improve consistency and clarity in some of the examples. Overall, this is an excellent addition to the documentation.

Note: Security Review has been skipped due to the limited scope of the PR.

Comment on lines +99 to +104
# Save as GGUF with q8_0 quantization (fast conversion, good quality)
model.save_pretrained_gguf(
"my_model",
tokenizer=tokenizer,
quantization_method="q8_0",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Python example for saving a GGUF file uses q8_0 quantization, but the subsequent Ollama Modelfile example refers to a Q4_K_M.gguf file. This inconsistency can be confusing.

To make the guide more consistent, I suggest updating the Python example to use q4_k_m, which is also noted as the recommended method for most use cases in the quantization table.

Suggested change
# Save as GGUF with q8_0 quantization (fast conversion, good quality)
model.save_pretrained_gguf(
"my_model",
tokenizer=tokenizer,
quantization_method="q8_0",
)
# Save as GGUF with q4_k_m quantization (recommended for most use cases)
model.save_pretrained_gguf(
"my_model",
tokenizer=tokenizer,
quantization_method="q4_k_m",
)


```bash
# Create a Modelfile
echo 'FROM ./my_model_gguf/<model-name>.Q4_K_M.gguf' > Modelfile
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The placeholder <model-name> is ambiguous. It's better to use <base-model-name> to clarify that it refers to the original model's name (e.g., Llama-3-8B-Instruct), not the name provided to save_pretrained_gguf. This will help users avoid errors when creating the Modelfile. This also applies to other parts of the document where <model-name> is used as a placeholder for the GGUF filename.

Suggested change
echo 'FROM ./my_model_gguf/<model-name>.Q4_K_M.gguf' > Modelfile
echo 'FROM ./my_model_gguf/<base-model-name>.Q4_K_M.gguf' > Modelfile

```bash
# On your local machine
pip install huggingface_hub
huggingface-cli download your-username/my-model-gguf --local-dir ./my-model
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's an inconsistency in the suggested --local-dir for downloading GGUF models. Here it's ./my-model, but in the "Quick Reference" section (line 544), it's ./my-model-gguf. Using ./my-model-gguf is more descriptive and consistent with the repository name your-username/my-model-gguf. I recommend using it here as well for clarity.

Suggested change
huggingface-cli download your-username/my-model-gguf --local-dir ./my-model
huggingface-cli download your-username/my-model-gguf --local-dir ./my-model-gguf

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.

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

1 participant