Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time
Paper • 2203.05482 • Published • 9
How to use kh38/my-cool-model1126 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="kh38/my-cool-model1126")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("kh38/my-cool-model1126")
model = AutoModelForCausalLM.from_pretrained("kh38/my-cool-model1126", device_map="auto")
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=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use kh38/my-cool-model1126 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "kh38/my-cool-model1126"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "kh38/my-cool-model1126",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/kh38/my-cool-model1126
How to use kh38/my-cool-model1126 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "kh38/my-cool-model1126" \
--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": "kh38/my-cool-model1126",
"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 "kh38/my-cool-model1126" \
--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": "kh38/my-cool-model1126",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use kh38/my-cool-model1126 with Docker Model Runner:
docker model run hf.co/kh38/my-cool-model1126
This is a merge of pre-trained language models created using mergekit.
This model was merged using the linear merge method.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
dtype: bfloat16
merge_method: linear
parameters:
int8_mask: 1.0
normalize: 1.0
slices:
- sources:
- layer_range: [0, 4]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.6682912881042561
- layer_range: [0, 4]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.8169238866732543
- sources:
- layer_range: [4, 8]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.824383032378547
- layer_range: [4, 8]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.585658209873855
- sources:
- layer_range: [8, 12]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.27646115516439407
- layer_range: [8, 12]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.6421834326611193
- sources:
- layer_range: [12, 16]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.19263623796034313
- layer_range: [12, 16]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.28408471038937055
- sources:
- layer_range: [16, 20]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.5452257394072989
- layer_range: [16, 20]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.5345283738895676
- sources:
- layer_range: [20, 24]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.6694408493851071
- layer_range: [20, 24]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.36909260818773304
- sources:
- layer_range: [24, 28]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.5611229475708517
- layer_range: [24, 28]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.1981276090509695
- sources:
- layer_range: [28, 32]
model: ../evol_merge_storage/input_models/Llama-3.1-Swallow-8B-v0.2_4249862252
parameters:
weight: 0.6876393865290468
- layer_range: [28, 32]
model: ../evol_merge_storage/input_models/Meta-Llama-3-8B-Instruct_fictional_mathqa_Spanish_v1_2935777833
parameters:
weight: 0.15713286244650526