Skip to main content

Multi-Modality

MM1

PyTorch Implementation of the paper "MM1: Methods, Analysis & Insights from Multimodal LLM Pre-training".

img -> encoder -> connector -> llm -> tokens 

install

pip3 install mm1-torch

usage

import torch
from mm1_torch.main import MM1

# Tensors
x = torch.randint(0, 100, (1, 512))  # Create a random tensor of shape (1, 512)
img = torch.randn(1, 3, 224, 224)  # Create a random image tensor of shape (1, 3, 224, 224)

# Create a model
model = MM1(
    dim=512,  # Dimension of the input tensor
    depth=12,  # Number of transformer layers
    heads=8,  # Number of attention heads
    dim_head=64,  # Dimension of each attention head
    dropout=0.1,  # Dropout rate
    num_experts=4,  # Number of experts in mixture-of-experts
    num_experts_per_tok=2,  # Number of experts per token in mixture-of-experts
    encoder_dim=512,  # Dimension of the encoder output
    encoder_depth=12,  # Number of encoder transformer layers
    encoder_heads=8,  # Number of encoder attention heads
    use_moe=True,  # Whether to use mixture-of-experts
    return_logits=True  # Whether to return logits or probabilities
)

# Forward
out = model(x, img)  # Forward pass through the model
print(out.shape)  # Print the shape of the output tensor (torch.Size([2, 3, 512]))
print(out)  # Print the output tensor

CAbstractor

import torch
from mm1_torch.main import CAbstractor

# Tensors
x = torch.randn(1, 100, 512)

# Create a model
model = CAbstractor(
    dim=512,
    depth=12,
    heads=8,
)


# Forward
out = model(x)
print(out.shape)

License

MIT

Todo

  • Implement the deformable attention
  • Create a training script for Huggingface datasets
  • Create unit tests for every module

Metadata

Release files for mm1-torch 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mm1-torch 0.0.6
File Size Uploaded
mm1_torch-0.0.6.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mm1-torch 0.0.6
File Interpreter ABI Platform
mm1_torch-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / mm1_torch-0.0.6.tar.gz

Download URL mm1_torch-0.0.6.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4f5d6cb67e51ada13401a42771f21488a5a78376a9ed763f49cae599539d38e3
BLAKE2b-256 checksum
How to use checksums
f3bc8bd107f4e9fe4fd07d7e9e4df833a65ecb7a24edc8f9db61b367e1fde034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0

Release files / mm1_torch-0.0.6-py3-none-any.whl

Download URL mm1_torch-0.0.6-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd23792bfa3604478f4ffd8b2d313cebf52acc9288e1c0e42377f0d4eade02fc
BLAKE2b-256 checksum
How to use checksums
2cfd475139b97e7736cd8dc3c2b0beb48f89f8ddef69bfdbc1197a5a67e58284
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page