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 files482 unmodified lines483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525482 unmodified linesreturn self.o_proj(o), final_state# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ# Training path (parallel scan): O(T) via prefix sum# ่ฎญ็ป่ทฏๅพ (ๅนถ่กๆซๆ): ้่ฟๅ็ผๅ O(T)# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ# For a full sequence of length T, compute ALL prefix states# S_1, S_2, ..., S_T simultaneously using parallel prefix scan.# Complexity: O(T) work, O(log T) depth โ GPU-friendly.## ๅฏน้ฟๅบฆไธบ T ็ๅฎๆดๅบๅ, ไฝฟ็จๅนถ่กๅ็ผๆซๆๅๆถ่ฎก็ฎๆๆๅ็ผ็ถๆ# S_1, S_2, ..., S_Tใ# ๅคๆๅบฆ: O(T) ๅทฅไฝ้, O(log T) ๆทฑๅบฆ โ GPU ๅๅฅฝใ# Batch outer product: kv_{t} = k_t โ v_t for all t# ๆน้ๅค็งฏ: kv_{t} = k_t โ v_t, ๅฏนๆๆ tkv = torch.einsum('bhtd, bhte -> bhtde', k, v) # [B,H,T,d,d]states = parallel_scan(log_alpha, kv)del kv # free [B,H,T,d,d] earlyfinal_state = None# โโ Incorporate h0: make training consistent with inference โโ# โโ ่ๅ ฅ h0: ไฝฟ่ฎญ็ปไธๆจ็ไธ่ด โโ# parallel_scan starts from S_0 = 0, but inference starts from S_0 = h0.# Fix: S_t(with h0) = h0 ยท ฮ _{i=1}^{t} ฮฑ_i + S_t(from scan)# The cumulative decay ฮ _{i=1}^{t} ฮฑ_i = exp(ฮฃ_{i=1}^{t} log_ฮฑ_i).# parallel_scan ไป S_0 = 0 ๅผๅง, ไฝๆจ็ไป S_0 = h0 ๅผๅงใ# ไฟฎๆญฃ: S_t(ๅซh0) = h0 ยท ฮ _{i=1}^{t} ฮฑ_i + S_t(ๆซๆ็ปๆ)# ็ดฏ็งฏ่กฐๅ ฮ _{i=1}^{t} ฮฑ_i = exp(ฮฃ_{i=1}^{t} log_ฮฑ_i)ใ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]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# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ482 unmodified lines483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512482 unmodified linesreturn self.o_proj(o), final_state# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ# Training path: memory-efficient sequential scan + inline readout# ่ฎญ็ป่ทฏๅพ: ๅ ๅญ้ซๆ็ไธฒ่กๆซๆ + ๅ ่่ฏปๅบ# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ# Loop token-by-token with running state S=[B,H,d,d].# Peak memory: O(BยทHยทdยฒ) instead of O(BยทHยทTยทdยฒ).# Autograd records each step for correct gradient computation.## ้ token ๅพช็ฏ, ไฝฟ็จ่ฟ่ก็ถๆ S=[B,H,d,d]ใ# ๅณฐๅผๅ ๅญ: O(BยทHยทdยฒ) ่้ O(BยทHยทTยทdยฒ)ใ# Autograd ่ฎฐๅฝๆฏๆญฅๆไฝไปฅๆญฃ็กฎ่ฎก็ฎๆขฏๅบฆใS = self.h0.expand(B, -1, -1, -1).clone() # [B,H,d,d]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_to_parts.append(torch.einsum('bhd, bhde -> bhe', q[:, :, t], S))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), None# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
MonoidForCausalLM.py+21-34