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 files453 unmodified lines454455456457458457458459460461462463460461462463464465466465466467468469470471472473474475476477467468469470471472473474475476477478479480481482483484485481486487488489490491453 unmodified lines return self.o_proj(o), new_state
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ # Inference prefill (use_cache=True, T>1): fused scan + readout # ๆจ็้ขๅกซๅ
(use_cache=True, T>1): ่ๅๆซๆ + ่ฏปๅบ # Inference prefill (use_cache=True, T>1): parallel 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ยฒ)ใ # Uses the same parallel_scan_with_state as training to leverage # Triton CUDA kernel acceleration instead of O(T) Python loop. # Memory: O(BยทHยทTยทdยฒ) โ same as training path. # ไฝฟ็จไธ่ฎญ็ป็ธๅ็ parallel_scan_with_state ๆฅๅฉ็จ # Triton CUDA ๆ ธๅฝๆฐๅ ้, ่้ O(T) ็ Python ๅพช็ฏใ # ๅ
ๅญ: O(BยทHยทTยท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) kv = torch.einsum('bhtd, bhte -> bhtde', k, v) # [B,H,T,d,d] states, (log_acc, S_T) = parallel_scan_with_state(log_alpha, kv)
# Add h0 contribution: S_t += (โ_{i=0}^{t} ฮฑ_i) ยท h0 # ๅ ๅ h0 ่ดก็ฎ: S_t += (โ_{i=0}^{t} ฮฑ_i) ยท h0 cum_log_alpha = torch.cumsum(log_alpha, dim=2) # [B,H,T,1] h0_decay = torch.exp(cum_log_alpha).unsqueeze(-1) # [B,H,T,1,1] states = states + h0_decay * self.h0.unsqueeze(2) # broadcast h0 [1,H,1,d,d]
# Final state includes h0 contribution # ๆ็ป็ถๆๅ
ๅซ h0 ่ดก็ฎ total_h0_decay = torch.exp(log_acc).unsqueeze(-1) # [B,H,1,1] S_final = S_T + total_h0_decay * self.h0.squeeze(0) # [B,H,d,d] (squeeze batch dim of h0) # h0 is [1,H,d,d], squeeze(0) removed for clarity but expand also works final_state = (log_acc, S_final)
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] # Vectorized readout: o_t = q_t ยท S_t for all t # ๅ้ๅ่ฏปๅบ: ไธๆฌกๆง่ฎก็ฎๆๆ t ็ o_t = q_t ยท S_t o = torch.einsum('bhtd, bhtde -> bhte', q, states) # [B,H,T,d] o = o.transpose(1, 2).contiguous().view(B, T, -1) return self.o_proj(o), final_state
MonoidForCausalLM.py+27-20