DELLA-Merging: Reducing Interference in Model Merging through Magnitude-Based Sampling
Paper • 2406.11617 • Published • 10
How to use Cran-May/PCB-NRSheared-1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Cran-May/PCB-NRSheared-1")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Cran-May/PCB-NRSheared-1")
model = AutoModelForCausalLM.from_pretrained("Cran-May/PCB-NRSheared-1")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Cran-May/PCB-NRSheared-1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Cran-May/PCB-NRSheared-1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Cran-May/PCB-NRSheared-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Cran-May/PCB-NRSheared-1
How to use Cran-May/PCB-NRSheared-1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Cran-May/PCB-NRSheared-1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Cran-May/PCB-NRSheared-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Cran-May/PCB-NRSheared-1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Cran-May/PCB-NRSheared-1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Cran-May/PCB-NRSheared-1 with Docker Model Runner:
docker model run hf.co/Cran-May/PCB-NRSheared-1
This is a merge of pre-trained language models created using mergekit.
This model was merged using the DELLA merge method using huihui-ai/Mistral-Small-24B-Instruct-2501-abliterated as a base.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
# 文件名: pcb_della_merge.yaml
merge_method: della # 基于DELLA的自适应剪裁
base_model: huihui-ai/Mistral-Small-24B-Instruct-2501-abliterated
models:
- model: trashpanda-org/MS-24B-Instruct-Mullein-v0
parameters:
weight: 1.0 # 添加默认权重
# PCB策略:限制层影响范围 + 动态竞争平衡
layers:
- layers: "8-16"
parameter_name: density
value: 0.4
- layers: "8-16"
parameter_name: epsilon
value: 0.15
- layers: "8-16"
parameter_name: lambda
value: 1.5
- layers: "17-24"
parameter_name: density
value: 0.2
variance_threshold: 0.3
- model: AlSamCur123/Mistral-Small3-24B-InstructContinuedFine
parameters:
weight: 1.0 # 添加默认权重
# 强化指令理解层
layers:
- layers: "0-12"
parameter_name: density
value: 0.7
- layers: "0-12"
parameter_name: epsilon
value: 0.05
- layers: "0-12"
parameter_name: lambda
value: 2.0
variance_threshold: 0.25
- model: huihui-ai/Mistral-Small-24B-Instruct-2501-abliterated
parameters:
weight: 1.0 # 添加默认权重
# 基模型参数保护策略
density: 0.9 # 全局密度 (可能需要单独处理)
layers:
- layers: "12-24"
parameter_name: density
value: 1.0
parameters:
global_density: 0.55 # 全局剪裁密度(PCB平衡点)
intra_balance: true
variance_threshold: 0.2
epsilon_range: [0.1, 0.2]
tokenizer:
source: base
# 参数压缩设置(实现12-13B目标)
architecture:
hidden_size: 4096
intermediate_size: 11008
num_attention_heads: 32
num_hidden_layers: 30
docker model run hf.co/Cran-May/PCB-NRSheared-1