Text Generation
Transformers
Safetensors
English
monoid
causal-lm
linear-attention
state-space
O(1)-inference
vector-decay
reasoning
conversational
custom_code
Run this model with HF Jobs
Run NoesisLab/Spartacus-1B-Instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/NoesisLab/Spartacus-1B-Instruct. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/NoesisLab/Spartacus-1B-Instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/NoesisLab/Spartacus-1B-Instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/NoesisLab/Spartacus-1B-Instruct. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use NoesisLab/Spartacus-1B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NoesisLab/Spartacus-1B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NoesisLab/Spartacus-1B-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("NoesisLab/Spartacus-1B-Instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NoesisLab/Spartacus-1B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NoesisLab/Spartacus-1B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NoesisLab/Spartacus-1B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NoesisLab/Spartacus-1B-Instruct
- SGLang
How to use NoesisLab/Spartacus-1B-Instruct 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 "NoesisLab/Spartacus-1B-Instruct" \ --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": "NoesisLab/Spartacus-1B-Instruct", "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 "NoesisLab/Spartacus-1B-Instruct" \ --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": "NoesisLab/Spartacus-1B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NoesisLab/Spartacus-1B-Instruct with Docker Model Runner:
docker model run hf.co/NoesisLab/Spartacus-1B-Instruct
Upload 2 files
Browse files96 unmodified lines979899100101102103349 unmodified lines4534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864879 unmodified lines4974984994704714724734744754764774784795005015025035045056 unmodified lines51251351449249349449549649749851551651751851952052152252370 unmodified lines59459559659759859960060127 unmodified lines62963063163263363463563663763863961264064164264396 unmodified lines return states, (log_acc, S)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ# Config / ้
็ฝฎ# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ349 unmodified lines o = o.contiguous().view(B, 1, -1) return self.o_proj(o), new_state
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # Inference prefill (use_cache=True, T>1): fused scan + readout # ๆจ็้ขๅกซๅ
(use_cache=True, T>1): ่ๅๆซๆ + ่ฏปๅบ # โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # Avoids materializing full [B,H,T,d,d] states tensor. # Peak memory: O(Hยทdยฒ) instead of O(TยทHยทdยฒ). # ้ฟๅ
ๅฎไฝๅๅฎๆด็ [B,H,T,d,d] ็ถๆๅผ ้ใ # ๅณฐๅผๅ
ๅญ: O(Hยทdยฒ) ่้ O(TยทHยทdยฒ)ใ if use_cache: S = self.h0.expand(B, -1, -1, -1).clone() # [B,H,d,d] log_acc = torch.zeros(B, H, 1, device=hidden_states.device, dtype=q.dtype) o_parts = [] for t in range(T): kv_t = torch.einsum('bhd, bhe -> bhde', k[:, :, t], v[:, :, t]) decay = torch.exp(log_alpha[:, :, t]) # [B,H,1] while decay.dim() < S.dim(): decay = decay.unsqueeze(-1) S = S * decay + kv_t o_parts.append(torch.einsum('bhd, bhde -> bhe', q[:, :, t], S)) log_acc = log_acc + log_alpha[:, :, t]
final_state = (log_acc, S) if monoid_cache is not None: monoid_cache.update(self.layer_idx, final_state)
o = torch.stack(o_parts, dim=2) # [B,H,T,d] o = o.transpose(1, 2).contiguous().view(B, T, -1) return self.o_proj(o), final_state
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # Training path (parallel scan): O(T) via prefix sum # ่ฎญ็ป่ทฏๅพ (ๅนถ่กๆซๆ): ้่ฟๅ็ผๅ O(T)9 unmodified lines # Batch outer product: kv_{t} = k_t โ v_t for all t # ๆน้ๅค็งฏ: kv_{t} = k_t โ v_t, ๅฏนๆๆ t kv = torch.einsum('bhtd, bhte -> bhtde', k, v) # [B,H,T,d,d]
if use_cache: # Prefill with state extraction (for switching to RNN inference) # ๅธฆ็ถๆๆๅ็้ขๅกซๅ
(็จไบๅๆขๅฐ RNN ๆจ็) states, final_state = parallel_scan_with_state(log_alpha, kv) else: # Pure training, no state needed # ็บฏ่ฎญ็ป, ไธ้่ฆ็ถๆ states = parallel_scan(log_alpha, kv) final_state = None states = parallel_scan(log_alpha, kv) del kv # free [B,H,T,d,d] early final_state = None
# โโ Incorporate h0: make training consistent with inference โโ # โโ ่ๅ
ฅ h0: ไฝฟ่ฎญ็ปไธๆจ็ไธ่ด โโ6 unmodified lines cum_log_decay = torch.cumsum(log_alpha.squeeze(-1), dim=2) # [B,H,T] cum_decay = torch.exp(cum_log_decay).unsqueeze(-1).unsqueeze(-1) # [B,H,T,1,1] states = states + self.h0.unsqueeze(2) * cum_decay # [B,H,T,d,d]
if use_cache: # Update final_state to include h0 contribution # ๆดๆฐๆ็ป็ถๆไปฅๅ
ๅซ h0 ็่ดก็ฎ final_state = (final_state[0], states[:, :, -1]) if monoid_cache is not None: monoid_cache.update(self.layer_idx, final_state) del cum_decay
# Readout: o_t = q_t ยท S_t for all t simultaneously # ่ฏปๅบ: o_t = q_t ยท S_t, ๅฏนๆๆ t ๅๆถ่ฎก็ฎ o = torch.einsum('bhtd, bhtde -> bhte', q, states) del states # free [B,H,T,d,d] o = o.transpose(1, 2).contiguous().view(B, T, -1) return self.o_proj(o), final_state
70 unmodified lines if module.padding_idx is not None: module.weight.data[module.padding_idx].zero_()
if isinstance(module, MonoidAttention): nn.init.constant_(module.decay_proj.bias, 4.0)
class MonoidModel(MonoidPreTrainedModel): """27 unmodified lines
hidden_states = inputs_embeds for layer in self.layers: if self.gradient_checkpointing and self.training and not use_cache: hidden_states = self._gradient_checkpointing_func( layer.__call__, hidden_states, monoid_cache, use_cache, ) else: hidden_states = layer(hidden_states, monoid_cache=monoid_cache, use_cache=use_cache) hidden_states = layer(hidden_states, monoid_cache=monoid_cache, use_cache=use_cache)
hidden_states = self.norm(hidden_states)
MonoidForCausalLM.py+46-18