Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Ollama Ollama ParseFromModel

From Leeroopedia
Knowledge Sources
Domains Storage, Model_Management
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for resolving a base model's layers from its manifest provided by the server package.

Description

parseFromModel takes a model name, finds its local manifest, and returns its layers as a slice of layerGGML structs. Each layer contains the GGUF-parsed metadata and a reference to the blob file.

The companion GetModel function provides a higher-level interface, returning a fully populated Model struct with paths, template, system prompt, options, and capability detection.

Usage

Called by CreateHandler to load the base model's layers when processing a FROM directive in model creation.

Code Reference

Source Location

  • Repository: ollama
  • File: server/model.go (parseFromModel), server/images.go (GetModel)
  • Lines: model.go:L28-77 (parseFromModel), images.go:L271-369 (GetModel)

Signature

func parseFromModel(ctx context.Context, name model.Name, fn func(api.ProgressResponse)) (layers []*layerGGML, err error)
func GetModel(name string) (*Model, error)

Import

import "github.com/ollama/ollama/server"

I/O Contract

Inputs

Name Type Required Description
ctx context.Context Yes Cancellation context
name model.Name Yes Parsed model name (host/namespace/model:tag)
fn func(api.ProgressResponse) Yes Progress callback

Outputs

Name Type Description
layers []*layerGGML Slice of GGUF layers from the base model (weights, config, template, system, params)
error error Non-nil if model not found or GGUF parsing fails

Usage Examples

Internal Usage in CreateHandler

// From server/create.go
layers, err := parseFromModel(ctx, baseName, fn)
if err != nil {
    return err
}
// layers now contains the base model's weights and metadata
// Override with Modelfile directives...

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment