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
| # COSMOS Cloud Integration Guide | |
| Enable optional cloud services (Azure, IBM) while maintaining local-first operation. | |
| --- | |
| ## Quick Start | |
| ### 1. Install Cloud Support | |
| ```bash | |
| pip install flask openai ibm-cloud-sdk-core ibm-cloud-sdk-watsonx requests | |
| ``` | |
| ### 2. Start Cloud Endpoint | |
| ```bash | |
| python cloud_endpoint.py | |
| ``` | |
| The dashboard opens at: `http://localhost:5000` | |
| ### 3. Configure Your Cloud Services | |
| #### Azure OpenAI | |
| 1. Go to dashboard → **Azure** tab | |
| 2. Enable Azure OpenAI | |
| 3. Enter: | |
| - **API Key**: Your Azure OpenAI key (from portal) | |
| - **API Endpoint**: `https://{resource-name}.openai.azure.com/` | |
| - **Deployment Name**: Name of your deployed model (e.g., `gpt-4`) | |
| - **Model Blob**: Reference name (e.g., `gpt-4-vision`) | |
| 4. Click **Test Connection** | |
| #### IBM Watsonx | |
| 1. Go to dashboard → **IBM** tab | |
| 2. Enable IBM Watsonx | |
| 3. Enter: | |
| - **API Key**: Your IBM Cloud API key | |
| - **API Endpoint**: Your Watsonx endpoint URL | |
| - **Model Name**: Model ID (e.g., `granite-13b-chat-v2`) | |
| - **Model Blob**: Reference (e.g., `ibm/granite`) | |
| 4. Click **Test Connection** | |
| --- | |
| ## Architecture | |
| ``` | |
| ┌─────────────────────────────────────┐ | |
| │ Genesis_Engine (Local COSMOS) │ | |
| │ - Ollama (default) │ | |
| │ - Hebbian learning │ | |
| │ - Quantum heart │ | |
| └──────────────────┬──────────────────┘ | |
| │ | |
| ┌──────────────┼──────────────┐ | |
| ▼ ▼ ▼ | |
| ┌────────┐ ┌──────────┐ ┌────────┐ | |
| │ Ollama │ │ Azure │ │ IBM │ | |
| │ (Local)│ │ OpenAI │ │ Watsonx│ | |
| └────────┘ └──────────┘ └────────┘ | |
| Cloud Router (cloud_endpoint.py) | |
| - Config management | |
| - Credential handling | |
| - Request routing | |
| - Vision processing | |
| ``` | |
| --- | |
| ## API Endpoints | |
| ### Configuration | |
| **GET /api/config** | |
| Get current configuration (sanitized). | |
| ```bash | |
| curl http://localhost:5000/api/config | |
| ``` | |
| **POST /api/config/default** | |
| Set default provider. | |
| ```bash | |
| curl -X POST http://localhost:5000/api/config/default \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"provider": "azure"}' | |
| ``` | |
| **POST /api/config/provider/{provider}** | |
| Update provider settings. | |
| ```bash | |
| curl -X POST http://localhost:5000/api/config/provider/azure \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "endpoint": "https://myresource.openai.azure.com/", | |
| "model_name": "gpt-4", | |
| "model_blob": "gpt-4-vision" | |
| }' | |
| ``` | |
| ### Credentials | |
| **POST /api/credentials/{provider}** | |
| Set API credentials (from environment variable or request body). | |
| ```bash | |
| curl -X POST http://localhost:5000/api/credentials/azure \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"api_key": "YOUR_AZURE_KEY"}' | |
| ``` | |
| **POST /api/credentials/test/{provider}** | |
| Test provider connectivity. | |
| ```bash | |
| curl -X POST http://localhost:5000/api/credentials/test/azure | |
| ``` | |
| ### Generation | |
| **POST /api/generate** | |
| Generate response from selected provider. | |
| ```bash | |
| curl -X POST http://localhost:5000/api/generate \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "prompt": "Hello, what is your name?", | |
| "provider": "azure" | |
| }' | |
| ``` | |
| **POST /api/vision** | |
| Analyze image with vision model. | |
| ```bash | |
| curl -X POST http://localhost:5000/api/vision \ | |
| -F "image=@photo.jpg" \ | |
| -F "prompt=Describe this image" \ | |
| -F "provider=azure" | |
| ``` | |
| ### Status | |
| **GET /api/status** | |
| Get system status and provider info. | |
| ```bash | |
| curl http://localhost:5000/api/status | |
| ``` | |
| **GET /api/health** | |
| Health check. | |
| ```bash | |
| curl http://localhost:5000/api/health | |
| ``` | |
| --- | |
| ## Environment Variables | |
| For security, use environment variables instead of hardcoding keys: | |
| ```bash | |
| # Azure | |
| export COSMOS_AZURE_KEY="your-azure-key-here" | |
| # IBM | |
| export COSMOS_IBM_KEY="your-ibm-key-here" | |
| # Start endpoint | |
| python cloud_endpoint.py | |
| ``` | |
| The dashboard will automatically load credentials from environment. | |
| --- | |
| ## Integration with Genesis_Engine | |
| Add cloud routing to your Genesis_Engine: | |
| ```python | |
| # In soul/loop.py or serve.py | |
| from cloud_router import CloudConfig, CloudRouter | |
| # Initialize | |
| config = CloudConfig() | |
| router = CloudRouter(config) | |
| # Generate with cloud (or local fallback) | |
| response = router.generate( | |
| prompt="Your message", | |
| provider="azure" # or "ibm", "ollama" | |
| ) | |
| # Handle vision | |
| image_analysis = router.vision( | |
| image_path="/path/to/image.jpg", | |
| prompt="Describe this", | |
| provider="azure" # gpt-4-vision | |
| ) | |
| ``` | |
| --- | |
| ## Configuration File | |
| Cloud settings are stored in `cloud_config.json` (credentials not persisted): | |
| ```json | |
| { | |
| "enabled": true, | |
| "default_provider": "ollama", | |
| "providers": { | |
| "azure": { | |
| "enabled": false, | |
| "api_key": "[SET_VIA_ENV]", | |
| "api_endpoint": "https://myresource.openai.azure.com/", | |
| "deployment_name": "gpt-4", | |
| "model_blob": "gpt-4-vision", | |
| "temperature": 0.7, | |
| "timeout": 30 | |
| }, | |
| "ibm": { | |
| "enabled": false, | |
| "api_key": "[SET_VIA_ENV]", | |
| "api_endpoint": "https://api.us-south.watson-platform.net/instances/...", | |
| "model_name": "granite-13b-chat-v2", | |
| "model_blob": "ibm/granite", | |
| "temperature": 0.7, | |
| "timeout": 30 | |
| }, | |
| "ollama": { | |
| "enabled": true, | |
| "api_endpoint": "http://localhost:11434", | |
| "model_name": "cosmos-q4:latest", | |
| "timeout": 60 | |
| } | |
| } | |
| } | |
| ``` | |
| --- | |
| ## Example: Full Cloud Setup | |
| ### Setup Script | |
| ```bash | |
| #!/bin/bash | |
| # Install dependencies | |
| pip install flask openai ibm-cloud-sdk-core ibm-cloud-sdk-watsonx requests | |
| # Set credentials | |
| export COSMOS_AZURE_KEY="your-azure-key" | |
| export COSMOS_IBM_KEY="your-ibm-key" | |
| # Start endpoint | |
| python cloud_endpoint.py | |
| ``` | |
| ### Client Code | |
| ```python | |
| import requests | |
| import json | |
| # Configure Azure as default | |
| requests.post('http://localhost:5000/api/config/default', | |
| json={'provider': 'azure'}) | |
| # Generate response | |
| response = requests.post('http://localhost:5000/api/generate', | |
| json={'prompt': 'Hello!'}) | |
| print(response.json()['response']) | |
| ``` | |
| --- | |
| ## Fallback Behavior | |
| If cloud service fails, routes to: | |
| 1. Default provider (if enabled) | |
| 2. Ollama (if available) | |
| 3. Error | |
| ```python | |
| # Graceful fallback | |
| try: | |
| response = router.generate(prompt, provider='azure') | |
| except Exception as e: | |
| print(f"Azure failed, falling back to Ollama: {e}") | |
| response = router.generate(prompt, provider='ollama') | |
| ``` | |
| --- | |
| ## Vision Support | |
| Currently supported: | |
| - ✅ Azure OpenAI (gpt-4-vision) | |
| - ⏳ IBM Watsonx (coming soon) | |
| - ✅ Ollama (with multimodal models) | |
| ```python | |
| # Azure vision | |
| analysis = router.vision( | |
| image_path="photo.jpg", | |
| prompt="What's in this image?", | |
| provider="azure" | |
| ) | |
| ``` | |
| --- | |
| ## Troubleshooting | |
| ### "Azure not enabled or API key not set" | |
| - Ensure `COSMOS_AZURE_KEY` environment variable is set | |
| - Or use dashboard to set credentials | |
| ### "Connection timeout" | |
| - Check endpoint URL is correct | |
| - Verify network access to cloud service | |
| - Increase timeout in `cloud_config.json` | |
| ### "Invalid deployment name" | |
| - Check deployment exists in Azure portal | |
| - Name is case-sensitive | |
| - Use "gpt-4" not "GPT-4" | |
| ### "Model not found" | |
| - For IBM: check model ID in Watsonx console | |
| - For Azure: verify deployment is created | |
| --- | |
| ## Security Best Practices | |
| 1. **Never commit API keys** to version control | |
| 2. **Use environment variables** for credentials | |
| 3. **Rotate keys regularly** in cloud portals | |
| 4. **Use API key with minimal permissions** if possible | |
| 5. **Monitor usage** in cloud provider dashboards | |
| 6. **Set rate limits** on endpoint if exposed | |
| --- | |
| ## Performance | |
| Typical latencies: | |
| - **Ollama (local)**: 50-500ms | |
| - **Azure OpenAI**: 500-2000ms (network + model) | |
| - **IBM Watsonx**: 500-2000ms (network + model) | |
| For best performance: | |
| - Use Ollama for interactive chat | |
| - Use Azure/IBM for heavy lifting (vision, reasoning) | |
| - Implement caching for repeated prompts | |
| --- | |
| ## Advanced: Custom Providers | |
| Extend `CloudRouter` to add custom providers: | |
| ```python | |
| class CustomRouter(CloudRouter): | |
| def _generate_custom(self, prompt: str, **kwargs) -> str: | |
| """Add your custom provider here.""" | |
| # Implementation | |
| pass | |
| def generate(self, prompt, provider=None, **kwargs): | |
| if provider == "custom": | |
| return self._generate_custom(prompt, **kwargs) | |
| return super().generate(prompt, provider, **kwargs) | |
| ``` | |
| --- | |
| ## Deployment | |
| ### Docker | |
| ```dockerfile | |
| FROM python:3.9 | |
| WORKDIR /cosmos | |
| COPY cloud_*.py . | |
| COPY templates/ templates/ | |
| RUN pip install flask openai requests | |
| EXPOSE 5000 | |
| CMD ["python", "cloud_endpoint.py"] | |
| ``` | |
| ### Systemd Service | |
| ```ini | |
| [Unit] | |
| Description=COSMOS Cloud Router | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| User=cosmos | |
| WorkingDirectory=/opt/cosmos | |
| EnvironmentFile=/etc/cosmos/cloud.env | |
| ExecStart=/usr/bin/python3 cloud_endpoint.py | |
| Restart=always | |
| [Install] | |
| WantedBy=multi-user.target | |
| ``` | |
| --- | |
| ## License & Citation | |
| COSMOS Cloud Integration is part of the COSMOS project. | |
| ```bibtex | |
| @misc{phera2026cosmos, | |
| title={COSMOS: A 54D Quantum-Inspired Transformer with Cloud Integration}, | |
| author={Phera}, | |
| year={2026}, | |
| url={https://zenodo.org/records/17574447} | |
| } | |
| ``` | |
| --- | |
| **Questions?** Check `/docs` endpoint or review `cloud_router.py` source code. | |