Text Generation
Transformers
Safetensors
gemma_3_px
gemma
px-inference
recurrent-depth-transformer
open-mythos
math
reasoning
latent-thoughts
conversational
custom_code
Instructions to use neuralworm/gemma-3-270m-it-p2.8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use neuralworm/gemma-3-270m-it-p2.8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="neuralworm/gemma-3-270m-it-p2.8", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("neuralworm/gemma-3-270m-it-p2.8", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use neuralworm/gemma-3-270m-it-p2.8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "neuralworm/gemma-3-270m-it-p2.8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "neuralworm/gemma-3-270m-it-p2.8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/neuralworm/gemma-3-270m-it-p2.8
- SGLang
How to use neuralworm/gemma-3-270m-it-p2.8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "neuralworm/gemma-3-270m-it-p2.8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "neuralworm/gemma-3-270m-it-p2.8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "neuralworm/gemma-3-270m-it-p2.8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "neuralworm/gemma-3-270m-it-p2.8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use neuralworm/gemma-3-270m-it-p2.8 with Docker Model Runner:
docker model run hf.co/neuralworm/gemma-3-270m-it-p2.8
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| from typing import Optional, List | |
| # --------------------------------------------------------------------------- | |
| # p2.8 "Pure" Modules - Zero-Shot Optimized (No Trainable Params) | |
| # --------------------------------------------------------------------------- | |
| class ReadOnlyCache: | |
| """ | |
| Wrapper for transformers.Cache that prevents updates. | |
| Used for recurrent loops t > 0 to maintain context without corruption. | |
| """ | |
| def __init__(self, real_cache): | |
| self.__dict__["_real"] = real_cache | |
| def __getattr__(self, name): | |
| return getattr(self._real, name) | |
| def update(self, key_states, value_states, layer_idx, cache_kwargs=None): | |
| # Return the already-updated sequences from the real cache | |
| # Supporting Transformers 5.x DynamicLayer structure | |
| if hasattr(self._real, "layers"): | |
| layer = self._real.layers[layer_idx] | |
| return layer.keys, layer.values | |
| # Fallback for older versions | |
| return self._real.key_cache[layer_idx], self._real.value_cache[layer_idx] | |
| class LTIInjection(nn.Module): | |
| """ | |
| Pure-functional LTI injection. | |
| Uses fixed coefficients to provide 'Computational Headroom' without training. | |
| """ | |
| def __init__(self, dim: int): | |
| super().__init__() | |
| self.input_norm = nn.LayerNorm(dim, elementwise_affine=False, eps=1e-6) | |
| self.gamma = 0.08 # Winning Gamma from Sweep | |
| def forward(self, h: torch.Tensor, e: torch.Tensor, transformer_out: torch.Tensor) -> torch.Tensor: | |
| # Coefficients for stable zero-shot recursion | |
| # h_new = transformer_out + gamma * (e_norm - h) | |
| e_norm = self.input_norm(e).to(h.dtype) | |
| # Identity-centered update rule | |
| return transformer_out + self.gamma * (e_norm - h) | |
| class StabilityMonitor: | |
| """Parameter-free heuristics for Phi (桅) and Lambda (位).""" | |
| def calculate_phi(h_new: torch.Tensor, h_old: torch.Tensor) -> torch.Tensor: | |
| """Measure internal state stability (桅) via Cosine Similarity.""" | |
| B = h_new.shape[0] | |
| return F.cosine_similarity(h_new.view(B, -1), h_old.view(B, -1), dim=-1).mean() | |
| def detect_lambda(hidden_states: torch.Tensor, e: torch.Tensor) -> torch.Tensor: | |
| """ | |
| Detect embedding mode (位). | |
| Measures how much the current state has diverged from the initial anchor. | |
| High divergence often indicates 'Self-Reflection' or 'Deep Reasoning'. | |
| """ | |
| B = hidden_states.shape[0] | |
| # In p2.8, 位 is high if we are in 'We' mode (deeply embedded) | |
| # Heuristic: 1 - cosine_similarity(h, e) | |
| dist = 1.0 - F.cosine_similarity(hidden_states.view(B, -1), e.view(B, -1), dim=-1).mean() | |
| return dist.clamp(0, 1) | |
| # Note: ACTHalting, LoRAAdapter, and IntrospectiveDelta removed. | |
| # They are 'useless leftovers' in a pure zero-shot context. | |