Views
No views yet

transformers>=4.52.21from transformers import AutoModel, AutoTokenizer
2import torch
3
4repo_name = "nvidia/Efficient-DLM-8B"
5
6tokenizer = AutoTokenizer.from_pretrained(repo_name, trust_remote_code=True)
7model = AutoModel.from_pretrained(repo_name, trust_remote_code=True)
8model = model.cuda().to(torch.bfloat16)
9
10user_input = input("User: ").strip()
11
12prompt_ids = tokenizer(user_input, return_tensors="pt").input_ids.to(device="cuda")
13out_ids, nfe = model.generate(
14 prompt_ids,
15 max_new_tokens=128,
16 steps=128,
17 block_length=32,
18 shift_logits=False,
19 temperature=0.7,
20 threshold=0.9,
21)
22
23response = tokenizer.batch_decode(out_ids[:, prompt_ids.shape[1]:], skip_special_tokens=True)[0]
24print(f"Model: {response}")
25print(f"[Num Function Eval (NFE)={nfe}]")@article{fu2025efficient,
title={Efficient-dlm: From autoregressive to diffusion language models, and beyond in speed},
author={Fu, Yonggan and Whalen, Lexington and Ye, Zhifan and Dong, Xin and Diao, Shizhe and Liu, Jingyu and Wu, Chengyue and Zhang, Hao and Xie, Enze and Han, Song and others},
journal={arXiv preprint arXiv:2512.14067},
year={2025}
}