Module 5 Wrap-up: Engineering Your Custom Bot
Hands-on: Creating a specialized AI persona from scratch. Move beyond the default registry.
Module 5 Wrap-up: Birth of a Persona
You’ve learned the syntax, the parameters, and the importance of versioning. Now, it’s time to build. We are going to create a "Structured Data Expert"—a bot that is designed specifically to take a mess of text and turn it into clean JSON.
Hands-on Exercise: The JSON Architect
1. Create the Modelfile
Create a file on your computer named JSONArchitect (no file extension) and paste the following:
FROM llama3
PARAMETER temperature 0.1
PARAMETER seed 42
SYSTEM """
You are a 'JSON Architect'. Your only job is to extract data from user input and format it as JSON.
- Never output conversational text.
- Never provide 'Sure, here is your JSON' introductions.
- If the input is empty, return an empty object {}.
- Always use double quotes for keys.
"""
2. Create the Model in Ollama
Open your terminal in the same folder as the file and run:
ollama create json-bot -f JSONArchitect
3. Test Your Creation
Run the new model:
ollama run json-bot
Now, give it some messy input: "The user Sudeep lives at 123 AI Lane in New York. He loves coding and hiking."
Expected Output:
{
"name": "Sudeep",
"address": "123 AI Lane, New York",
"hobbies": ["coding", "hiking"]
}
Challenge: The Extension
Now, try to use Inheritance to create a second model called json-bot-pirate that inherits FROM json-bot but adds a new SYSTEM prompt that forces it to use pirate slang for the JSON keys.
Module 5 Summary
- A Modelfile is a text-based blueprint for your AI.
- The
FROMcommand sets the base weights. - The
SYSTEMcommand sets the persistent personality. - The
PARAMETERcommand fine-tunes the engine statistics. ollama createis the command that turns the script into a runnable model.
Coming Up Next...
In Module 6, we leave the Ollama registry behind and enter the massive world of Hugging Face. We will learn how to find any model on the internet and pull it into Ollama manually.
Module 5 Checklist
- I have created my first custom Modelfile.
- I understand the difference between a User Prompt and a System Prompt.
- I know how to set the Temperature and Context Window.
- I successfully ran
ollama createand verified it withollama list. - I tried the "Inheritance" challenge.