Resolving Interference When Merging Models
Paper • 2306.01708 • Published • 19
How to use ClaudioItaly/Chronicle-Qwen2.5-7B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="ClaudioItaly/Chronicle-Qwen2.5-7B")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ClaudioItaly/Chronicle-Qwen2.5-7B")
model = AutoModelForCausalLM.from_pretrained("ClaudioItaly/Chronicle-Qwen2.5-7B")
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 ClaudioItaly/Chronicle-Qwen2.5-7B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ClaudioItaly/Chronicle-Qwen2.5-7B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ClaudioItaly/Chronicle-Qwen2.5-7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/ClaudioItaly/Chronicle-Qwen2.5-7B
How to use ClaudioItaly/Chronicle-Qwen2.5-7B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ClaudioItaly/Chronicle-Qwen2.5-7B" \
--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": "ClaudioItaly/Chronicle-Qwen2.5-7B",
"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 "ClaudioItaly/Chronicle-Qwen2.5-7B" \
--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": "ClaudioItaly/Chronicle-Qwen2.5-7B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use ClaudioItaly/Chronicle-Qwen2.5-7B with Docker Model Runner:
docker model run hf.co/ClaudioItaly/Chronicle-Qwen2.5-7B
This is a merge of pre-trained language models created using mergekit.
This model was merged using the TIES merge method using nbeerbower/Dumpling-Qwen2.5-7B-1k-r32-2e-5 as a base.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
models:
# Modello 1: Aggiunge la creatività generale al modello base (Dumpling)
- model: ZeroXClem/Qwen2.5-7B-HomerCreative-Mix
parameters:
# density: Viene applicata la density globale specificata sotto
weight: 0.75 # Peso più alto rispetto all'altro modello nella lista, per dare priorità alle sue caratteristiche (creatività) da aggiungere al base
# Modello 2: Aggiunge le sue specifiche caratteristiche al modello base (Dumpling)
- model: Cran-May/T.E-8.1
parameters:
# density: Viene applicata la density globale specificata sotto
weight: 0.25 # Peso inferiore per le sue caratteristiche da aggiungere al base
# NOTA IMPORTANTE: Il modello base (base_model) NON viene incluso nella lista 'models'
# Nel metodo TIES, 'mergekit' calcola i "task vectors" come (modello_in_lista - base_model).
# Questi vettori di differenza vengono poi potati, normalizzati (se normalize: true) e sommati pesati,
# e infine aggiunti al base_model.
# Quindi, nbeerbower/Dumpling-Qwen2.5-7B-1k-r32-2e-5 è il punto di partenza, e aggiungiamo un mix delle differenze degli altri due modelli rispetto a Dumpling.
merge_method: ties
base_model: nbeerbower/Dumpling-Qwen2.5-7B-1k-r32-2e-5 # Nuovo modello base
parameters:
density: 0.7 # Percentuale di parametri non nulli da mantenere nei task vectors di *ciascuno* dei modelli nella lista 'models'.
# mask_threshold: 0.02 # Rimosso, non si applica a TIES.
normalize: true # Normalizza i task vectors potati prima di applicare i pesi. Raccomandato con TIES multi-modello.
int8_mask: true # Opzione utile per risparmiare memoria.
dtype: bfloat16 # Corrisponde al dtype del nuovo modello base.