Text Generation
Transformers
Safetensors
English
spin
tiny-models
custom-architecture
story-generation
experimental
custom_code
Instructions to use Quantech/spin-80k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Quantech/spin-80k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Quantech/spin-80k", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Quantech/spin-80k", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Quantech/spin-80k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Quantech/spin-80k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Quantech/spin-80k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Quantech/spin-80k
- SGLang
How to use Quantech/spin-80k 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 "Quantech/spin-80k" \ --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": "Quantech/spin-80k", "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 "Quantech/spin-80k" \ --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": "Quantech/spin-80k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Quantech/spin-80k with Docker Model Runner:
docker model run hf.co/Quantech/spin-80k
Update modeling_spin.py
Browse files- modeling_spin.py +4 -2
modeling_spin.py
CHANGED
|
@@ -108,8 +108,8 @@ class TransformerBlock(nn.Module):
|
|
| 108 |
|
| 109 |
class SpinForCausalLM(PreTrainedModel, GenerationMixin):
|
| 110 |
config_class = SpinConfig
|
| 111 |
-
# Fix: Use dict mapping for tied weights
|
| 112 |
_tied_weights_keys = {"lm_head.weight": "tok_embeddings.weight"}
|
|
|
|
| 113 |
|
| 114 |
def __init__(self, config: SpinConfig):
|
| 115 |
super().__init__(config)
|
|
@@ -144,6 +144,7 @@ class SpinForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 144 |
def forward(
|
| 145 |
self,
|
| 146 |
input_ids: torch.Tensor = None,
|
|
|
|
| 147 |
labels: torch.Tensor = None,
|
| 148 |
past_key_values: list = None,
|
| 149 |
use_cache: bool = False,
|
|
@@ -182,12 +183,13 @@ class SpinForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 182 |
past_key_values=new_kv_caches if use_cache else None,
|
| 183 |
)
|
| 184 |
|
| 185 |
-
def prepare_inputs_for_generation(self, input_ids, past_key_values=None, **kwargs):
|
| 186 |
if past_key_values is not None and len(past_key_values) > 0 and past_key_values[0] is not None:
|
| 187 |
input_ids = input_ids[:, -1:]
|
| 188 |
return {
|
| 189 |
"input_ids": input_ids,
|
| 190 |
"past_key_values": past_key_values,
|
|
|
|
| 191 |
"use_cache": True,
|
| 192 |
}
|
| 193 |
|
|
|
|
| 108 |
|
| 109 |
class SpinForCausalLM(PreTrainedModel, GenerationMixin):
|
| 110 |
config_class = SpinConfig
|
|
|
|
| 111 |
_tied_weights_keys = {"lm_head.weight": "tok_embeddings.weight"}
|
| 112 |
+
_supports_cache_class = False
|
| 113 |
|
| 114 |
def __init__(self, config: SpinConfig):
|
| 115 |
super().__init__(config)
|
|
|
|
| 144 |
def forward(
|
| 145 |
self,
|
| 146 |
input_ids: torch.Tensor = None,
|
| 147 |
+
attention_mask: torch.Tensor = None,
|
| 148 |
labels: torch.Tensor = None,
|
| 149 |
past_key_values: list = None,
|
| 150 |
use_cache: bool = False,
|
|
|
|
| 183 |
past_key_values=new_kv_caches if use_cache else None,
|
| 184 |
)
|
| 185 |
|
| 186 |
+
def prepare_inputs_for_generation(self, input_ids, past_key_values=None, attention_mask=None, **kwargs):
|
| 187 |
if past_key_values is not None and len(past_key_values) > 0 and past_key_values[0] is not None:
|
| 188 |
input_ids = input_ids[:, -1:]
|
| 189 |
return {
|
| 190 |
"input_ids": input_ids,
|
| 191 |
"past_key_values": past_key_values,
|
| 192 |
+
"attention_mask": attention_mask,
|
| 193 |
"use_cache": True,
|
| 194 |
}
|
| 195 |
|