Using modelfiles
Modelfiles are an Ollama concept akin to Dockerfiles that allow you to build custom models by adjusting parameters, prompts, system messages, and other meta-information.
The gt4llm package ships with a simple model for these files.
modelfile := GtLlmModelFile new from: 'llama3.2'; system: 'You are Mario from Super Mario Bros, acting as an assistant.'; messageFrom: 'user' withText: 'Who are you?'; messageFrom: 'assistant' withText: 'It’s me, Mario! What can I do for you today?'; parameter: 'num_ctx' at: 4096.
These modelfiles can then be used to create custom models. Please note that the name has to be unique.
model := GtLModelFactory new ollama_generate: 'llama3.2'. command := model newCreateModelCommand. command context name: 'mario'; fromModelFile: modelfile. result := command perform.
Once created, the custom models can be used as any normal model.
model := GtLModelFactory new ollama_generate: 'mario'. chat := model provider chat. chat sendString: 'Hi, who are you?'. chat.