Text Generation
Transformers
Safetensors
PyTorch
English
pebble_25m
pebble
language-model
small-language-model
custom-code
mamba2
hybrid
chat
sft
custom_code
Instructions to use basically-ai/Pebble-25M-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use basically-ai/Pebble-25M-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="basically-ai/Pebble-25M-Chat", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("basically-ai/Pebble-25M-Chat", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use basically-ai/Pebble-25M-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "basically-ai/Pebble-25M-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "basically-ai/Pebble-25M-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/basically-ai/Pebble-25M-Chat
- SGLang
How to use basically-ai/Pebble-25M-Chat 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 "basically-ai/Pebble-25M-Chat" \ --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": "basically-ai/Pebble-25M-Chat", "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 "basically-ai/Pebble-25M-Chat" \ --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": "basically-ai/Pebble-25M-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use basically-ai/Pebble-25M-Chat with Docker Model Runner:
docker model run hf.co/basically-ai/Pebble-25M-Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,179 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
tags:
|
| 7 |
+
- pebble
|
| 8 |
+
- language-model
|
| 9 |
+
- small-language-model
|
| 10 |
+
- pytorch
|
| 11 |
+
- safetensors
|
| 12 |
+
- custom-code
|
| 13 |
+
- mamba2
|
| 14 |
+
- hybrid
|
| 15 |
+
- chat
|
| 16 |
+
- sft
|
| 17 |
+
base_model:
|
| 18 |
+
- basically-ai/Pebble-25M
|
| 19 |
+
library_name: transformers
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
# Pebble-25M-Chat
|
| 23 |
+
|
| 24 |
+

|
| 25 |
+
|
| 26 |
+
Pebble-25M-Chat is a compact, hybrid autoregressive chat language model. It combines the efficiency of state-space models with the proven performance of attention layers, optimized using a custom Muon + AdamW optimizer split.
|
| 27 |
+
|
| 28 |
+
## Model Details
|
| 29 |
+
|
| 30 |
+
- **Architecture:** Hybrid Mamba2 / Transformer
|
| 31 |
+
- **Block Pattern:** 3 Mamba2 blocks : 1 Attention block (repeating)
|
| 32 |
+
- **Parameters:** ~25,000,000 (25M)
|
| 33 |
+
- **Hidden Dimension:** 608
|
| 34 |
+
- **Layers:** 8 (6 Mamba2, 2 Attention)
|
| 35 |
+
- **Vocab Size:** 2,048 (Custom Byte-Level BPE)
|
| 36 |
+
- **Context Length:** 2048
|
| 37 |
+
- **Pretraining Tokens:** ~25,000,000,000 (~25 Billion)
|
| 38 |
+
- **SFT Tokens:** ~250,000,000 (~250 Million)
|
| 39 |
+
- **Optimizer:** Muon (for 2D hidden weights) + AdamW (for embeddings, norms, and scalars)
|
| 40 |
+
- **Precision:** fp32 master weights with bf16 autocast
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## Dataset Sources
|
| 45 |
+
|
| 46 |
+
The base model was pretrained on a 25B token subset of the following datasets:
|
| 47 |
+
|
| 48 |
+
| Dataset | Token Allocation | Share |
|
| 49 |
+
|---|---:|---:|
|
| 50 |
+
| FineWeb-Edu | 7.50 billion | 30% |
|
| 51 |
+
| DCLM | 5.00 billion | 20% |
|
| 52 |
+
| Cosmopedia-v2 | 3.75 billion | 15% |
|
| 53 |
+
| FineMath-4+ | 3.75 billion | 15% |
|
| 54 |
+
| FinePhrase | 3.00 billion | 12% |
|
| 55 |
+
| NPset | 2.00 billion | 8% |
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## Benchmarks
|
| 60 |
+
|
| 61 |
+
Pebble-25M-Chat was evaluated using zero-shot multiple-choice evaluation. Higher scores are better. **Bold** indicates the best score among the models listed.
|
| 62 |
+
|
| 63 |
+
| Benchmark | Pebble-25M | Pebble-25M Chat | Pebble-10M | BananaMind-2-Mini | Random |
|
| 64 |
+
|---|---:|---:|---:|---:|---:|
|
| 65 |
+
| PIQA | 59.25% | 53.37% | 58.43% | **59.63%** | 50.00% |
|
| 66 |
+
| ARC-Easy | 38.17% | 26.68% | 37.29% | **39.86%** | 25.00% |
|
| 67 |
+
| ARC-Challenge | 18.60% | 19.62% | 18.60% | **25.68%** | 25.00% |
|
| 68 |
+
| HellaSwag | 27.62% | 25.63% | 26.81% | **29.72%** | 25.00% |
|
| 69 |
+
| ArithMark-2.0 | 27.60% | 26.20% | **27.64%** | 27.52% | 25.00% |
|
| 70 |
+
| ArithMark-3.0 | 33.80% | 28.80% | 32.80% | **34.90%** | 25.00% |
|
| 71 |
+
|
| 72 |
+
### Evaluation Notes
|
| 73 |
+
|
| 74 |
+
- PIQA, ARC-Easy, ARC-Challenge, and HellaSwag were evaluated on their respective test splits.
|
| 75 |
+
- ArithMark-2.0 was evaluated on its train split due to the lack of a suitable test split.
|
| 76 |
+
- ArithMark-3.0 was evaluated on its train split due to the lack of a suitable test split.
|
| 77 |
+
- Results were obtained using zero-shot multiple-choice evaluation.
|
| 78 |
+
- The model was additionally fine-tuned using supervised fine-tuning (SFT).
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## SFT Attribution
|
| 83 |
+
|
| 84 |
+
The 250,000,000 SFT tokens used for Pebble-25M-Chat were provided by [smol-smoltalk](https://huggingface.co/datasets/HuggingFaceTB/smol-smoltalk).
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## Usage
|
| 89 |
+
|
| 90 |
+
To run the model for text generation, you will need to install the required dependencies. The included Mamba2 implementation relies on CUDA/Triton kernels and is intended to run on a CUDA-enabled GPU. Ampere-class GPUs or newer are recommended.
|
| 91 |
+
|
| 92 |
+
> **Note:** The model uses custom architecture code, so you must pass `trust_remote_code=True` when loading both the tokenizer and the model.
|
| 93 |
+
|
| 94 |
+
### Installation
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
pip install transformers huggingface_hub torch
|
| 98 |
+
pip install causal-conv1d mamba-ssm
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### Generation
|
| 102 |
+
|
| 103 |
+
Here is a simple Python script to load the model and generate text interactively:
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
import torch
|
| 107 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 108 |
+
|
| 109 |
+
MODEL_ID = "basically-ai/Pebble-25M-Chat"
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def main():
|
| 113 |
+
print("Loading Pebble-25M-Chat...")
|
| 114 |
+
|
| 115 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 116 |
+
MODEL_ID,
|
| 117 |
+
trust_remote_code=True,
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 121 |
+
MODEL_ID,
|
| 122 |
+
trust_remote_code=True,
|
| 123 |
+
dtype=torch.float32,
|
| 124 |
+
).to("cuda")
|
| 125 |
+
|
| 126 |
+
model.eval()
|
| 127 |
+
|
| 128 |
+
print(
|
| 129 |
+
f"Model loaded successfully! "
|
| 130 |
+
f"VRAM usage: {torch.cuda.memory_allocated() / 1e9:.2f} GB"
|
| 131 |
+
)
|
| 132 |
+
print("Type 'quit' or 'exit' to stop.\n")
|
| 133 |
+
|
| 134 |
+
while True:
|
| 135 |
+
prompt = input("You: ")
|
| 136 |
+
|
| 137 |
+
if prompt.lower() in ["quit", "exit"]:
|
| 138 |
+
break
|
| 139 |
+
|
| 140 |
+
# Format the prompt for the chat model
|
| 141 |
+
formatted_prompt = f"User: {prompt}\nAssistant: "
|
| 142 |
+
|
| 143 |
+
# Tokenize the prompt
|
| 144 |
+
inputs = tokenizer(
|
| 145 |
+
formatted_prompt,
|
| 146 |
+
return_tensors="pt",
|
| 147 |
+
).to("cuda")
|
| 148 |
+
|
| 149 |
+
# Generate text
|
| 150 |
+
print("Pebble: ", end="", flush=True)
|
| 151 |
+
|
| 152 |
+
with torch.inference_mode():
|
| 153 |
+
outputs = model.generate(
|
| 154 |
+
**inputs,
|
| 155 |
+
max_new_tokens=100,
|
| 156 |
+
do_sample=True,
|
| 157 |
+
temperature=0.7,
|
| 158 |
+
top_k=50,
|
| 159 |
+
top_p=0.95,
|
| 160 |
+
repetition_penalty=1.2,
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
# Decode and print (skip the prompt part)
|
| 164 |
+
generated_text = tokenizer.decode(
|
| 165 |
+
outputs[0][inputs["input_ids"].shape[1]:],
|
| 166 |
+
skip_special_tokens=True,
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
print(generated_text)
|
| 170 |
+
print()
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
if __name__ == "__main__":
|
| 174 |
+
main()
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
## License
|
| 178 |
+
|
| 179 |
+
Apache 2.0
|