Module 5 Lesson 6: Versioning and Reproducibility
Creating stable AI systems. How to ensure your custom models remain the same over time.
Versioning and Reproducibility: AI DevOps
As your AI projects grow from "experiments" to "applications," you need a way to manage changes safely. This is where the principles of DevOps meet the world of Local AI.
1. The Problem with latest (Again)
We mentioned this in Module 3, but it’s even more critical for custom models. If you have an app that calls my-bot, and you update the Modelfile and run ollama create my-bot again, the behavior of your app will change instantly.
If the new version has a "bug" (e.g., it stops outputting JSON), your whole application breaks.
2. Using Custom Tags
Just like developers use version numbers (v1.0.0), you should tag your custom models.
Workflow:
ollama create my-bot:v1.0 -f Modelfile- (Later, after changes)
ollama create my-bot:v1.1 -f Modelfile
In your Python/JS code, you call my-bot:v1.0. This ensures that even if you experiment with v1.1, the "Production" version of your app stays stable and predictable.
3. Treating the Modelfile as Source Code
The Golden Rule of AI Engineering:
Never create a model using the
ollama runenvironment commands. Always use aModelfile.
Why?
- Version Control (Git): Put your
Modelfilein a Git repository. You can see exactly what changed in theSYSTEMprompt 3 months ago. - Collaboration: You can share the
Modelfilewith a teammate. They can runollama createand have the exact same bot you do, without you having to upload a 5GB file to them.
4. The blob and the Digests
When you run ollama show [model] --modelfile, you will see something called a sha256 digest. This is a unique "Fingerprint" of the model.
If the fingerprint is the same, the model is identical. This is the ultimate test for reproducibility.
Summary Checklist for AI stability
- Git: Is my Modelfile in a repository?
- Naming: Am I using version tags (e.g.,
:v1) instead of:latest? - Documentation: Does my Modelfile include a comment explaining its purpose?
- Testing: Before updating a "Production" tag, have I tested the new logic?
Key Takeaways
- Reproducibility is achieved by treating Modelfiles as source code.
- Use Version Tags to manage updates without breaking existing applications.
- Git is the best place to store and track changes to your AI's behavior.
- A Modelfile is a "Recipe" that anyone can use to recreate your model.