{"id":26304369,"url":"https://github.com/neuralwork/instruct-finetune-mistral","last_synced_at":"2025-05-12T18:42:18.645Z","repository":{"id":213705871,"uuid":"728266016","full_name":"neuralwork/instruct-finetune-mistral","owner":"neuralwork","description":"Fine-tune Mistral 7B to generate fashion style suggestions","archived":false,"fork":false,"pushed_at":"2024-01-02T17:13:12.000Z","size":20,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-01-02T18:33:20.961Z","etag":null,"topics":["finetuning-llms","huggingface","llm","llm-inference","mistral","peft","quantization"],"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/neuralwork.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}},"created_at":"2023-12-06T15:22:59.000Z","updated_at":"2024-01-02T17:09:10.000Z","dependencies_parsed_at":"2023-12-26T17:52:21.972Z","dependency_job_id":null,"html_url":"https://github.com/neuralwork/instruct-finetune-mistral","commit_stats":null,"previous_names":["neuralwork/instruct-finetune-mistral"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralwork%2Finstruct-finetune-mistral","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralwork%2Finstruct-finetune-mistral/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralwork%2Finstruct-finetune-mistral/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuralwork%2Finstruct-finetune-mistral/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuralwork","download_url":"https://codeload.github.com/neuralwork/instruct-finetune-mistral/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701456,"owners_count":20333631,"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":["finetuning-llms","huggingface","llm","llm-inference","mistral","peft","quantization"],"created_at":"2025-03-15T08:16:06.427Z","updated_at":"2025-03-15T08:16:07.062Z","avatar_url":"https://github.com/neuralwork.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Fine-tuning LLMs with PEFT\nThis project is a tutorial on parameter-efficient fine-tuning (PEFT) and quantization of the [Mistral 7B v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) model. We use LoRA for PEFT and 4-bit quantization to compress the model, and fine-tune the model on a semi-manually crafted fashion style recommendation instruct [dataset](https://huggingface.co/datasets/neuralwork/fashion-style-instruct). For more information and a step by step guide, see our [blog post](https://blog.neuralwork.ai/an-llm-fine-tuning-cookbook-with-mistral-7b/).\n\n## Usage\nStart by cloning the repository, setting up a conda environment and installing the dependencies. We tested our scripts with python 3.9 and CUDA 11.7.\n```\ngit clone https://github.com/neuralwork/finetune-mistral.git\ncd finetune-mistral\n\nconda create -n llm python=3.9\nconda activate llm\npip install -r requirements.txt\n```\n\nYou can finetune the model on our fashion-style-instruct [dataset](https://huggingface.co/datasets/neuralwork/fashion-style-instruct) or another dataset. Note that you will need to have the same features as our dataset and pass in your HF Hub token as an argument if using a private dataset. Fine-tuning takes about 2 hours on a single A40, you can either use the default accelerate settings or configure it to use multiple GPUS. To fine-tune the model:\n```\naccelerate config default\n\npython finetune_model.py --dataset=\u003cHF_DATASET_ID_OR_PATH\u003e --base_model=\"mistralai/Mistral-7B-v0.1\" --model_name=\u003cYOUR_MODEL_NAME\u003e --auth_token=\u003cHF_AUTH_TOKEN\u003e --push_to_hub\n```\n\nOne model training is completed, only the fine-tuned (LoRA) parameters are saved, which are loaded to overwrite the corresponding parameters of the base model during testing.  \n\nTo test the fine-tuned model with a random sample selected from the dataset, run `python test.py`. To launch the full Gradio demo and play around with your own examples, launch the demo with `python app.py`\n\n\n## License\nThis project is licensed under the [MIT license](https://github.com/neuralwork/finetune-mistral/blob/main/LICENSE).\n\nFrom [neuralwork](https://neuralwork.ai/) with :heart:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuralwork%2Finstruct-finetune-mistral","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuralwork%2Finstruct-finetune-mistral","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuralwork%2Finstruct-finetune-mistral/lists"}