Views
No views yet
1from hdlm.hf_utils import smart_model_loader
2from hdlm.epsilon_hybrid.sample import full_diff
3from transformers import GPT2TokenizerFast
4import torch
5
6# Load model using smart loader (automatically detects model type)
7model, cfg, device, accelerator, metaschedule = smart_model_loader(
8 model_path="hdlm-group/hdlm-base-epsilon-0.01",
9 model_type="auto", # automatically detects epsilon_hybrid
10 device="cuda"
11)
12
13# Load tokenizer
14tokenizer = GPT2TokenizerFast.from_pretrained('gpt2')
15
16# Generate text
17prompt = "The future of artificial intelligence"
18prompt_ids = tokenizer.encode(prompt, return_tensors='pt').to(device)
19
20# Full diffusion sampling
21generated = full_diff(
22 model=model,
23 prompt=prompt_ids,
24 batch_size=1,
25 alg='acs', # or 'original', 'remask', 'remdm'
26 steps=512,
27 temperature=1.0,
28 context_length=1024,
29 device=device
30)
31
32# Decode generated text
33generated_text = tokenizer.decode(generated[0], skip_special_tokens=True)
34print(generated_text)1# Text generation evaluation
2python hdlm/eval_generation.py \
3 --checkpoint_path hdlm-group/hdlm-base-epsilon-0.01 \
4 --sampling_method full_diff \
5 --algorithm acs \
6 --save_samples
7
8# Perplexity evaluation
9python hdlm/eval_modeling.py \
10 --checkpoint_path hdlm-group/hdlm-base-epsilon-0.01 \
11 --work_dir "./logs/eval_modeling_epsilon" \
12 --dataset ptboriginal: Standard diffusion samplingacs: Adaptive Correction Sampler with error correctionremask: Remasking strategy for improved qualityremdm: ReMDM-style sampling with probability mixing1@article{fathi2025unifying,
2 title={Unifying autoregressive and diffusion-based sequence generation},
3 author={Fathi, Nima and Scholak, Torsten and No{\"e}l, Pierre-Andr{\'e}},
4 journal={arXiv preprint arXiv:2504.06416},
5 year={2025}
6}