Text Generation
Transformers
Safetensors
PyTorch
English
pebble_50m
pebble
base-model
mamba
mamba2
hybrid
custom-architecture
custom_code
Run this model with HF Jobs
Run basically-experimental/Pebble-50M-beta on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/basically-experimental/Pebble-50M-beta. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/basically-experimental/Pebble-50M-beta on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/basically-experimental/Pebble-50M-beta. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/basically-experimental/Pebble-50M-beta. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use basically-experimental/Pebble-50M-beta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use basically-experimental/Pebble-50M-beta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="basically-experimental/Pebble-50M-beta", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("basically-experimental/Pebble-50M-beta", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use basically-experimental/Pebble-50M-beta with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "basically-experimental/Pebble-50M-beta" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "basically-experimental/Pebble-50M-beta", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/basically-experimental/Pebble-50M-beta
- SGLang
How to use basically-experimental/Pebble-50M-beta 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-experimental/Pebble-50M-beta" \ --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-experimental/Pebble-50M-beta", "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-experimental/Pebble-50M-beta" \ --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-experimental/Pebble-50M-beta", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use basically-experimental/Pebble-50M-beta with Docker Model Runner:
docker model run hf.co/basically-experimental/Pebble-50M-beta
Update modeling_pebble.py
Browse files90 unmodified lines9192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231 unmodified line1251261271281291301311321331345 unmodified lines14014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017190 unmodified linesself.d_inner = expand * d_modelself.headdim = headdimself.nheads = self.d_inner // headdimself.in_proj = nn.Linear(d_model, 2 * self.d_inner + 2 * d_state + self.nheads, bias=False)self.out_proj = nn.Linear(self.d_inner, d_model, bias=False)self.norm = RMSNorm(self.d_inner, eps=config.rms_norm_eps)self.conv1d = nn.Conv1d(self.d_inner, self.d_inner, d_conv, padding=d_conv-1, groups=self.d_inner, bias=True)# In Mamba2, A_log is just (nheads,)self.A_log = nn.Parameter(torch.zeros(self.nheads, dtype=torch.float32))self.D = nn.Parameter(torch.ones(self.nheads))self.dt_bias = nn.Parameter(torch.ones(self.nheads))def forward(self, x):B, T, C = x.shapexz = self.in_proj(x)x_part, z, dt, B_p, C_p = xz.split([self.d_inner, self.d_inner, self.nheads, self.d_state, self.d_state], dim=-1)# Conv1dx_part = x_part.transpose(1, 2)x_part = self.conv1d(x_part)[:, :, :T]x_part = x_part.transpose(1, 2)x_part = F.silu(x_part)# Normx_part = self.norm(x_part)z = self.norm(z)# Discretization1 unmodified lineA = -torch.exp(self.A_log)# Reshape for multi-head SSMx_part = x_part.view(B, T, self.nheads, self.headdim)z = z.view(B, T, self.nheads, self.headdim)# B and C are (B, T, d_state) -> (B, T, 1, 1, d_state)B_p = B_p.view(B, T, 1, 1, self.d_state)C_p = C_p.view(B, T, 1, 1, self.d_state)5 unmodified linesys = []for t in range(T):# dt_t is (B, nheads, 1, 1)dt_t = dt[:, t].view(B, self.nheads, 1, 1)dA = torch.exp(dt_t * A)# dB is (B, nheads, 1, d_state)dB = dt_t * B_p[:, t]# x_t is (B, nheads, 1, headdim)x_t = x_part[:, t].unsqueeze(2)# h is (B, nheads, d_state, headdim)h = dA * h + (dB.transpose(-1, -2) * x_t)# y is (B, nheads, headdim)y = (h * C_p[:, t].transpose(-1, -2)).sum(dim=2)ys.append(y)y = torch.stack(ys, dim=1)y = y.view(B, T, self.d_inner)# D skip connection# D is (nheads,) -> (1, 1, nheads, 1)D = self.D.view(1, 1, self.nheads, 1)y = y + (x_part * D).view(B, T, self.d_inner)# Gate and Out Projout = y * zout = self.out_proj(out)return out90 unmodified lines9192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451 unmodified line1471481491501511521531541551565 unmodified lines16216316416516616716816917017117217317417517617717817918018118218318490 unmodified linesself.d_inner = expand * d_modelself.headdim = headdimself.nheads = self.d_inner // headdimself.d_conv = d_convself.in_proj = nn.Linear(d_model, 2 * self.d_inner + 2 * d_state + self.nheads, bias=False)self.out_proj = nn.Linear(self.d_inner, d_model, bias=False)self.norm = RMSNorm(self.d_inner, eps=config.rms_norm_eps)# Conv1d takes x, B, and C combined (d_inner + 2 * d_state)conv_in_channels = self.d_inner + 2 * d_stateself.conv1d = nn.Conv1d(in_channels=conv_in_channels,out_channels=conv_in_channels,kernel_size=d_conv,padding=d_conv-1,groups=conv_in_channels,bias=True)self.A_log = nn.Parameter(torch.zeros(self.nheads, dtype=torch.float32))self.D = nn.Parameter(torch.ones(self.nheads))self.dt_bias = nn.Parameter(torch.ones(self.nheads))def forward(self, x):B, T, C = x.shapexzbc = self.in_proj(x)# Split into x, z, B, C, dtx, z, B_p, C_p, dt = torch.split(xzbc,[self.d_inner, self.d_inner, self.d_state, self.d_state, self.nheads],dim=-1)# Apply conv1d to x, B, C combinedxbc = torch.cat([x, B_p, C_p], dim=-1)xbc = xbc.transpose(1, 2)xbc = self.conv1d(xbc)[:, :, :T]xbc = xbc.transpose(1, 2)x, B_p, C_p = torch.split(xbc,[self.d_inner, self.d_state, self.d_state],dim=-1)# Activationx = F.silu(x)# Normx = self.norm(x)z = self.norm(z)# Discretization1 unmodified lineA = -torch.exp(self.A_log)# Reshape for multi-head SSMx = x.view(B, T, self.nheads, self.headdim)z = z.view(B, T, self.nheads, self.headdim)# B and C are (B, T, d_state) -> (B, T, 1, 1, d_state) to broadcast across headsB_p = B_p.view(B, T, 1, 1, self.d_state)C_p = C_p.view(B, T, 1, 1, self.d_state)5 unmodified linesys = []for t in range(T):dt_t = dt[:, t].view(B, self.nheads, 1, 1)dA = torch.exp(dt_t * A)dB = dt_t * B_p[:, t]x_t = x[:, t].unsqueeze(2)h = dA * h + (dB.transpose(-1, -2) * x_t)y = (h * C_p[:, t].transpose(-1, -2)).sum(dim=2)ys.append(y)y = torch.stack(ys, dim=1)y = y.view(B, T, self.d_inner)D = self.D.view(1, 1, self.nheads, 1)y = y + (x * D).view(B, T, self.d_inner)out = y * zout = self.out_proj(out)return out
modeling_pebble.py+37-24