{"id":18678504,"url":"https://github.com/kamalkraj/e5-mistral-7b-instruct","last_synced_at":"2025-04-12T02:41:10.936Z","repository":{"id":215819649,"uuid":"739701294","full_name":"kamalkraj/e5-mistral-7b-instruct","owner":"kamalkraj","description":"Finetune mistral-7b-instruct for sentence embeddings","archived":false,"fork":false,"pushed_at":"2024-05-02T13:24:00.000Z","size":35,"stargazers_count":81,"open_issues_count":7,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T22:21:19.553Z","etag":null,"topics":["finetuning","huggingface","lora","mistral-7b","peft","pytorch","sentence-embeddings","transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamalkraj.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-01-06T09:22:35.000Z","updated_at":"2025-03-14T20:42:52.000Z","dependencies_parsed_at":"2024-01-26T09:27:40.694Z","dependency_job_id":"53645237-0f76-428a-8274-dcf9d1eb8ef0","html_url":"https://github.com/kamalkraj/e5-mistral-7b-instruct","commit_stats":null,"previous_names":["kamalkraj/e5-mistral-7b-instruct"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalkraj%2Fe5-mistral-7b-instruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalkraj%2Fe5-mistral-7b-instruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalkraj%2Fe5-mistral-7b-instruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamalkraj%2Fe5-mistral-7b-instruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamalkraj","download_url":"https://codeload.github.com/kamalkraj/e5-mistral-7b-instruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507468,"owners_count":21115607,"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","huggingface","lora","mistral-7b","peft","pytorch","sentence-embeddings","transformers"],"created_at":"2024-11-07T09:38:01.287Z","updated_at":"2025-04-12T02:41:10.916Z","avatar_url":"https://github.com/kamalkraj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# e5-mistral-7b-instruct\n\n\n```bash\ndocker build -t pytorch .\n```\n\n```bash\ndocker run --gpus=all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -it --rm -v $(pwd):/e5-mistral-7b-instruct/ pytorch bash\n```\n\n\n### Prepare data\n\nRun `prepare_dataset` to create a similarity dataset with one postive and negative pair from SNLI. \n```bash\npython prepare_dataset.py\n```\n\n### Run model\n\nset the model cache folder `export TRANSFORMERS_CACHE=.cache/`\n\nFirst, run `accelerate config --config_file ds_zero3_cpu.yaml`\n\ncheck the sample file for Single GPU [here](ds_zero3_cpu.yaml)\n\nBelow given parameter is taken from the paper for finetuning. \nAdjust accroding to your dataset and usecase.\n\n```bash\naccelerate launch \\\n    --config_file ds_zero3_cpu.yaml \\\n    peft_lora_embedding_semantic_search.py \\\n    --dataset_name similarity_dataset \\\n    --max_length 512 \\\n    --model_name_or_path intfloat/e5-mistral-7b-instruct \\\n    --per_device_train_batch_size 1 \\\n    --per_device_eval_batch_size 1 \\\n    --learning_rate 0.0001 \\\n    --weight_decay 0.01 \\\n    --max_train_steps 1000 \\\n    --gradient_accumulation_steps 2048 \\\n    --lr_scheduler_type linear \\\n    --num_warmup_steps 100 \\\n    --output_dir trained_model \\\n    --use_peft\n```\n\n\n[loss](loss.py) function copied from here -\u003e https://github.com/RElbers/info-nce-pytorch","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamalkraj%2Fe5-mistral-7b-instruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamalkraj%2Fe5-mistral-7b-instruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamalkraj%2Fe5-mistral-7b-instruct/lists"}