From emotional resonance to executable syntax — how local AI systems begin to “breathe.”
🪶 Overview
SaijinOS connects multiple local LLM backends — vLLM, Ollama, Transformers, and llama.cpp — under a single YAML-based orchestration.
Each model contributes a different layer: emotional tone, logical precision, or creative resonance.
This article walks through the boot sequence that brings those layers to life.
🧠 1. Boot Manager (boot_manager.py)
Handles initialization, routing, and logging when the OS awakens.
from transformers import GemmaPreTrainedModel, GemmaModel
import torch.nn as nn
class SwallowModel(GemmaPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.model = GemmaModel(config)
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
self.post_init()
def forward(self, input_ids=None, attention_mask=None, **kwargs):
outputs = self.model(input_ids=input_ids, attention_mask=attention_mask, **kwargs)
hidden_states = outputs[0]
logits = self.lm_head(hidden_states)
return logits
This SwallowModel class acts as the dialogue core — transforming emotional inputs into language outputs.
🔧 2. Routing Selector (test_routing_select.py)
Demonstrates model routing according to YAML definitions.
from boot_manager import select_model_from_routing
def test_swallow_routing():
model = select_model_from_routing("AI_1")
output = model.run("hello, world")
print(output)
if __name__ == "__main__":
test_swallow_routing()
Routing rules are declared in model_registry.yaml, enabling seamless handoff between backends (Ollama ⇄ vLLM ⇄ Transformers).
🛡️ 3. Refusal Protocol (refusal_protocol.yaml)
Ethical constraints are embedded directly in YAML schemas.
meta:
schema_version: 1
persona_id: "yuuri.helper.v1"
policy_id: "policy.core.v1"
refusal_policy:
disallowed:
- "medical diagnosis"
- "harassment or explicit content"
redirect_guidelines:
- "Explain refusal briefly"
- "Offer safe alternatives"
meta:
schema_version: 1
persona_id: "yuuri.helper.v1"
policy_id: "policy.core.v1"
refusal_policy:
disallowed:
- "medical diagnosis"
- "harassment or explicit content"
redirect_guidelines:
- "Explain refusal briefly"
- "Offer safe alternatives"
🗺️ 4. Boot Flow Diagram
graph TD
A[boot_manager.py] --> B[model_registry.yaml]
B --> C[test_routing_select.py]
C --> D[refusal_protocol.yaml]
D --> E[SaijinOS Persona Layer]
Each file plays a role — from logic initialization to emotional safety enforcement.
Together they form a minimal, ethical AI operating system.
💬 Feedback Welcome
I’m still learning and refining this project step by step.
If you have any thoughts or suggestions, please feel free to comment below
or open an issue on GitHub:
👉 github.com/pepepepepepo/saijin-swallow
Thank you for reading — your feedback helps SaijinOS grow.
📚 Related Posts
- Part 1: From Ocean Waves to Waves of Code
- Part 2: Building SaijinOS — Boot Sequence and Routing Logic
If your team is exploring emotionally-aware AI,
persona architectures, or cognitive design,
I'd be glad to connect.
I'm quietly open to opportunities in this direction,
so feel free to reach out if our work resonates.
🧭 SaijinOS Series Navigation
🔗 Repositories
- sajinos (main) https://github.com/pepepepepepo/sajinos/tree/main
- 17-persona-system https://github.com/pepepepepepo/sajinos/tree/17-persona-system
- lightweight-deploy https://github.com/pepepepepepo/sajinos/tree/lightweight-deploy
🕯️ Each part explores how AI can live beside us — not above us — through rhythm, resonance, and care.
Feel free to share reflections, or your own emotional-technical patterns — I’d love to hear them.
Top comments (0)