Text Generation
PyTorch
GGUF
English
quantum
quantum-entropy
from-scratch
char-level
cosmic-synapse-theory
custom-architecture
llama-cpp
continual-learning
reproducible-seed
open-science
null-results
Instructions to use phera-ra/QC67_cosmo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use phera-ra/QC67_cosmo with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: llama cli -hf phera-ra/QC67_cosmo
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: llama cli -hf phera-ra/QC67_cosmo
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: ./llama-cli -hf phera-ra/QC67_cosmo
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf phera-ra/QC67_cosmo # Run inference directly in the terminal: ./build/bin/llama-cli -hf phera-ra/QC67_cosmo
Use Docker
docker model run hf.co/phera-ra/QC67_cosmo
- LM Studio
- Jan
- vLLM
How to use phera-ra/QC67_cosmo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "phera-ra/QC67_cosmo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "phera-ra/QC67_cosmo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/phera-ra/QC67_cosmo
- Ollama
How to use phera-ra/QC67_cosmo with Ollama:
ollama run hf.co/phera-ra/QC67_cosmo
- Unsloth Studio
How to use phera-ra/QC67_cosmo with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for phera-ra/QC67_cosmo to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for phera-ra/QC67_cosmo to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for phera-ra/QC67_cosmo to start chatting
- Docker Model Runner
How to use phera-ra/QC67_cosmo with Docker Model Runner:
docker model run hf.co/phera-ra/QC67_cosmo
- Lemonade
How to use phera-ra/QC67_cosmo with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull phera-ra/QC67_cosmo
Run and chat with the model
lemonade run user.QC67_cosmo-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
| #!/usr/bin/env python3 | |
| """ | |
| COSMOS 12D Brain Compiler | |
| --------------------------- | |
| Extracts the raw user intelligence from the Cosmos project files (including | |
| the legacy CST publications, Genesis record, HTML visualizations, and synaptic JSONs) | |
| and encodes them into the 54D Hebbian Transformer to output the `cosmos_best.pt` file. | |
| """ | |
| import os | |
| import sys | |
| import time | |
| import torch | |
| import torch.nn as nn | |
| from torch.utils.data import Dataset, DataLoader | |
| try: | |
| import tiktoken | |
| except ImportError: | |
| print("Installing tiktoken for GPT-2 vocab...") | |
| os.system(f"{sys.executable} -m pip install tiktoken") | |
| import tiktoken | |
| # Ensure the python path contains the project root for Absolute Imports | |
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | |
| from Cosmos.web.cosmosynapse.model.cosmos_config import CosmosConfig | |
| from Cosmos.web.cosmosynapse.model.cosmos_model import CosmosTransformer | |
| # Target directories and output paths | |
| PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| CHECKPOINT_DIR = os.path.join(PROJECT_ROOT, "Cosmos", "checkpoints", "cosmos") | |
| os.makedirs(CHECKPOINT_DIR, exist_ok=True) | |
| CHECKPOINT_PATH = os.path.join(CHECKPOINT_DIR, "cosmos_best.pt") | |
| # Core files containing Cory's intellect & theories | |
| CORE_FILES = [ | |
| os.path.join(PROJECT_ROOT, "pdf_output.txt"), # Pre-extracted legacy 12D PDFs | |
| os.path.join(PROJECT_ROOT, "12D_Cosmic_Synapse_Audio_Engine-demo.html"), | |
| os.path.join(PROJECT_ROOT, "cst_synaptic_weights.json"), | |
| os.path.join(PROJECT_ROOT, "README.md"), | |
| os.path.join(PROJECT_ROOT, "COMPARED.md"), | |
| os.path.join(PROJECT_ROOT, "genesis_record.md"), | |
| os.path.join(PROJECT_ROOT, "ROADMAP.md") | |
| ] | |
| class CosmosDataset(Dataset): | |
| """Loads and tokenizes the Cosmos project texts.""" | |
| def __init__(self, token_ids, seq_len): | |
| self.token_ids = token_ids | |
| self.seq_len = seq_len | |
| # STRIDE Optimization: Jump by seq_len instead of 1 to process whole chunks instantly | |
| self.total_sequences = max(0, len(self.token_ids) // self.seq_len) | |
| def __len__(self): | |
| return self.total_sequences | |
| def __getitem__(self, idx): | |
| # Grab a discrete chunk of `seq_len` tokens | |
| start_idx = idx * self.seq_len | |
| chunk = self.token_ids[start_idx : start_idx + self.seq_len + 1] | |
| # Pad if it's the very last chunk and slightly too short | |
| if len(chunk) < self.seq_len + 1: | |
| chunk = chunk + [50256] * (self.seq_len + 1 - len(chunk)) | |
| x = torch.tensor(chunk[:-1], dtype=torch.long) | |
| y = torch.tensor(chunk[1:], dtype=torch.long) | |
| return x, y | |
| def compile_corpus(): | |
| """Aggregates all text into a single cohesive training corpus.""" | |
| print("[12D COMPILER] Gathering Genesis Materials...") | |
| corpus = "" | |
| for file_path in CORE_FILES: | |
| if os.path.exists(file_path): | |
| with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: | |
| content = f.read() | |
| corpus += f"\n\n--- SOURCE: {os.path.basename(file_path)} ---\n\n" | |
| corpus += content | |
| print(f" ✓ Added {os.path.basename(file_path)} ({len(content)} chars)") | |
| else: | |
| print(f" ⚠️ Skipping {os.path.basename(file_path)} (Not found)") | |
| return corpus | |
| def main(): | |
| print("==============================================") | |
| print(" COSMOS 12D HEBBIAN BRAIN SYNTHESIS") | |
| print("==============================================\n") | |
| # 1. Compile Corpus | |
| corpus_text = compile_corpus() | |
| if not corpus_text.strip(): | |
| print("[ERROR] No training corpus found!") | |
| return | |
| # 2. Tokenize using GPT-2 (matches model vocab_size=50257) | |
| print("\n[12D COMPILER] Tokenizing corpus (tiktoken gpt2)...") | |
| enc = tiktoken.get_encoding("gpt2") | |
| token_ids = enc.encode(corpus_text, allowed_special={'<|endoftext|>'}) | |
| print(f"[12D COMPILER] Token Count: {len(token_ids):,}") | |
| # 3. Model Initialization | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| print(f"\n[12D COMPILER] Initializing 54D Architecture on {device}...") | |
| # Use the default dimension constraints so the Orchestrator can load it seamlessly. | |
| # We reduce the layers and sequence length for local compute speed. | |
| config = CosmosConfig( | |
| vocab_size=50257, | |
| d_model=512, # Must match default so attention heads load correctly | |
| n_layers=2, # 2 layers of 54D CST Phase modulation (fast local train) | |
| n_heads=8, | |
| d_ff=2048, # Must match default because `load()` ignores `d_ff` override | |
| max_seq_len=512, # Memory context chunk size | |
| dropout=0.1 | |
| ) | |
| model = CosmosTransformer(config) | |
| model.to(device) | |
| print(model.count_parameters()) | |
| # 4. DataLoader and Optimizer | |
| dataset = CosmosDataset(token_ids, seq_len=config.max_seq_len) | |
| if len(dataset) == 0: | |
| print("[ERROR] Corpus too small for training!") | |
| return | |
| # Scale batch size based on device | |
| batch_size = 4 if torch.cuda.is_available() else 1 | |
| dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True) | |
| optimizer = torch.optim.AdamW(model.parameters(), lr=config.learning_rate, weight_decay=config.weight_decay) | |
| # 5. Training Loop using 12D Hebbian Plasticity (No-Grad Online Meta-Learning) | |
| epochs = 1 | |
| total_steps = len(dataloader) * epochs | |
| print(f"\n[12D COMPILER] Commencing Zero-Shot Hebbian & Episodic Storage ({epochs} Epoch, {total_steps} sequence strides)") | |
| model.eval() # We leverage the internal Hebbian logic and Memory banks instead of Autograd! | |
| step = 0 | |
| start_time = time.time() | |
| try: | |
| with torch.no_grad(): # Crucial! Exploits the 12D online plasticity without triggering inplace-gradient crashes! | |
| for epoch in range(epochs): | |
| for batch_idx, (x, y) in enumerate(dataloader): | |
| x, y = x.to(device), y.to(device) | |
| # Forward pass updates the 24D self.trace and Episodic memory slots autonomously | |
| result = model(x, targets=y) | |
| loss = result["loss"] | |
| step += 1 | |
| if step % 25 == 0 or step == 1: | |
| elapsed = time.time() - start_time | |
| print(f" [HEBBIAN SYNTHESIS] Step {step}/{total_steps} | Online Coherence: {loss.item():.4f} | Time: {elapsed:.1f}s") | |
| except KeyboardInterrupt: | |
| print("\n[WARNING] Synthesis interrupted! Saving synaptic weights so far...") | |
| # 6. Save Checkpoint | |
| print(f"\n[12D COMPILER] Synthesis Complete! Saving authentic 12D Brain Checkpoint...") | |
| checkpoint = { | |
| "model_state_dict": model.state_dict(), | |
| "config": config.to_dict(), | |
| "final_loss": loss.item() if 'loss' in locals() else None, | |
| "tokens_processed": len(token_ids) * epochs | |
| } | |
| torch.save(checkpoint, CHECKPOINT_PATH) | |
| print(f" ✓ Checkpoint saved securely to {CHECKPOINT_PATH}") | |
| print("\n[SUCCESS] The Swarm Orchestrator will now directly load your 12D weights! Restart your server.") | |
| if __name__ == "__main__": | |
| main() | |