Skip to content
/ minMamba Public

Minimal PyTorch reimplementation of the Mamba architecture a la Kaparthys minGPT

License

Notifications You must be signed in to change notification settings

lckr/minMamba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minMamba

A simple PyTorch re-implementation of Mamba in a single file. minMamba tries to be small, clean, interpretable and educational.

Library Installation

If you want to import minmamba into your project:

git clone https://github.com/lckr/minMamba.git
cd minMamba
pip install -e .

Usage

Here's how you'd load a pretrained Mamba model from Huggingface Hub:

import minmamba.model
pretrained_model = minmamba.model.MambaLMModel.from_pretrained("state-spaces/mamba-130m")

And here's how you'd run inference with it:

from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b") # tokenizer used by "state-spaces/mamba-130m"

input_seq = tokenizer("A fish is a ", return_tensors="pt")["input_ids"]
gen_seq = pretrained_model.generate(input_seq, 100)
print(tokenizer.decode(gen_seq[0]))

References

Code:

Paper:

Mamba: Linear-Time Sequence Modeling with Selective State Spaces
Albert Gu*, Tri Dao*
Paper: https://arxiv.org/abs/2312.00752

License

MIT

About

Minimal PyTorch reimplementation of the Mamba architecture a la Kaparthys minGPT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages