Making LLMs Smaller Without Breaking Them: A GLU-Aware Pruning Approach
oopere
• • 20How to use oopere/pruned40-gemma-2-2b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="oopere/pruned40-gemma-2-2b") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("oopere/pruned40-gemma-2-2b")
model = AutoModelForCausalLM.from_pretrained("oopere/pruned40-gemma-2-2b")How to use oopere/pruned40-gemma-2-2b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "oopere/pruned40-gemma-2-2b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "oopere/pruned40-gemma-2-2b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/oopere/pruned40-gemma-2-2b
How to use oopere/pruned40-gemma-2-2b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "oopere/pruned40-gemma-2-2b" \
--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": "oopere/pruned40-gemma-2-2b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "oopere/pruned40-gemma-2-2b" \
--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": "oopere/pruned40-gemma-2-2b",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use oopere/pruned40-gemma-2-2b with Docker Model Runner:
docker model run hf.co/oopere/pruned40-gemma-2-2b
This model is a pruned version of the Gemma-2b architecture, with a parameter reduction of 40% in the MLP Layers. The pruning process aims to enhance computational efficiency while maintaining acceptable performance across specific tasks. This model is not intended to be used directly, but rather to be fine-tuned for specific tasks where it can achieve equal or superior performance compared to fine-tuning the base model for the same task.
Base Model:
Pruned Model (40%):
Memory Reduction:
docker model run hf.co/oopere/pruned40-gemma-2-2b