{"id":26236341,"url":"https://github.com/tomsanbear/bitnet-rs","last_synced_at":"2025-07-06T23:03:16.380Z","repository":{"id":225227923,"uuid":"765378711","full_name":"tomsanbear/bitnet-rs","owner":"tomsanbear","description":"Implementing the BitNet model in Rust","archived":false,"fork":false,"pushed_at":"2024-04-18T19:14:40.000Z","size":159,"stargazers_count":31,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T17:44:08.954Z","etag":null,"topics":["bitnet","candle","llm","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/tomsanbear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-02-29T20:02:10.000Z","updated_at":"2025-03-20T20:05:05.000Z","dependencies_parsed_at":"2024-03-16T23:15:25.904Z","dependency_job_id":"d13be518-f960-43b3-a282-18f30b709080","html_url":"https://github.com/tomsanbear/bitnet-rs","commit_stats":null,"previous_names":["tomsanbear/bitnet-rs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomsanbear/bitnet-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsanbear%2Fbitnet-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsanbear%2Fbitnet-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsanbear%2Fbitnet-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsanbear%2Fbitnet-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomsanbear","download_url":"https://codeload.github.com/tomsanbear/bitnet-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomsanbear%2Fbitnet-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263986227,"owners_count":23539807,"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":["bitnet","candle","llm","rust"],"created_at":"2025-03-13T03:30:08.105Z","updated_at":"2025-07-06T23:03:16.364Z","avatar_url":"https://github.com/tomsanbear.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitnet-rs: Bitnet Transformer in Rust!\n\nImplementation of the Bitnet transformer using [Candle](https://github.com/huggingface/candle). Implementation is based on the pytorch implementation here: [kyegomez/BitNet](https://github.com/kyegomez/BitNet)\n\n## About\n\nI started this project in order to better understand what goes into making a transformer model in a ML library from scratch, rather than re-implement an existing model I wanted to try doing this from a less known and unimplemented model. In addition, I'm curious about non pytorch based models in order to push performance for models, as such learning to use Candle was a big part of this!\n\n## Building\n\n### CPU\n\n`cargo build --release`\n\n### Metal\n\n`cargo build --release --features \"metal,accelerate\"`\n\n### CUDA\n\n`cargo build --release --features \"cuda\"`\n\n## Training\n\nFirst, build the binary according to the instructions above, then run the command below.\n\n`./target/release/bitnet-rs train --dataset \"\u003cpath to dataset\u003e\"`\n\nReplace `\u003cpath to dataset\u003e` with the directory location of the dataset you are training from. These must be precompiled datasets. I would recommend using the same dataset that has been used for validation: [karpathy/llama2.c](https://github.com/karpathy/llama2.c?tab=readme-ov-file#training). Please follow the instructions in that repository for generating the pretokenized dataset.\n\nFor example, on my machine the training command is this: `./target/release/bitnet-rs train --dataset \"../../karpathy/llama2.c/data/TinyStories_all_data\"`.\n\n## Inference\n\nFirst, build the binary according to the instructions above, then run the command below.\n\n`./target/release/bitnet-rs inference`\n\nIf you want to provide a prompt, provide the `--prompt` flag.\n\n`./target/release/bitnet-rs inference --prompt \"Once upon a time \"`\n\nIf you want to specify a specific model to use for the inference, use the `--pretrained-model-path` flag.\n\n`./target/release/bitnet-rs inference --pretrained-model-path \"./checkpoint.safetensors\"`.\n\n## Known Issues\n\nI'm still testing this out but I am getting semi coherent output with models I've trained. Definitely not useful for any task right now until I can get loss down.\n\n## Contributing\n\nIf you have an interest in contributing please feel free! I'm still learning and would appreciate any suggestions from others.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomsanbear%2Fbitnet-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomsanbear%2Fbitnet-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomsanbear%2Fbitnet-rs/lists"}