Implementation:Ollama Ollama Llama Model Apertus
| Knowledge Sources | |
|---|---|
| Domains | LLM Inference, Model Architecture |
| Last Updated | 2025-02-15 00:00 GMT |
Overview
Implements the ggml computation graph builder for the Apertus model architecture.
Description
The llm_build_apertus constructor builds a standard transformer pipeline: token embeddings, RoPE-based positional encoding with rope factors, RMS-normalized self-attention with Q/K/V projections (including Q and K normalization), and SiLU-gated feed-forward layers across all transformer blocks, producing final logits via an output projection.
Usage
Enables Ollama to run Apertus-family models through the llama.cpp inference engine by defining how model weights map to ggml tensor operations.
Code Reference
Source Location
- Repository: Ollama
- File:
llama/llama.cpp/src/models/apertus.cpp - Lines: 1-125
Signature
llm_build_apertus::llm_build_apertus(
const llama_model & model,
const llm_graph_params & params) : llm_graph_context(params);
Import
#include "models.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | const llama_model & | Yes | Loaded model with Apertus weights |
| params | const llm_graph_params & | Yes | Graph construction parameters |
Outputs
| Name | Type | Description |
|---|---|---|
| ggml graph | ggml_cgraph | Complete Apertus computation graph |
Usage Examples
// Dispatched via llama_model::build_graph():
auto builder = llm_build_apertus(model, params);
// Graph is constructed in the constructor