Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ollama Ollama Convert Olmo

From Leeroopedia
Knowledge Sources
Domains Model Conversion, GGUF Format
Last Updated 2025-02-15 00:00 GMT

Overview

Implements the GGUF model converter for the OLMo 3 architecture, supporting RoPE scaling configurations, sliding window attention with per-layer patterns, and QK normalization.

Description

The olmoModel struct implements ModelConverter for OLMo (Open Language Model) models using the olmo3 architecture designation. The KV method emits metadata for standard transformer parameters plus optional RoPE scaling (factor, original context length, attention factor, type), sliding window attention size, and per-layer sliding window patterns derived from layer_types configuration. The Tensors method performs a straightforward pass-through without any tensor transformation. Tensor name replacements include QK norm support (attn_q_norm, attn_k_norm) and post-attention/post-feedforward normalization layers.

Usage

Invoked automatically when the model's architecture matches OlmoForCausalLM or Olmo3ForCausalLM.

Code Reference

Source Location

  • Repository: Ollama
  • File: convert/convert_olmo.go
  • Lines: 1-117

Signature

type olmoModel struct {
    ModelParameters
    HiddenSize            uint32       `json:"hidden_size"`
    NumHiddenLayers       uint32       `json:"num_hidden_layers"`
    RopeTheta             float32      `json:"rope_theta"`
    RopeScaling           *ropeScaling `json:"rope_scaling"`
    SlidingWindow         uint32       `json:"sliding_window"`
    LayerTypes            []string     `json:"layer_types"`
}

func (p *olmoModel) KV(t *Tokenizer) KV
func (p *olmoModel) Tensors(ts []Tensor) []*ggml.Tensor
func (p *olmoModel) Replacements() []string

Import

import "github.com/ollama/ollama/convert"

I/O Contract

Inputs

Name Type Required Description
t *Tokenizer Yes Tokenizer data for GGUF metadata
ts []Tensor Yes Source tensors (passed through without transformation)

Outputs

Name Type Description
KV KV GGUF metadata with olmo3.* keys including RoPE scaling and sliding window pattern
[]*ggml.Tensor slice Pass-through converted tensors

Usage Examples

// Converter registered for OLMo architectures
// Sliding window pattern is derived from layer_types:
// "sliding_attention" -> true, others -> false

Related Pages

Page Connections

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