Editing Models with Task Arithmetic
Paper • 2212.04089 • Published • 9
How to use Edens-Gate/madness-nemo-12b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Edens-Gate/madness-nemo-12b")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Edens-Gate/madness-nemo-12b")
model = AutoModelForCausalLM.from_pretrained("Edens-Gate/madness-nemo-12b", 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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Edens-Gate/madness-nemo-12b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Edens-Gate/madness-nemo-12b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Edens-Gate/madness-nemo-12b",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Edens-Gate/madness-nemo-12b
How to use Edens-Gate/madness-nemo-12b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Edens-Gate/madness-nemo-12b" \
--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": "Edens-Gate/madness-nemo-12b",
"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 "Edens-Gate/madness-nemo-12b" \
--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": "Edens-Gate/madness-nemo-12b",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Edens-Gate/madness-nemo-12b with Docker Model Runner:
docker model run hf.co/Edens-Gate/madness-nemo-12b
This is a merge of pre-trained language models created using mergekit.
This model was merged using the task arithmetic merge method using NewEden/nemo-erebus as a base.
The following models were included in the merge:
The following YAML configuration was used to produce this model:
models:
- model: grimjim/mistralai-Mistral-Nemo-Instruct-2407
parameters:
density: 0.2
weight: 0.23
- model: nbeerbower/mistral-nemo-bophades-12B
parameters:
density: 0.2
weight: 0.43
- model: nbeerbower/mistral-nemo-gutenberg-12B-v4
parameters:
density: 0.2
weight: 0.43
- model: TheDrummer/UnslopNemo-12B-v4.1
parameters:
density: 0.5
weight: 0.63
merge_method: task_arithmetic
base_model: NewEden/nemo-erebus
parameters:
normalize: false
int8_mask: true
dtype: bfloat16
layer_parameters:
- range: [0, 10]
density_multiplier: 1.2
- range: [10, 20]
density_multiplier: 1.0
- range: [20, 30]
density_multiplier: 0.8
- range: [30, 40]
density_multiplier: 0.6
regularization:
- method: gradient_penalty
scale: 0.05
- method: weight_clipping
clip_range: [-0.2, 0.2]
- method: random_noise
scale: 0.01
- method: attention_dropout
scale: 0.1
postprocessing:
- operation: entropy_regularization
scale: 0.05
- operation: non_linear_scaling
parameters:
function: tanh
- operation: sharpening
intensity: 0.5
- operation: gaussian_smoothing
sigma: 1.5
- operation: normalize
- operation: dynamic_scaling
scale_range: [0.8, 1.2]
- operation: smoothing
parameters:
adaptive: true
range: [0.85, 1.15]
kernel_size: 5