Text Generation
Transformers
Safetensors
English
pollock
causal-lm
gpt2
nanogpt
swiglu
bpe
educational
base-model
custom_code
Eval Results (legacy)
Instructions to use SlayerLab/pollock-mini-lm-125m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SlayerLab/pollock-mini-lm-125m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SlayerLab/pollock-mini-lm-125m", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("SlayerLab/pollock-mini-lm-125m", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SlayerLab/pollock-mini-lm-125m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SlayerLab/pollock-mini-lm-125m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SlayerLab/pollock-mini-lm-125m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/SlayerLab/pollock-mini-lm-125m
- SGLang
How to use SlayerLab/pollock-mini-lm-125m 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 "SlayerLab/pollock-mini-lm-125m" \ --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": "SlayerLab/pollock-mini-lm-125m", "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 "SlayerLab/pollock-mini-lm-125m" \ --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": "SlayerLab/pollock-mini-lm-125m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use SlayerLab/pollock-mini-lm-125m with Docker Model Runner:
docker model run hf.co/SlayerLab/pollock-mini-lm-125m
File size: 1,401 Bytes
f8bd6fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """Transformers implementation used to package Pollock SwiGLU checkpoints."""
import torch.nn as nn
import torch.nn.functional as F
from transformers import GPT2Config, GPT2LMHeadModel
from transformers.pytorch_utils import Conv1D
class PollockConfig(GPT2Config):
model_type = "pollock"
def __init__(self, mlp_variant="swiglu", **kwargs):
super().__init__(**kwargs)
self.mlp_variant = mlp_variant
class PollockSwiGLU(nn.Module):
def __init__(self, config):
super().__init__()
n_inner = config.n_inner or 4 * config.hidden_size
self.c_fc = Conv1D(2 * n_inner, config.hidden_size)
self.c_proj = Conv1D(config.hidden_size, n_inner)
self.dropout = nn.Dropout(config.resid_pdrop)
def forward(self, hidden_states):
gate, value = self.c_fc(hidden_states).chunk(2, dim=-1)
hidden_states = F.silu(gate) * value
return self.dropout(self.c_proj(hidden_states))
class PollockForCausalLM(GPT2LMHeadModel):
config_class = PollockConfig
def __init__(self, config):
if config.mlp_variant != "swiglu":
raise ValueError(
f"PollockForCausalLM requires SwiGLU, got {config.mlp_variant!r}"
)
super().__init__(config)
for block in self.transformer.h:
block.mlp = PollockSwiGLU(config)
block.mlp.apply(self._init_weights)
|