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
Download modeling_pollock.py from SlayerLab/pollock-mini-lm-125m: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/SlayerLab/pollock-mini-lm-125m/resolve/main/modeling_pollock.py
- Command line
-
hf download hf://SlayerLab/pollock-mini-lm-125m/modeling_pollock.py
-
curl -L -o modeling_pollock.py https://huggingface.co/SlayerLab/pollock-mini-lm-125m/resolve/main/modeling_pollock.py
1.4 kB
| """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) | |