Instructions to use stabilityai/stablelm-base-alpha-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stabilityai/stablelm-base-alpha-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="stabilityai/stablelm-base-alpha-7b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-base-alpha-7b") model = AutoModelForCausalLM.from_pretrained("stabilityai/stablelm-base-alpha-7b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use stabilityai/stablelm-base-alpha-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "stabilityai/stablelm-base-alpha-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "stabilityai/stablelm-base-alpha-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/stabilityai/stablelm-base-alpha-7b
- SGLang
How to use stabilityai/stablelm-base-alpha-7b 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 "stabilityai/stablelm-base-alpha-7b" \ --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": "stabilityai/stablelm-base-alpha-7b", "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 "stabilityai/stablelm-base-alpha-7b" \ --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": "stabilityai/stablelm-base-alpha-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use stabilityai/stablelm-base-alpha-7b with Docker Model Runner:
docker model run hf.co/stabilityai/stablelm-base-alpha-7b
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Model Info:
|
| 2 |
+
- Size: 7B
|
| 3 |
+
- Dataset: The Pile v2
|
| 4 |
+
- `contaminated(P3) + lower_code(5%) + wiki(fixed) + books3(fixed & broken)`
|
| 5 |
+
- Batch size (in tokens): 8M
|
| 6 |
+
- Checkpoint path (AWS East): `/fsx/ckpts/7b_tok=neox_data=pilev2-recontam_lower-code_bs=8m_tp=4_pp=1_init=wang-small-init/global_step69000_hf`
|
| 7 |
+
|
| 8 |
+
Notes:
|
| 9 |
+
- Trained for 36k steps with incorrectly tokenized Books3 dataset (GPT-2 tokenizer instead of NeoX tokenizer)
|
| 10 |
+
- tp=2 (not 4)
|
| 11 |
+
|
| 12 |
+
W&B Report: https://stability.wandb.io/stability-llm/stable-lm/reports/StableLM-7B-alpha---Vmlldzo2MjA
|
| 13 |
+
|
| 14 |
+
Usage:
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
import transformers
|
| 18 |
+
|
| 19 |
+
model = transformers.AutoModelForCausalLM.from_pretrained("CarperAI/7b-alpha")
|
| 20 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained("CarperAI/7b-alpha")
|
| 21 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 22 |
+
tokenizer.paddding_side = "left"
|
| 23 |
+
|
| 24 |
+
prompts = [
|
| 25 |
+
"User1: The dog sat on a man's lap and barked 3 times.\nUser2: How many times did the dog bark?"
|
| 26 |
+
"Curious Person Question: A group of genetically identical individuals is called what?\nSmart Person Answer: a clone\n\nCurious Person Question: Who proposed the theory of evolution by natural selection?\nSmart Person Answer:"
|
| 27 |
+
]
|
| 28 |
+
batch_encoding = tokenizer(prompts, return_tensors="pt", padding=True)
|
| 29 |
+
|
| 30 |
+
print(f"Generating {len(prompts)} prompts...")
|
| 31 |
+
samples = model.generate(
|
| 32 |
+
**batch_encoding,
|
| 33 |
+
max_new_tokens=64,
|
| 34 |
+
temperature=0.0,
|
| 35 |
+
do_sample=False,
|
| 36 |
+
)
|
| 37 |
+
samples = tokenizer.batch_decode(samples, skip_special_tokens=True)
|
| 38 |
+
for i, sample in enumerate(samples):
|
| 39 |
+
print(f"Prompt: {prompts[i]}\nSample: {sample}\n")
|
| 40 |
+
```
|