Instructions to use tiny-random/stablelm-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/stablelm-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/stablelm-2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tiny-random/stablelm-2") model = AutoModelForCausalLM.from_pretrained("tiny-random/stablelm-2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/stablelm-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/stablelm-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/stablelm-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tiny-random/stablelm-2
- SGLang
How to use tiny-random/stablelm-2 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 "tiny-random/stablelm-2" \ --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": "tiny-random/stablelm-2", "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 "tiny-random/stablelm-2" \ --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": "tiny-random/stablelm-2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tiny-random/stablelm-2 with Docker Model Runner:
docker model run hf.co/tiny-random/stablelm-2
Download README.md from tiny-random/stablelm-2: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/tiny-random/stablelm-2/resolve/main/README.md
- Command line
-
hf download hf://tiny-random/stablelm-2/README.md
-
curl -L -o README.md https://huggingface.co/tiny-random/stablelm-2/resolve/main/README.md
library_name: transformers
pipeline_tag: text-generation
base_model:
- stabilityai/stablelm-2-1_6b
This is a randomly initialized tiny model based on stabilityai/stablelm-2-1_6b for testing and debugging.
| Feature | Source | This repo |
|---|---|---|
| Checkpoint tensor elements | 1.64B BF16 | 13.65M BF16 |
| Safetensors weight files | 3.29 GB (model.safetensors) | 27.31 MB (model.safetensors) |
| Layers | 24 | 4 |
| Hidden width / MLP width | 2,048 / 5,632 (2.75x) | 128 / 352 (2.75x) |
| Q heads / KV heads / head_dim | 32 / 32 / 64 | 4 / 4 / 32 |
| Rotary coverage | partial, 25% of head_dim | Same (8 of 32) |
| QKV bias / embedding tying | true / untied (source) | true / tied |
| Vocabulary rows | 100,352 | Same |
| Stored precision | FP16 config | BF16 |
StableLM has no rectangular attention, so TP=4 forces four 32-dim heads and hidden width 128. The tiny checkpoint ties the language-model head to the token embedding (the source shipped them untied), keeping the artifact at 27.31MB within the 30MB best-effort target.
| File path | Size |
|---|---|
| model.safetensors | 27.3MB |
Example usage
Transformers (✅ verified)
def run_transformers(model_id: str):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = str(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = (
AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16, attn_implementation="sdpa").eval().cuda()
)
inputs = tokenizer("The quick brown fox jumps over the lazy dog.", return_tensors="pt").to("cuda")
with torch.no_grad():
assert torch.isfinite(model(**inputs).logits).all()
output = model.generate(**inputs, do_sample=False, max_new_tokens=8)
print(tokenizer.decode(output[0], skip_special_tokens=True))
if __name__ == "__main__":
run_transformers(model_id="tiny-random/stablelm-2")
SGLang (✅ verified)
SGLang 0.5.10 ships a native StableLmForCausalLM implementation; serve the tiny checkpoint with tensor parallelism:
sglang serve --model-path tiny-random/stablelm-2 --tp 4 \
--dtype bfloat16 --context-length 1024 --disable-piecewise-cuda-graph --host 0.0.0.0 --port 30000
piecewise prefill CUDA graph capture hits CUBLAS_STATUS_INTERNAL_ERROR in o_proj, so the command below passes --disable-piecewise-cuda-graph.
Send an OpenAI completion request:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
resp = client.completions.create(
model="tiny-random/stablelm-2", prompt="The quick brown fox", max_tokens=8, temperature=0
)
print(resp.choices[0].text)
Creating this repo
- Code: .meta/create_model.py
- Model structure: .meta/model.log
- Environment: .meta/env.json
Change log
- 2026-11-07: Initial version rebuilt from the official stabilityai/stablelm-2-1_6b source with four layers and 25%-partial rotary embeddings.
This repo is generated by GPT-6.1-Sol.