{"id":18293455,"url":"https://github.com/archinetai/difformer-pytorch","last_synced_at":"2025-04-05T11:31:02.100Z","repository":{"id":58817044,"uuid":"533909831","full_name":"archinetai/difformer-pytorch","owner":"archinetai","description":"Diffusion based transformer, in PyTorch (Experimental).","archived":false,"fork":false,"pushed_at":"2022-09-13T10:01:06.000Z","size":15,"stargazers_count":24,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T03:34:25.727Z","etag":null,"topics":["artificial-intelligence","deep-learning","diffusion","transformer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archinetai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-07T19:24:22.000Z","updated_at":"2024-12-05T02:56:31.000Z","dependencies_parsed_at":"2022-09-08T01:02:37.711Z","dependency_job_id":null,"html_url":"https://github.com/archinetai/difformer-pytorch","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fdifformer-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fdifformer-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fdifformer-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fdifformer-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archinetai","download_url":"https://codeload.github.com/archinetai/difformer-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247330547,"owners_count":20921651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["artificial-intelligence","deep-learning","diffusion","transformer"],"created_at":"2024-11-05T14:24:38.167Z","updated_at":"2025-04-05T11:31:01.799Z","avatar_url":"https://github.com/archinetai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Difformer - PyTorch (Experimental)\n\nDiffusion based transformer, in PyTorch.\n\n```bash\npip install difformer-pytorch\n```\n[![PyPI - Python Version](https://img.shields.io/pypi/v/difformer-pytorch?style=flat\u0026colorA=black\u0026colorB=black)](https://pypi.org/project/difformer-pytorch/)\n\n\n## Usage\n\n### Token based\n```python\nfrom difformer_pytorch import Difformer\n\nnum_tokens = 1000\n\ndifformer = Difformer(\n    num_tokens=num_tokens,\n    embedding_dim=512,\n    num_layers=6\n)\n\n# Input tokens and mask\ntokens = torch.randint(0, num_tokens, (1, 1024))\nmask = torch.ones_like(x).bool()\n\n# Train difformer to demask\nloss = difformer(tokens=tokens, mask=mask)\nloss.backward()\n\n# Sample unmasked prediction given masked start sequence\nsampled = difformer.sample(\n    tokens=tokens,\n    mask=mask,\n    num_steps=5\n) # [1, 1024]\n\n```\n\n### Embedding based\n```py\nfrom difformer_pytorch import Difformer\n\ndifformer = Difformer(\n    embedding_dim=512,\n    num_layers=6\n)\n\n# Input embedding and mask\nembedding = torch.randn(1, 1024, 512)\nmask = torch.ones(1, 1024).bool()\n\n# Train difformer\nloss = difformer(embedding=embedding, mask=mask)\nloss.backward()\n\n# Sample prediction given masked start embedding\nsampled = difformer.sample(\n    embedding=embedding,\n    mask=mask, # Optional mask to apply on embeddings\n    num_steps=5\n) # [1, 1024, 512]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchinetai%2Fdifformer-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchinetai%2Fdifformer-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchinetai%2Fdifformer-pytorch/lists"}