{"id":13742228,"url":"https://github.com/AdrianBZG/LLM-distributed-finetune","last_synced_at":"2025-05-08T23:33:51.185Z","repository":{"id":216841598,"uuid":"655251976","full_name":"AdrianBZG/LLM-distributed-finetune","owner":"AdrianBZG","description":"Tune efficiently any LLM model from HuggingFace using distributed training (multiple GPU) and DeepSpeed. Uses Ray AIR to orchestrate the training on multiple AWS GPU instances","archived":false,"fork":false,"pushed_at":"2023-06-20T08:25:26.000Z","size":21878,"stargazers_count":46,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-22T13:31:06.129Z","etag":null,"topics":["aws","deep-learning","distributed-training","falcon","fine-tuning","huggingface","large-language-models","natural-language-processing","transformers"],"latest_commit_sha":null,"homepage":"","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/AdrianBZG.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}},"created_at":"2023-06-18T10:54:23.000Z","updated_at":"2024-05-04T13:44:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac45fa38-94fd-4019-ab32-301d8ed90722","html_url":"https://github.com/AdrianBZG/LLM-distributed-finetune","commit_stats":null,"previous_names":["adrianbzg/llm-distributed-finetune"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdrianBZG%2FLLM-distributed-finetune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdrianBZG%2FLLM-distributed-finetune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdrianBZG%2FLLM-distributed-finetune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdrianBZG%2FLLM-distributed-finetune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdrianBZG","download_url":"https://codeload.github.com/AdrianBZG/LLM-distributed-finetune/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253165384,"owners_count":21864427,"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":["aws","deep-learning","distributed-training","falcon","fine-tuning","huggingface","large-language-models","natural-language-processing","transformers"],"created_at":"2024-08-03T05:00:24.374Z","updated_at":"2025-05-08T23:33:46.143Z","avatar_url":"https://github.com/AdrianBZG.png","language":"Python","funding_links":[],"categories":["Models and Projects"],"sub_categories":["Ray + LLM"],"readme":"# Finetuning Large Language Models Efficiently on a Distributed Cluster\n\nThis repository is a boilerplate/fingerprint to fine tune any HuggingFace Large Language Model, such as FALCON-7B, using a distributed cluster.\nThe purpose of this repo is to make it straightforward to fine tune any model efficiently by leveraging multi-GPU training.\nIt uses Ray AIR to orchestrate the cluster on AWS, and DeepSpeed for parameter+optimizer sharding + offloading.\n\nThe following FALCON-7B model was fine-tuned using this repo: [https://huggingface.co/AdrianBZG/falcon-7b-spanish-8bit](https://huggingface.co/AdrianBZG/falcon-7b-spanish-8bit)\n\n## Setup\n\nFirst, you need to clone the repo:\n\n`git clone https://github.com/AdrianBZG/LLM-distributed-finetune`\n\nThen, configure your aws credentials using the `awscli` package command `aws configure`. This will allow Ray to spawn the head node and provision workers with the auto-scaling mechanism. If you don't have `awscli`, you can install it using `pip install awscli`.\n\n## Working with the Ray cluster and submitting finetuning jobs\n\nTo spawn the cluster, simply run:\n\n`ray up ray_cluster.yaml`\n\nOnce Ray has finished setting up the cluster, you can attach to the head node by doing:\n\n`ray attach ray_cluster.yaml`\n\nNow, to run a finetuning job, you can use the script `finetune.py` under `/src`.\n\nAn example usage is as below:\n\n`python finetune.py --model=\"tiiuae/falcon-7b\" --num-workers 4 --data alpaca_data_cleaned.json`\n\nThis will run a finetuning on the FALCON-7B model using 4 GPU workers, and the Alpaca instruction dataset. Feel free to adjust the arguments for your own purposes.\n\nWhen you are finished, you can turn off the cluster with:\n\n`ray down ray_cluster.yaml`\n\n## Changing DeepSpeed configuration\n\nTo tune the DeepSpeed configuration for your specific use case, edit the file on `config/deepspeed.json`. If you want to disable DeepSpeed, you can pass the `--no-deepspeed` parameter to the `finetune.py` script.\n\n# Datasets\n\nI have successfully fine-tuned FALCON-7B on the following 2 datasets:\n\n- Alpaca: [https://huggingface.co/datasets/yahma/alpaca-cleaned](https://huggingface.co/datasets/yahma/alpaca-cleaned)\n- Alpaca Spanish: [https://huggingface.co/datasets/bertin-project/alpaca-spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAdrianBZG%2FLLM-distributed-finetune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAdrianBZG%2FLLM-distributed-finetune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAdrianBZG%2FLLM-distributed-finetune/lists"}