{"id":13640650,"url":"https://github.com/coreylowman/llama-dfdx","last_synced_at":"2025-04-13T05:34:35.908Z","repository":{"id":158293075,"uuid":"633909319","full_name":"coreylowman/llama-dfdx","owner":"coreylowman","description":"LLaMa 7b with CUDA acceleration implemented in rust. Minimal GPU memory needed!","archived":false,"fork":false,"pushed_at":"2023-07-27T13:46:57.000Z","size":406,"stargazers_count":100,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-18T23:17:02.617Z","etag":null,"topics":["cuda","deep-learning","inference","language-model","llama","neural-network","rust","rust-lang"],"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/coreylowman.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},"funding":{"github":"coreylowman","patreon":"dfdx","ko_fi":"coreylowman","open_collective":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-04-28T15:01:29.000Z","updated_at":"2024-09-14T06:08:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bda0288-c69c-4976-9741-5036e66eee7c","html_url":"https://github.com/coreylowman/llama-dfdx","commit_stats":{"total_commits":72,"total_committers":3,"mean_commits":24.0,"dds":0.08333333333333337,"last_synced_commit":"544397211be4290b6b0e3f4e14acd7c87eb4e028"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreylowman%2Fllama-dfdx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreylowman%2Fllama-dfdx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreylowman%2Fllama-dfdx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreylowman%2Fllama-dfdx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coreylowman","download_url":"https://codeload.github.com/coreylowman/llama-dfdx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670518,"owners_count":21142896,"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":["cuda","deep-learning","inference","language-model","llama","neural-network","rust","rust-lang"],"created_at":"2024-08-02T01:01:13.119Z","updated_at":"2025-04-13T05:34:35.473Z","avatar_url":"https://github.com/coreylowman.png","language":"Rust","funding_links":["https://github.com/sponsors/coreylowman","https://patreon.com/dfdx","https://ko-fi.com/coreylowman"],"categories":["Summary","Frameworks","Machine Learning"],"sub_categories":[],"readme":"# LLaMa 7b in rust\n\n[![](https://dcbadge.vercel.app/api/server/AtUhGqBDP5)](https://discord.gg/AtUhGqBDP5)\n\nThis repo contains the popular [LLaMa 7b](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/)\nlanguage model, fully implemented in the rust programming language!\n\nUses [dfdx](https://github.com/coreylowman/dfdx) tensors and CUDA acceleration.\n\n**This runs LLaMa directly in f16, meaning there is no hardware acceleration on CPU.** Using CUDA is heavily recommended.\n\nHere is the 7b model running on an A10 GPU:\n\n![](llama-7b-a10.gif)\n\n# How To Run\n\n## (Once) Setting up model weights\n\n### Download model weights\n1. Install git lfs. On ubuntu you can run `sudo apt install git-lfs`\n2. Activate git lfs with `git lfs install`.\n3. Run the following commands to download the model weights in pytorch format (~25 GB):\n    1. LLaMa 7b (~25 GB): `git clone https://huggingface.co/decapoda-research/llama-7b-hf`\n    2. LLaMa 13b (~75 GB): `git clone https://huggingface.co/decapoda-research/llama-13b-hf`\n    3. LLaMa 65b (~244 GB): `git clone https://huggingface.co/decapoda-research/llama-65b-hf`\n\n### Convert the model\n1. (Optional) Run `python3.x -m venv \u003cmy_env_name\u003e` to create a python virtual environment, where `x` is your prefered python version\n2. (Optional, requires 1.) Run `source \u003cmy_env_name\u003e\\bin\\activate` (or `\u003cmy_env_name\u003e\\Scripts\\activate` if on Windows) to activate the environment\n3. Run `pip install numpy torch`\n4. Run `python convert.py` to convert the model weights to rust understandable format:\n    a. LLaMa 7b: `python convert.py`\n    b. LLaMa 13b: `python convert.py llama-13b-hf`\n    c. LLaMa 65b: `python convert.py llama-65b-hf`\n\n## (Once) Compile\n\nYou can compile with normal rust commands:\n\nWith cuda:\n```bash\ncargo build --release -F cuda\n```\n\nWithout cuda:\n```bash\ncargo build --release\n```\n\n## Run the executable\n\nWith default args:\n```bash\n./target/release/llama-dfdx --model \u003cmodel-dir\u003e generate \"\u003cprompt\u003e\"\n./target/release/llama-dfdx --model \u003cmodel-dir\u003e chat\n./target/release/llama-dfdx --model \u003cmodel-dir\u003e file \u003cpath to prompt file\u003e\n```\n\nTo see what commands/custom args you can use:\n```bash\n./target/release/llama-dfdx --help\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreylowman%2Fllama-dfdx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoreylowman%2Fllama-dfdx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreylowman%2Fllama-dfdx/lists"}