Text Generation
Transformers
Safetensors
minspark
language-model
transformer
rope
gqa
custom_code
tiny
looped
slm
custom-architecture
custom-tokenizer
Instructions to use MinimaLabs/min-spark with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MinimaLabs/min-spark with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MinimaLabs/min-spark", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MinimaLabs/min-spark", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MinimaLabs/min-spark with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MinimaLabs/min-spark" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MinimaLabs/min-spark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MinimaLabs/min-spark
- SGLang
How to use MinimaLabs/min-spark 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 "MinimaLabs/min-spark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MinimaLabs/min-spark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "MinimaLabs/min-spark" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MinimaLabs/min-spark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MinimaLabs/min-spark with Docker Model Runner:
docker model run hf.co/MinimaLabs/min-spark
scrub internal project references from modeling_minspark.py
Browse files- modeling_minspark.py +2 -5
modeling_minspark.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""MinSparkForCausalLM: thin Transformers wrapper around the vendored Meiosis.
|
| 2 |
|
| 3 |
-
Exact semantics: identical to
|
| 4 |
loop (EOS prefix once, truncate to last max_seq_len, effort -> loop count).
|
| 5 |
No KV cache (min-spark 1.1); right-padding is scoring-only; generation is
|
| 6 |
single-sequence (enforced in prepare_inputs_for_generation).
|
|
@@ -38,7 +38,6 @@ class MinSparkForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 38 |
self.model = Meiosis(config.to_meiosis())
|
| 39 |
self.post_init() # ties weights (no-op: output == input embedding)
|
| 40 |
|
| 41 |
-
# -- embeddings ----------------------------------------------------
|
| 42 |
def get_input_embeddings(self) -> nn.Embedding:
|
| 43 |
return self.model.embed
|
| 44 |
|
|
@@ -48,7 +47,6 @@ class MinSparkForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 48 |
def get_output_embeddings(self) -> nn.Embedding:
|
| 49 |
return self.model.embed # tied: unembed reads embed.weight
|
| 50 |
|
| 51 |
-
# -- forward -------------------------------------------------------
|
| 52 |
def forward(
|
| 53 |
self,
|
| 54 |
input_ids: torch.Tensor,
|
|
@@ -153,7 +151,6 @@ class MinSparkForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 153 |
"interior gaps are not supported"
|
| 154 |
)
|
| 155 |
|
| 156 |
-
# -- generation -----------------------------------------------------
|
| 157 |
def prepare_inputs_for_generation(
|
| 158 |
self,
|
| 159 |
input_ids: torch.Tensor,
|
|
@@ -165,7 +162,7 @@ class MinSparkForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 165 |
"""Build the next forward's inputs. Returns exactly these four keys so
|
| 166 |
generation machinery (cache_position, position_ids, use_cache) is never
|
| 167 |
echoed into forward, which has no **kwargs. EOS is prepended BEFORE
|
| 168 |
-
truncation (
|
| 169 |
a supplied attention_mask is extended/truncated in lockstep so its length
|
| 170 |
always matches the returned input_ids (forward validates mask shape)."""
|
| 171 |
if input_ids.shape[0] != 1:
|
|
|
|
| 1 |
"""MinSparkForCausalLM: thin Transformers wrapper around the vendored Meiosis.
|
| 2 |
|
| 3 |
+
Exact semantics: identical to the bundled generate.py's generation
|
| 4 |
loop (EOS prefix once, truncate to last max_seq_len, effort -> loop count).
|
| 5 |
No KV cache (min-spark 1.1); right-padding is scoring-only; generation is
|
| 6 |
single-sequence (enforced in prepare_inputs_for_generation).
|
|
|
|
| 38 |
self.model = Meiosis(config.to_meiosis())
|
| 39 |
self.post_init() # ties weights (no-op: output == input embedding)
|
| 40 |
|
|
|
|
| 41 |
def get_input_embeddings(self) -> nn.Embedding:
|
| 42 |
return self.model.embed
|
| 43 |
|
|
|
|
| 47 |
def get_output_embeddings(self) -> nn.Embedding:
|
| 48 |
return self.model.embed # tied: unembed reads embed.weight
|
| 49 |
|
|
|
|
| 50 |
def forward(
|
| 51 |
self,
|
| 52 |
input_ids: torch.Tensor,
|
|
|
|
| 151 |
"interior gaps are not supported"
|
| 152 |
)
|
| 153 |
|
|
|
|
| 154 |
def prepare_inputs_for_generation(
|
| 155 |
self,
|
| 156 |
input_ids: torch.Tensor,
|
|
|
|
| 162 |
"""Build the next forward's inputs. Returns exactly these four keys so
|
| 163 |
generation machinery (cache_position, position_ids, use_cache) is never
|
| 164 |
echoed into forward, which has no **kwargs. EOS is prepended BEFORE
|
| 165 |
+
truncation (generate.py parity — it drops off prompts >max_seq_len);
|
| 166 |
a supplied attention_mask is extended/truncated in lockstep so its length
|
| 167 |
always matches the returned input_ids (forward validates mask shape)."""
|
| 168 |
if input_ids.shape[0] != 1:
|