{"id":19932237,"url":"https://github.com/amazon-science/masked-diffusion-lm","last_synced_at":"2026-04-02T01:34:56.584Z","repository":{"id":161759238,"uuid":"626021474","full_name":"amazon-science/masked-diffusion-lm","owner":"amazon-science","description":"Official implementation for the paper \"A Cheaper and Better Diffusion Language Model with Soft-Masked Noise\"","archived":false,"fork":false,"pushed_at":"2023-08-14T22:24:30.000Z","size":8558,"stargazers_count":59,"open_issues_count":20,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-09T05:10:07.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amazon-science.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-10T16:19:44.000Z","updated_at":"2025-08-25T15:33:39.000Z","dependencies_parsed_at":"2025-05-03T11:42:28.853Z","dependency_job_id":null,"html_url":"https://github.com/amazon-science/masked-diffusion-lm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amazon-science/masked-diffusion-lm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fmasked-diffusion-lm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fmasked-diffusion-lm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fmasked-diffusion-lm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fmasked-diffusion-lm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amazon-science","download_url":"https://codeload.github.com/amazon-science/masked-diffusion-lm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fmasked-diffusion-lm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T23:09:28.473Z","updated_at":"2026-04-02T01:34:56.579Z","avatar_url":"https://github.com/amazon-science.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Cheaper and Better Diffusion Language Model with Soft-Masked Noise\n\n\nThis is the official implementation of the paper: A Cheaper and Better Diffusion Language Model with Soft-Masked Noise.\n\n-----------------------------------------------------\n## Usage\nOne needs to setup the enrironment before running the experiments.\n\n\n## Conda Setup:\n```python \nconda install mpi4py\nconda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch\npip install -e improved-diffusion/ \npip install -e transformers/\npip install spacy==3.2.4\npip install datasets==1.8.0 \npip install huggingface_hub==0.4.0 \npip install wandb\n```\n\n-----------------------------------------------------\n## Train Masked-Diffusion-LM:\n\n\n```cd improved-diffusion; mkdir diffusion_models;```\n\n```python scripts/run_train.py --diff_steps 500 --model_arch bert --lr 0.0003 --lr_anneal_steps 400000  --seed 0 --noise_schedule sqrt  --in_channel 128 --modality roc --submit no --padding_mode pad  --app \"--predict_xstart True --training_mode masked-diffuse-lm  --roc_train ../datasets/ROCstory \"  --bsz 64```\n\n\n\n-------------------\n## Decode Diffusion-LM:\nmkdir generation_outputs \n\n``python scripts/batch_decode.py {path-to-diffusion-lm} -1.0 ema``\n\n\n------------------- \n## Controllable Text Generation \nFirst, train the classsifier used to guide the generation (e.g. a syntactic parser) \n\n``  \npython train_run.py --experiment e2e-tgt-tree  --app \"--init_emb {path-to-diffusion-lm} --n_embd {16} --learned_emb yes \" --pretrained_model bert-base-uncased --epoch 6 --bsz 10\n``\n\nThen, we can use the trained classifier to guide generation. \n(currently, need to update the classifier directory in scripts/infill.py. I will clean this up in the next release.)\n\n``python \npython scripts/infill.py --model_path {path-to-diffusion-lm} --eval_task_ 'control_tree' --use_ddim True  --notes \"tree_adagrad\" --eta 1. --verbose pipe``\n\n\n\n## Acknowledgement\nPart of our codes are adapted from [Diffusion-LM](https://github.com/XiangLi1999/Diffusion-LM) and [Transformers](https://github.com/huggingface/transformers).\n\n\n## License\nThis project is licensed under the Apache-2.0 License.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazon-science%2Fmasked-diffusion-lm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famazon-science%2Fmasked-diffusion-lm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazon-science%2Fmasked-diffusion-lm/lists"}