Instructions to use samadpls/torchlight-phi4-mini-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use samadpls/torchlight-phi4-mini-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-4-mini-instruct") model = PeftModel.from_pretrained(base_model, "samadpls/torchlight-phi4-mini-lora") - MLX
How to use samadpls/torchlight-phi4-mini-lora with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("samadpls/torchlight-phi4-mini-lora") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use samadpls/torchlight-phi4-mini-lora with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "samadpls/torchlight-phi4-mini-lora" --prompt "Once upon a time"
- Atomic Chat
Add the LoRA adapter in PEFT and mlx-lm formats
Browse files- adapter_config.json +77 -0
- adapter_model.safetensors +3 -0
- mlx/adapter_config.json +48 -0
- mlx/adapters.safetensors +3 -0
adapter_config.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"peft_type": "LORA",
|
| 3 |
+
"task_type": "CAUSAL_LM",
|
| 4 |
+
"base_model_name_or_path": "microsoft/Phi-4-mini-instruct",
|
| 5 |
+
"r": 16,
|
| 6 |
+
"lora_alpha": 32.0,
|
| 7 |
+
"lora_dropout": 0.0,
|
| 8 |
+
"bias": "none",
|
| 9 |
+
"fan_in_fan_out": false,
|
| 10 |
+
"inference_mode": true,
|
| 11 |
+
"target_modules": [
|
| 12 |
+
"model.layers.16.mlp.down_proj",
|
| 13 |
+
"model.layers.16.mlp.gate_up_proj",
|
| 14 |
+
"model.layers.16.self_attn.o_proj",
|
| 15 |
+
"model.layers.16.self_attn.qkv_proj",
|
| 16 |
+
"model.layers.17.mlp.down_proj",
|
| 17 |
+
"model.layers.17.mlp.gate_up_proj",
|
| 18 |
+
"model.layers.17.self_attn.o_proj",
|
| 19 |
+
"model.layers.17.self_attn.qkv_proj",
|
| 20 |
+
"model.layers.18.mlp.down_proj",
|
| 21 |
+
"model.layers.18.mlp.gate_up_proj",
|
| 22 |
+
"model.layers.18.self_attn.o_proj",
|
| 23 |
+
"model.layers.18.self_attn.qkv_proj",
|
| 24 |
+
"model.layers.19.mlp.down_proj",
|
| 25 |
+
"model.layers.19.mlp.gate_up_proj",
|
| 26 |
+
"model.layers.19.self_attn.o_proj",
|
| 27 |
+
"model.layers.19.self_attn.qkv_proj",
|
| 28 |
+
"model.layers.20.mlp.down_proj",
|
| 29 |
+
"model.layers.20.mlp.gate_up_proj",
|
| 30 |
+
"model.layers.20.self_attn.o_proj",
|
| 31 |
+
"model.layers.20.self_attn.qkv_proj",
|
| 32 |
+
"model.layers.21.mlp.down_proj",
|
| 33 |
+
"model.layers.21.mlp.gate_up_proj",
|
| 34 |
+
"model.layers.21.self_attn.o_proj",
|
| 35 |
+
"model.layers.21.self_attn.qkv_proj",
|
| 36 |
+
"model.layers.22.mlp.down_proj",
|
| 37 |
+
"model.layers.22.mlp.gate_up_proj",
|
| 38 |
+
"model.layers.22.self_attn.o_proj",
|
| 39 |
+
"model.layers.22.self_attn.qkv_proj",
|
| 40 |
+
"model.layers.23.mlp.down_proj",
|
| 41 |
+
"model.layers.23.mlp.gate_up_proj",
|
| 42 |
+
"model.layers.23.self_attn.o_proj",
|
| 43 |
+
"model.layers.23.self_attn.qkv_proj",
|
| 44 |
+
"model.layers.24.mlp.down_proj",
|
| 45 |
+
"model.layers.24.mlp.gate_up_proj",
|
| 46 |
+
"model.layers.24.self_attn.o_proj",
|
| 47 |
+
"model.layers.24.self_attn.qkv_proj",
|
| 48 |
+
"model.layers.25.mlp.down_proj",
|
| 49 |
+
"model.layers.25.mlp.gate_up_proj",
|
| 50 |
+
"model.layers.25.self_attn.o_proj",
|
| 51 |
+
"model.layers.25.self_attn.qkv_proj",
|
| 52 |
+
"model.layers.26.mlp.down_proj",
|
| 53 |
+
"model.layers.26.mlp.gate_up_proj",
|
| 54 |
+
"model.layers.26.self_attn.o_proj",
|
| 55 |
+
"model.layers.26.self_attn.qkv_proj",
|
| 56 |
+
"model.layers.27.mlp.down_proj",
|
| 57 |
+
"model.layers.27.mlp.gate_up_proj",
|
| 58 |
+
"model.layers.27.self_attn.o_proj",
|
| 59 |
+
"model.layers.27.self_attn.qkv_proj",
|
| 60 |
+
"model.layers.28.mlp.down_proj",
|
| 61 |
+
"model.layers.28.mlp.gate_up_proj",
|
| 62 |
+
"model.layers.28.self_attn.o_proj",
|
| 63 |
+
"model.layers.28.self_attn.qkv_proj",
|
| 64 |
+
"model.layers.29.mlp.down_proj",
|
| 65 |
+
"model.layers.29.mlp.gate_up_proj",
|
| 66 |
+
"model.layers.29.self_attn.o_proj",
|
| 67 |
+
"model.layers.29.self_attn.qkv_proj",
|
| 68 |
+
"model.layers.30.mlp.down_proj",
|
| 69 |
+
"model.layers.30.mlp.gate_up_proj",
|
| 70 |
+
"model.layers.30.self_attn.o_proj",
|
| 71 |
+
"model.layers.30.self_attn.qkv_proj",
|
| 72 |
+
"model.layers.31.mlp.down_proj",
|
| 73 |
+
"model.layers.31.mlp.gate_up_proj",
|
| 74 |
+
"model.layers.31.self_attn.o_proj",
|
| 75 |
+
"model.layers.31.self_attn.qkv_proj"
|
| 76 |
+
]
|
| 77 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5dfb61ff19c292717964769fcb688eab05cbdca031f1bdc8c62b916f6d30dbb
|
| 3 |
+
size 46154552
|
mlx/adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"adapter_path": "data/train/phi4-mini/adapters",
|
| 3 |
+
"batch_size": 2,
|
| 4 |
+
"clear_cache_threshold": 0,
|
| 5 |
+
"config": "data/train/phi4-mini/lora.yaml",
|
| 6 |
+
"data": "data/train/phi4-mini/data",
|
| 7 |
+
"fine_tune_type": "lora",
|
| 8 |
+
"grad_accumulation_steps": 4,
|
| 9 |
+
"grad_checkpoint": true,
|
| 10 |
+
"iters": 3459,
|
| 11 |
+
"learning_rate": 0.0002,
|
| 12 |
+
"lora_parameters": {
|
| 13 |
+
"rank": 16,
|
| 14 |
+
"scale": 2.0,
|
| 15 |
+
"dropout": 0.0
|
| 16 |
+
},
|
| 17 |
+
"lr_schedule": {
|
| 18 |
+
"name": "cosine_decay",
|
| 19 |
+
"warmup": 43,
|
| 20 |
+
"arguments": [
|
| 21 |
+
0.0002,
|
| 22 |
+
821,
|
| 23 |
+
0.0
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"mask_prompt": true,
|
| 27 |
+
"max_seq_length": 4096,
|
| 28 |
+
"model": "microsoft/Phi-4-mini-instruct",
|
| 29 |
+
"num_layers": 16,
|
| 30 |
+
"optimizer": "adamw",
|
| 31 |
+
"optimizer_config": {
|
| 32 |
+
"adamw": {
|
| 33 |
+
"weight_decay": 0.01
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"project_name": null,
|
| 37 |
+
"report_to": null,
|
| 38 |
+
"resume_adapter_file": null,
|
| 39 |
+
"save_every": 1000,
|
| 40 |
+
"seed": 0,
|
| 41 |
+
"steps_per_eval": 1000,
|
| 42 |
+
"steps_per_report": 10,
|
| 43 |
+
"test": false,
|
| 44 |
+
"test_batches": 500,
|
| 45 |
+
"train": true,
|
| 46 |
+
"trust_remote_code": false,
|
| 47 |
+
"val_batches": -1
|
| 48 |
+
}
|
mlx/adapters.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e39525e0a72f712cce4a6402522da5f3265af95d925bb5b1e6f6644a9352ee7d
|
| 3 |
+
size 46151500
|