| #!/bin/bash |
| |
| set -uo pipefail |
| pip install -q "transformers==4.46.2" "huggingface_hub<1.0" "datasets<4" "accelerate" 2>&1 | tail -1 |
| python -c " |
| from huggingface_hub import snapshot_download |
| snapshot_download('ashishk1331/ccd-repro-code', repo_type='dataset', local_dir='/work')" |
| cd /work |
|
|
| python - <<'EOF' |
| import sys, torch |
| sys.path.insert(0, "scripts") |
| from transformers import AutoModel, AutoTokenizer |
| from datasets import load_dataset |
| import ccd_decode |
| from run_eval import humaneval_prompt |
|
|
| M = "Dream-org/Dream-v0-Instruct-7B" |
| tok = AutoTokenizer.from_pretrained(M, trust_remote_code=True) |
| model = AutoModel.from_pretrained(M, torch_dtype=torch.bfloat16, |
| trust_remote_code=True).to("cuda").eval() |
| doc = load_dataset("openai/openai_humaneval", split="test")[0] |
| p = humaneval_prompt(tok, doc) |
| enc = tok(p, return_tensors="pt") |
| print("prompt tokens:", enc.input_ids.shape) |
| print("prompt tail ids:", enc.input_ids[0, -8:].tolist()) |
| print("prompt tail dec:", repr(tok.decode(enc.input_ids[0, -8:].tolist()))) |
|
|
| |
| x, st = ccd_decode.generate( |
| model, enc.input_ids.to("cuda"), attention_mask=enc.attention_mask.to("cuda"), |
| max_new_tokens=256, steps=256, temperature=0.1, top_p=0.9, |
| mask_token_id=model.config.mask_token_id, method="baseline") |
| gen = x[0, enc.input_ids.shape[1]:] |
| ids = gen.tolist() |
| print("\nfirst 24 generated ids:", ids[:24]) |
| print("unique ids (count):", len(set(ids))) |
| from collections import Counter |
| print("most common ids:", Counter(ids).most_common(6)) |
| print("\nRAW decode (no split), first 400 chars:") |
| print(repr(tok.decode(ids)[:400])) |
| print("\nDecode skip_special_tokens=True, first 400:") |
| print(repr(tok.decode(ids, skip_special_tokens=True)[:400])) |
| print("\neos_token:", repr(tok.eos_token), tok.eos_token_id) |
| print("split-on-eos result (first 200):", repr(tok.decode(ids).split(tok.eos_token)[0][:200])) |
| EOF |
|
|