AlexWortega commited on
Commit
e368d07
·
verified ·
1 Parent(s): 3eced74

code: gen_ifeval.py

Browse files
Files changed (1) hide show
  1. code/gen_ifeval.py +38 -0
code/gen_ifeval.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Generate IFEval responses with a few Qwen3.5 sizes (vLLM, thinking off) for eval_extra.py's `ifeval` task.
3
+ Labels are NOT computed here: eval_extra.py runs the IFEval strict checker on every response.
4
+
5
+ for m in Qwen/Qwen3.5-0.8B Qwen/Qwen3.5-2B Qwen/Qwen3.5-4B; do # one process per model: vLLM frees memory on exit
6
+ ~/venvs/vllm/bin/python gen_ifeval.py --models $m --out data/ifeval_gen.jsonl; done
7
+ """
8
+ import argparse
9
+ import json
10
+
11
+ from huggingface_hub import hf_hub_download
12
+ from vllm import LLM, SamplingParams
13
+
14
+
15
+ def main():
16
+ ap = argparse.ArgumentParser()
17
+ ap.add_argument("--models", nargs="+", default=["Qwen/Qwen3.5-0.8B", "Qwen/Qwen3.5-2B", "Qwen/Qwen3.5-4B"])
18
+ ap.add_argument("--out", default="data/ifeval_gen.jsonl")
19
+ ap.add_argument("--max-tokens", type=int, default=1536)
20
+ ap.add_argument("--gpu-util", type=float, default=0.85)
21
+ args = ap.parse_args()
22
+ path = hf_hub_download("google/IFEval", "ifeval_input_data.jsonl", repo_type="dataset")
23
+ ds = [json.loads(line) for line in open(path)]
24
+ with open(args.out, "a") as f:
25
+ for m in args.models:
26
+ llm = LLM(m, max_model_len=4096, gpu_memory_utilization=args.gpu_util, limit_mm_per_prompt={"image": 0})
27
+ msgs = [[{"role": "user", "content": ex["prompt"]}] for ex in ds]
28
+ outs = llm.chat(msgs, SamplingParams(temperature=0.7, top_p=0.9, max_tokens=args.max_tokens, seed=0),
29
+ chat_template_kwargs={"enable_thinking": False})
30
+ for ex, o in zip(ds, outs):
31
+ f.write(json.dumps({"model": m, "key": ex["key"], "prompt": ex["prompt"],
32
+ "instruction_id_list": ex["instruction_id_list"], "kwargs": ex["kwargs"],
33
+ "response": o.outputs[0].text}, ensure_ascii=False) + "\n")
34
+ f.flush()
35
+
36
+
37
+ if __name__ == "__main__":
38
+ main()