Editing Models with Task Arithmetic
Paper • 2212.04089 • Published • 8
How to use tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
pipe(text=messages) # Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic")
model = AutoModelForMultimodalLM.from_pretrained("tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic")
messages = [
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
{"type": "text", "text": "What animal is on the candy?"}
]
},
]
inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'docker model run hf.co/tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic
How to use tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic" \
--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": "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'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 "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic" \
--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": "tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image in one sentence."
},
{
"type": "image_url",
"image_url": {
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
}
}
]
}
]
}'How to use tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic with Docker Model Runner:
docker model run hf.co/tepirale/gemma-4-12B-merge-coder40-agentic40-it20-task_arithmetic
This is a merge of pre-trained language models created using mergekit.
This model was merged using the Task Arithmetic merge method using google/gemma-4-12B-it as a base.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
merge_method: task_arithmetic
base_model: google/gemma-4-12B-it
dtype: bfloat16
parameters:
normalize: true
models:
- model: google/gemma-4-12B-it
parameters:
weight: 1.0 # Base limpia que mantiene la estructura gramatical
- model: tepirale/gemma-4-12B-coder-fable5-composer2.5-v1-safetensors-yuxinlu1
parameters:
weight: 0.35 # Inyecta la habilidad de código puro
- model: tepirale/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-safetensors-yuxinlu1
parameters:
weight: 0.35 # Inyecta la lógica y uso de herramientas de agente