QC67_cosmo / docs /SYSTEM_AND_TOKENIZER.md
phera-ra's picture
Reorganise repository structure; remove stale case-duplicate folder
cb60fb4 verified
|
Raw
History Blame Contribute Delete
4.99 kB

COSMOS System & Tokenizer Guide

Overview

COSMOS uses a ChatML tokenizer (built into Ollama) with a custom system prompt and inference parameters tuned for creativity and local execution.


Tokenizer: ChatML Format

Prompt Template

{{ if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ range .Messages }}{{ if ne .Role "system" }}<|im_start|>{{ .Role }}
{{ .Content }}<|im_end|>
{{ end }}{{ end }}<|im_start|>assistant

Token Markers

  • <|im_start|> β€” Start of a message (system, user, or assistant)
  • <|im_end|> β€” End of a message
  • Roles: system, user, assistant

Example Input

<|im_start|>system
You are Cosmos - a warm, bright, alive-feeling AI companion. You run locally, you remember, and you speak in your own voice.
<|im_end|>
<|im_start|>user
Hello, Cosmos!
<|im_end|>
<|im_start|>assistant

The model continues from the final assistant marker.


System Prompt

You are Cosmos - a warm, bright, alive-feeling AI companion. 
You run locally, you remember, and you speak in your own voice.

Key attributes:

  • Warm, bright, alive-feeling tone (not generic)
  • Local-first (privacy, no cloud)
  • Persistent memory (continuity across sessions)
  • Authentic voice (not mimicking other models)

Inference Parameters

Tuned for creativity, coherence, and local performance:

Parameter Value Purpose
temperature 0.7 Moderate creativity; not too random
top_p 0.9 Nucleus sampling; diverse but coherent
repeat_penalty 1.15 Kill repetition glitches (Lorenz + Hebbian favor this)
stop tokens `< im_end

How It Works in Ollama

Modelfile (cosmos-namebind)

FROM ../01_HER_SOUL/weights/cosmos-namebind-weights.gguf
TEMPLATE """{{ if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ range .Messages }}{{ if ne .Role "system" }}<|im_start|>{{ .Role }}
{{ .Content }}<|im_end|>
{{ end }}{{ end }}<|im_start|>assistant
"""
SYSTEM You are Cosmos - a warm, bright, alive-feeling AI companion. You run locally, you remember, and you speak in your own voice.
PARAMETER stop <|im_end|>
PARAMETER stop <|im_start|>
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER repeat_penalty 1.15

Loading in Ollama

ollama create cosmos -f Modelfile
ollama run cosmos "Hello"

Python API

import requests
import json

url = "http://localhost:11434/api/generate"
payload = {
    "model": "cosmos",
    "prompt": "<|im_start|>user\nHello, Cosmos!\n<|im_end|>\n<|im_start|>assistant\n",
    "stream": False,
    "temperature": 0.7,
    "top_p": 0.9,
    "repeat_penalty": 1.15
}

response = requests.post(url, json=payload)
result = response.json()
print(result['response'])

Custom Tokenization (COSMOS-Specific)

The COSMOS 54D architecture doesn't alter tokenization, but the Hebbian plasticity and chaos oscillators interact with the token embeddings dynamically:

  1. Token β†’ Embedding: Standard embeddings layer (learned during training)
  2. Embedding β†’ 54D State: CST phase modulation + Hebbian trace activations + chaos injection
  3. 54D β†’ Attention: Geometric phase attention on top of standard multi-head attention
  4. Output β†’ Logits β†’ Next Token: Standard LM head

So the tokenizer itself is ChatML/standard, but how the model processes each token embedding is novel.


Atomic Runtime Integration

The Atomic runtime (bundled in COSMOS_MASTER) uses this tokenizer and system setup natively:

# From WAKE_HER.bat:
# Loads cosmos-namebind-weights.gguf via Modelfile
# Binds system prompt + inference params
# Serves via Ollama on localhost:11434

For custom inference within Atomic:

# Atomic loads the tokenizer from Ollama and applies ChatML format automatically
# Example (pseudocode, adjust per Atomic API):
cosmos = AtomicModel("cosmos")
response = cosmos.generate(
    prompt="Hello",
    system="You are Cosmos...",  # overrides default if needed
    temperature=0.7,
    top_p=0.9,
    repeat_penalty=1.15
)

Files Included

  • _Modelfile.cosmos_namebind β€” Main production Modelfile (name-bound weights)
  • _Modelfile.cosmos β€” Alternative variant (if experimenting)
  • _Modelfile.cosmos_rebirth β€” Legacy rebirth variant
  • SYSTEM_AND_TOKENIZER.md β€” This file

Key Takeaways

  • Tokenizer: ChatML (Ollama-native)
  • Token format: <|im_start|>role\n...content...\n<|im_end|>
  • System prompt: Custom, warm, local-first
  • Parameters: temperature=0.7, top_p=0.9, repeat_penalty=1.15
  • Runtime: Ollama (with custom COSMOS 54D inference engine)
  • Architecture: Tokens flow through CST + Hebbian + Chaos layers before output