Transfusion in Pytorch
Project description
Transfusion - Pytorch (wip)
Pytorch implementation of Transfusion, "Predict the Next Token and Diffuse Images with One Multi-Modal Model", from MetaAI.
Once completed, will also extend this to flow matching, as well as audio, video, perhaps even policies.
Install
$ pip install transfusion-pytorch
Usage
import torch
from transfusion_pytorch import Transfusion
model = Transfusion(
num_text_tokens = 256,
transformer = dict(
dim = 512,
depth = 8
)
)
text_ids = torch.randint(0, 256, (2, 1024))
modality_tokens = [[
torch.randn(6, 512),
torch.randn(4, 512)
], [
torch.randn(5, 512),
torch.randn(3, 512)
]]
modality_positions = [[
(2, 6),
(10, 4)
], [
(2, 5),
(10, 3)
]] # (offset, length)
loss, breakdown = model(
text_ids,
modality_tokens = modality_tokens,
modality_positions = modality_positions
)
loss.backward()
Citations
@inproceedings{Zhou2024TransfusionPT,
title = {Transfusion: Predict the Next Token and Diffuse Images with One Multi-Modal Model},
author = {Chunting Zhou and Lili Yu and Arun Babu and Kushal Tirumala and Michihiro Yasunaga and Leonid Shamis and Jacob Kahn and Xuezhe Ma and Luke Zettlemoyer and Omer Levy},
year = {2024},
url = {https://api.semanticscholar.org/CorpusID:271909855}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
transfusion_pytorch-0.0.3.tar.gz
(345.3 kB
view hashes)
Built Distribution
Close
Hashes for transfusion_pytorch-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 156c5f7121208ca5b4ef83828cff2c7033e808c121aebfed4d02ce8b29a2cafd |
|
MD5 | df424fe96c48a4e83f9d0ed57ad70f06 |
|
BLAKE2b-256 | 8bcc24169edf2abc833baa1ce67026f5afb203c00b0edf190b00409b46ed0608 |
Close
Hashes for transfusion_pytorch-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd1c986d841a590de0ad8f7dd9b5994deef78d200b878c56d20eeb9ec507d71a |
|
MD5 | 2daa8b02b3725498f98afa66209870ea |
|
BLAKE2b-256 | 27c97205bceafe7e0c5be2d572f07e6b2fae2c4e324a60d13b7385ec2e2be56e |