Instructions to use Qwest/Space_Oleg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwest/Space_Oleg with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwest/Space_Oleg", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Qwest/Space_Oleg", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwest/Space_Oleg with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwest/Space_Oleg" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwest/Space_Oleg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Qwest/Space_Oleg
- SGLang
How to use Qwest/Space_Oleg 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 "Qwest/Space_Oleg" \ --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": "Qwest/Space_Oleg", "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 "Qwest/Space_Oleg" \ --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": "Qwest/Space_Oleg", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Qwest/Space_Oleg with Docker Model Runner:
docker model run hf.co/Qwest/Space_Oleg
Update model.py
Browse files
model.py
CHANGED
|
@@ -6,8 +6,11 @@ import json
|
|
| 6 |
from safetensors.torch import save_file, load_file
|
| 7 |
import os
|
| 8 |
from huggingface_hub import PyTorchModelHubMixin
|
|
|
|
| 9 |
|
| 10 |
-
class CosmoFormerConfig:
|
|
|
|
|
|
|
| 11 |
def __init__(
|
| 12 |
self,
|
| 13 |
d_model: int = 256,
|
|
@@ -18,7 +21,9 @@ class CosmoFormerConfig:
|
|
| 18 |
num_layers: int = 6,
|
| 19 |
vocab_size: int = 65400,
|
| 20 |
max_len: int = 2048,
|
|
|
|
| 21 |
):
|
|
|
|
| 22 |
self.d_model = d_model
|
| 23 |
self.d_ff = d_ff
|
| 24 |
self.dropout = dropout
|
|
@@ -183,9 +188,11 @@ class DecoderLayer(nn.Module):
|
|
| 183 |
return x
|
| 184 |
|
| 185 |
|
| 186 |
-
class CosmoFormer(
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
self.config = config
|
| 190 |
self.d_model = config.d_model
|
| 191 |
self.vocab_size = config.vocab_size
|
|
|
|
| 6 |
from safetensors.torch import save_file, load_file
|
| 7 |
import os
|
| 8 |
from huggingface_hub import PyTorchModelHubMixin
|
| 9 |
+
from transformers import PretrainedConfig, PreTrainedModel
|
| 10 |
|
| 11 |
+
class CosmoFormerConfig(PretrainedConfig):
|
| 12 |
+
model_type = "cosmoformer"
|
| 13 |
+
|
| 14 |
def __init__(
|
| 15 |
self,
|
| 16 |
d_model: int = 256,
|
|
|
|
| 21 |
num_layers: int = 6,
|
| 22 |
vocab_size: int = 65400,
|
| 23 |
max_len: int = 2048,
|
| 24 |
+
**kwargs
|
| 25 |
):
|
| 26 |
+
super().__init__(**kwargs)
|
| 27 |
self.d_model = d_model
|
| 28 |
self.d_ff = d_ff
|
| 29 |
self.dropout = dropout
|
|
|
|
| 188 |
return x
|
| 189 |
|
| 190 |
|
| 191 |
+
class CosmoFormer(PreTrainedModel):
|
| 192 |
+
config_class = CosmoFormerConfig
|
| 193 |
+
|
| 194 |
+
def __init__(self, config: CosmoFormerConfig):
|
| 195 |
+
super().__init__(config)
|
| 196 |
self.config = config
|
| 197 |
self.d_model = config.d_model
|
| 198 |
self.vocab_size = config.vocab_size
|