datavorous/Demoscener-Dweets-25k
Viewer โข Updated โข 26.3k โข 59 โข 4
How to use datavorous/Demoscener-7B with PEFT:
Task type is invalid.
Demoscener-7B adapts Qwen2.5-Coder-7B Base to short Dwitter JavaScript animations. This repository contains three independently loadable PEFT LoRA adapters:
| Adapter | Training stage | Use it to study |
|---|---|---|
cpt/ |
Continued pretraining on Dwitter code | Dwitter syntax and code completion |
curriculum/ |
CPT followed by training on awesomeness ranked dweets | The effect of ranking-based training |
grpo/ |
CPT, curriculum, then human preference optimisation | The effect of preference training |
from pathlib import Path
from huggingface_hub import snapshot_download
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = Path(snapshot_download("datavorous/Demoscener-7B"))
base_id = "Qwen/Qwen2.5-Coder-7B" # Base, not Instruct
tokenizer = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(base_id, device_map="auto")
model = PeftModel.from_pretrained(base, str(repo / "cpt"), adapter_name="cpt")
model.load_adapter(str(repo / "curriculum"), adapter_name="curriculum")
model.load_adapter(str(repo / "grpo"), adapter_name="grpo")
inputs = tokenizer("c.width=1920;for(i=0;i<80;i++)x.fillRect(",
return_tensors="pt", add_special_tokens=False).to(model.device)
for stage in ("cpt", "curriculum", "grpo"):
model.set_adapter(stage)
output = model.generate(**inputs, max_new_tokens=96, do_sample=False,
pad_token_id=tokenizer.eos_token_id)
continuation = output[0][inputs.input_ids.shape[-1]:]
print(stage, tokenizer.decode(continuation, skip_special_tokens=True))
CPT used Dwitter programs; curriculum continued from CPT using the top 5,000 dweets ranked by awesomeness; GRPO then used human choices among generated continuations. Later stages were trained on quantized bases, so their probabilities on a shared BF16 base may differ from those of the original training runs.