l3-unc/CausalDiagnosticity
Viewer • Updated • 3.2k • 36
How to use l3-unc/qwen2.5-7b_edited_fact_check_v2 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="l3-unc/qwen2.5-7b_edited_fact_check_v2")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("l3-unc/qwen2.5-7b_edited_fact_check_v2")
model = AutoModelForMultimodalLM.from_pretrained("l3-unc/qwen2.5-7b_edited_fact_check_v2")
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 l3-unc/qwen2.5-7b_edited_fact_check_v2 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "l3-unc/qwen2.5-7b_edited_fact_check_v2"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "l3-unc/qwen2.5-7b_edited_fact_check_v2",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/l3-unc/qwen2.5-7b_edited_fact_check_v2
How to use l3-unc/qwen2.5-7b_edited_fact_check_v2 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "l3-unc/qwen2.5-7b_edited_fact_check_v2" \
--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": "l3-unc/qwen2.5-7b_edited_fact_check_v2",
"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 "l3-unc/qwen2.5-7b_edited_fact_check_v2" \
--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": "l3-unc/qwen2.5-7b_edited_fact_check_v2",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use l3-unc/qwen2.5-7b_edited_fact_check_v2 with Docker Model Runner:
docker model run hf.co/l3-unc/qwen2.5-7b_edited_fact_check_v2
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 "l3-unc/qwen2.5-7b_edited_fact_check_v2" \
--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": "l3-unc/qwen2.5-7b_edited_fact_check_v2",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'This model is derived from Qwen/Qwen2.5-7B and has been edited using MEMIT for the fact_check task from the Causal Diagnosticity dataset.
_v1 → The model is edited such that new knowledge is based on target_1 from the related_edits field of each dataset item. _v2 → The model is edited such that new knowledge is based on target_2 from the related_edits field of each dataset item.alg_name: "MEMIT"
layers: [4, 5, 6, 7, 8]
clamp_norm_factor: 4
layer_selection: "all"
fact_token: "subject_last"
v_num_grad_steps: 25
v_lr: 5e-1
v_loss_layer: 27
v_weight_decay: 1e-3
kl_factor: 0.0625
mom2_adjustment: true
mom2_update_weight: 15000
rewrite_module_tmp: "model.layers.{}.mlp.down_proj"
layer_module_tmp: "model.layers.{}"
mlp_module_tmp: "model.layers.{}.mlp"
attn_module_tmp: "model.layers.{}.self_attn"
ln_f_module: "model.norm"
lm_head_module: "lm_head"
mom2_dataset: "wikipedia"
mom2_n_samples: 100000
mom2_dtype: "float32"
model_parallel: False
For more information about the dataset, editing details, and the associated paper, see:
Base model
Qwen/Qwen2.5-7B
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "l3-unc/qwen2.5-7b_edited_fact_check_v2" \ --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": "l3-unc/qwen2.5-7b_edited_fact_check_v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'