{"id":19156188,"url":"https://github.com/kyegomez/hsss","last_synced_at":"2025-05-07T07:34:34.300Z","repository":{"id":222861170,"uuid":"758589043","full_name":"kyegomez/HSSS","owner":"kyegomez","description":"Implementation of a Hierarchical Mamba as described in the paper: \"Hierarchical State Space Models for Continuous Sequence-to-Sequence Modeling\"","archived":false,"fork":false,"pushed_at":"2024-11-11T08:46:31.000Z","size":2295,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T20:16:50.498Z","etag":null,"topics":["ai","artificial-intelligence","jesus","machine-learning","ml","multi-modal","multi-modality","open-source","pytorch","rnn","rnns","ssms","tensorflow","zeta"],"latest_commit_sha":null,"homepage":"https://discord.gg/jkwyyFdANm","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyegomez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["kyegomez"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-02-16T16:37:19.000Z","updated_at":"2024-07-01T21:37:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"95b76831-745d-4a58-a44c-7897f8994793","html_url":"https://github.com/kyegomez/HSSS","commit_stats":null,"previous_names":["kyegomez/hsss"],"tags_count":0,"template":false,"template_full_name":"kyegomez/Python-Package-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FHSSS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FHSSS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FHSSS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FHSSS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyegomez","download_url":"https://codeload.github.com/kyegomez/HSSS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252834093,"owners_count":21811310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","jesus","machine-learning","ml","multi-modal","multi-modality","open-source","pytorch","rnn","rnns","ssms","tensorflow","zeta"],"created_at":"2024-11-09T08:33:32.731Z","updated_at":"2025-05-07T07:34:34.252Z","avatar_url":"https://github.com/kyegomez.png","language":"Python","funding_links":["https://github.com/sponsors/kyegomez"],"categories":[],"sub_categories":[],"readme":"[![Multi-Modality](agorabanner.png)](https://discord.gg/qUtxnK2NMf)\n\n# HSSS\nImplementation of a Hierarchical Mamba as described in the paper: \"Hierarchical State Space Models for Continuous Sequence-to-Sequence Modeling\" but instead of using traditional SSMs were using Mambas. Basically the flow is single input -\u003e low level mambas -\u003e concat -\u003e high level ssm -\u003e multiple outputs. \n\n\n[Paper link](https://arxiv.org/pdf/2402.10211.pdf)\n\n\nI believe in this architecture alot as it segments local and global learning. \n\n\n## install\n`pip install hsss`\n\n##  usage\n```python\nimport torch\nfrom hsss.model import LowLevelMamba, HSSS\n\n\n# Random input text tokens\ntext = torch.randint(0, 10, (1, 100)).long()\n\n# Low level model\nmamba = LowLevelMamba(\n    dim=12,  # dimension of input\n    depth=6,  # depth of input\n    dt_rank=4,  # rank of input\n    d_state=4,  # state of input\n    expand_factor=4,  # expansion factor of input\n    d_conv=6,  # convolution dimension of input\n    dt_min=0.001,  # minimum time step of input\n    dt_max=0.1,  # maximum time step of input\n    dt_init=\"random\",  # initialization method of input\n    dt_scale=1.0,  # scaling factor of input\n    bias=False,  # whether to use bias in input\n    conv_bias=True,  # whether to use bias in convolution of input\n    pscan=True,  # whether to use parallel scan in input\n)\n\n\n# Low level model 2\nmamba2 = LowLevelMamba(\n    dim=12,  # dimension of input\n    depth=6,  # depth of input\n    dt_rank=4,  # rank of input\n    d_state=4,  # state of input\n    expand_factor=4,  # expansion factor of input\n    d_conv=6,  # convolution dimension of input\n    dt_min=0.001,  # minimum time step of input\n    dt_max=0.1,  # maximum time step of input\n    dt_init=\"random\",  # initialization method of input\n    dt_scale=1.0,  # scaling factor of input\n    bias=False,  # whether to use bias in input\n    conv_bias=True,  # whether to use bias in convolution of input\n    pscan=True,  # whether to use parallel scan in input\n)\n\n\n# Low level mamba 3\nmamba3 = LowLevelMamba(\n    dim=12,  # dimension of input\n    depth=6,  # depth of input\n    dt_rank=4,  # rank of input\n    d_state=4,  # state of input\n    expand_factor=4,  # expansion factor of input\n    d_conv=6,  # convolution dimension of input\n    dt_min=0.001,  # minimum time step of input\n    dt_max=0.1,  # maximum time step of input\n    dt_init=\"random\",  # initialization method of input\n    dt_scale=1.0,  # scaling factor of input\n    bias=False,  # whether to use bias in input\n    conv_bias=True,  # whether to use bias in convolution of input\n    pscan=True,  # whether to use parallel scan in input\n)\n\n\n# HSSS\nhsss = HSSS(\n    layers=[mamba, mamba2, mamba3],\n    num_tokens=10,  # number of tokens in model\n    seq_length=100,  # sequence length of model\n    dim=128,  # dimension of model\n    depth=3,  # depth of model\n    dt_rank=2,  # rank of model\n    d_state=2,  # state of model\n    expand_factor=2,  # expansion factor of model\n    d_conv=3,  # convolution dimension of model\n    dt_min=0.001,  # minimum time step of model\n    dt_max=0.1,  # maximum time step of model\n    dt_init=\"random\",  # initialization method of model\n    dt_scale=1.0,  # scaling factor of model\n    bias=False,  # whether to use bias in model\n    conv_bias=True,  # whether to use bias in convolution of model\n    pscan=True,  # whether to use parallel scan in model\n    proj_layer=True,\n)\n\n\n# Forward pass\nout = hsss(text)\nprint(out)\n\n\n```\n## Citation\n```bibtex\n@misc{bhirangi2024hierarchical,\n      title={Hierarchical State Space Models for Continuous Sequence-to-Sequence Modeling}, \n      author={Raunaq Bhirangi and Chenyu Wang and Venkatesh Pattabiraman and Carmel Majidi and Abhinav Gupta and Tess Hellebrekers and Lerrel Pinto},\n      year={2024},\n      eprint={2402.10211},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n\n\n# License\nMIT\n\n\n## Todo \n\n- [ ] Implement the chunking of the tokens by spliting it up the sequence dimension\n\n- [ ] Make the fusion projection layer dynamic and not use just a linear, ffn, or cross attention or even an output head.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fhsss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyegomez%2Fhsss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fhsss/lists"}