ranjanrajib commited on
Commit
b1e2897
·
verified ·
1 Parent(s): 8954115

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md CHANGED
@@ -20,6 +20,56 @@ attempts, where some samples passed a problem's tests and others failed.
20
  **Base model:** `Qwen/Qwen2.5-Coder-7B-Instruct` at snapshot
21
  `c03e6d358207e414f1eca0bb1891e29f1db0e242`. The merge was performed against exactly these weights.
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ## What was measured, and what it does and does not show
24
 
25
  On `python_eval_v3` — 508 BigCodeBench problems held out of training, 10 samples per problem at
 
20
  **Base model:** `Qwen/Qwen2.5-Coder-7B-Instruct` at snapshot
21
  `c03e6d358207e414f1eca0bb1891e29f1db0e242`. The merge was performed against exactly these weights.
22
 
23
+ ## Downloading and using
24
+
25
+ ### The merged model (what most people want)
26
+
27
+ ```python
28
+ from transformers import AutoModelForCausalLM, AutoTokenizer
29
+
30
+ model = AutoModelForCausalLM.from_pretrained(
31
+ "ranjanrajib/DPO-trained-Qwen2.5-Coder-7B", dtype="bfloat16", device_map="auto")
32
+ tok = AutoTokenizer.from_pretrained("ranjanrajib/DPO-trained-Qwen2.5-Coder-7B")
33
+
34
+ msgs = [{"role": "user", "content": "Write a Python function that merges overlapping intervals."}]
35
+ text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
36
+ out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=512)
37
+ print(tok.decode(out[0], skip_special_tokens=True))
38
+ ```
39
+
40
+ Or fetch the files without loading them (~14 GB, four shards):
41
+
42
+ ```bash
43
+ hf download ranjanrajib/DPO-trained-Qwen2.5-Coder-7B --exclude "adapter/*" --local-dir ./d4
44
+ ```
45
+
46
+ ### The LoRA adapter only (308 MB)
47
+
48
+ The adapter lives in `adapter/`. Applying it to the base model gives the same result as the
49
+ merged weights, at a fraction of the download.
50
+
51
+ ```bash
52
+ hf download ranjanrajib/DPO-trained-Qwen2.5-Coder-7B --include "adapter/*" --local-dir ./d4-lora
53
+ ```
54
+
55
+ ```python
56
+ import torch
57
+ from peft import PeftModel
58
+ from transformers import AutoModelForCausalLM
59
+
60
+ BASE = "Qwen/Qwen2.5-Coder-7B-Instruct"
61
+ REVISION = "c03e6d358207e414f1eca0bb1891e29f1db0e242" # the snapshot this was trained against
62
+
63
+ base = AutoModelForCausalLM.from_pretrained(
64
+ BASE, revision=REVISION, dtype=torch.bfloat16, device_map="auto")
65
+ model = PeftModel.from_pretrained(
66
+ base, "ranjanrajib/DPO-trained-Qwen2.5-Coder-7B", subfolder="adapter")
67
+ ```
68
+
69
+ **Pin the revision.** The adapter's own config does not record one, so omitting `revision`
70
+ silently applies it to whatever `main` points at. Today that is the same snapshot; it will not
71
+ stay true forever, and an adapter applied to different base weights is not this model.
72
+
73
  ## What was measured, and what it does and does not show
74
 
75
  On `python_eval_v3` — 508 BigCodeBench problems held out of training, 10 samples per problem at