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.4.tar.gz
(345.4 kB
view hashes)
Built Distribution
Close
Hashes for transfusion_pytorch-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fb52339da0a148e481cc80d082c1bd9d234e7206be5ace052027bd150838f64 |
|
MD5 | 4efa8aa55248f12ea49d7dece508e89b |
|
BLAKE2b-256 | 733ca9d23d2362a550e949c7b5f396ece1e3b3ba18157328903f3f59dc15b8d4 |
Close
Hashes for transfusion_pytorch-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a29bb8e968392a60879dda288bd7aad88a74108ab0f794ceb721b64774f4d0d4 |
|
MD5 | 906aab4e69b95f9d09b6dccd74fc93eb |
|
BLAKE2b-256 | 4ba762a529b44b7ab2ce1d934f108b49f9508347290c94db99d3e4fbaca4df97 |