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.

Principle:Ollama Ollama Architecture Detection

From Leeroopedia
Knowledge Sources
Domains Model_Architecture, Format_Conversion
Last Updated 2026-02-14 00:00 GMT

Overview

A metadata-driven model architecture detection mechanism that identifies the model family from HuggingFace config.json and selects the appropriate format converter.

Description

Architecture Detection is the first step in model format conversion. HuggingFace models include a config.json file with an architectures field that identifies the model family (e.g., "LlamaForCausalLM", "GemmaForCausalLM", "Qwen2ForCausalLM"). This field is used to dispatch to the correct converter that knows the architecture-specific tensor name mappings, weight layouts, and metadata keys.

The detection supports 25+ architecture families including LLaMA, Gemma, Qwen2, DeepSeek V2/V3, Mistral, Phi-3, BERT, and others.

Usage

Use this principle when building a multi-architecture model converter that must automatically detect and handle different model families from a common input format.

Theoretical Basis

The detection algorithm:

  1. Read config.json: Parse the JSON configuration file from the model directory.
  2. Extract architectures: Read the "architectures" array field.
  3. Lookup converter: Match the architecture string to a registered converter implementation.
  4. Fallback: If no exact match, attempt to infer from other config fields or fail with an informative error.

Related Pages

Implemented By

Page Connections

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