Tiny GPTV - Pytorch
Project description
TinyGPTV
Simple Implementation of TinyGPTV in super simple Zeta lego blocks. Here all the modules from figure 2 are implemented in Zeta and Pytorch.
The flow is the following: x -> skip connection -> layer norm -> lora -> mha + lora -> residual_rms_norm -> original_skip_connection -> mlp + rms norm
Install
pip3 install tiny-gptv
Usage
TinyGPTVBlock, Figure3 (c):
- Layernorm
- MHA
- Lora
- QK Norm
- RMS Norm
- MLP
import torch
from tiny_gptv.blocks import TinyGPTVBlock
# Random tensor, replace with your input data
x = torch.rand(2, 8, 512)
# TinyGPTVBlock
block = TinyGPTVBlock(512, 8, depth=10)
# Print the block
print(block)
# Forward pass
out = block(x)
# Print the output shape
print(out.shape)
Figure3 (b) Lora Module for LLMS Block
- MHA,
- Lora,
- Normalization,
- MLP
- Skip connection
- Split then add
import torch
from tiny_gptv import LoraMHA
x = torch.rand(2, 8, 512)
block = LoraMHA(512, 8)
out = block(x)
print(out.shape)
Citation
@misc{yuan2023tinygptv,
title={TinyGPT-V: Efficient Multimodal Large Language Model via Small Backbones},
author={Zhengqing Yuan and Zhaoxu Li and Lichao Sun},
year={2023},
eprint={2312.16862},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tiny_gptv-0.0.5.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file tiny_gptv-0.0.5.tar.gz
.
File metadata
- Download URL: tiny_gptv-0.0.5.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 659f25aec9d149292e99d5ea812fbbf1c2f7ca6e8b94691f5287b6cf00fd7cd8 |
|
MD5 | ba2b964f4a3c3bec60985054236f532b |
|
BLAKE2b-256 | 39d4b88b55f804377ec5a1045df401f9aea5cae5412fd383e21593e7f27cf32e |
File details
Details for the file tiny_gptv-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: tiny_gptv-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83b08d1f178211348d6e6c2b2e24ba38d3cad4062eddd35da2d75581faea1403 |
|
MD5 | 8b67b5d61014b8f4d264eb3553f406e7 |
|
BLAKE2b-256 | 5f4f6012d8709c2795670cde0d90d4b8d20aba7363e4be7979843804a02f7c5d |