mzbac commited on
Commit
3537ef4
·
verified ·
1 Parent(s): b044266

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +151 -0
README.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3
3
+ datasets:
4
+ - mzbac/glaive-function-calling-v2-llama-3-format
5
+ language:
6
+ - en
7
+ ---
8
+
9
+ # Model
10
+
11
+ This model is fine-tuned based on Meta-Llama/Meta-Llama-3-8B instructions via mlx-lm.
12
+
13
+ ## Usage
14
+
15
+ ```python
16
+ from transformers import AutoTokenizer, AutoModelForCausalLM
17
+ import torch
18
+
19
+ model_id = "lora_fused_model"
20
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
21
+ model = AutoModelForCausalLM.from_pretrained(
22
+ model_id,
23
+ torch_dtype=torch.bfloat16,
24
+ device_map="auto",
25
+ )
26
+
27
+ tool = {
28
+ "name": "search_web",
29
+ "description": "Perform a web search for a given search terms.",
30
+ "parameter": {
31
+ "type": "object",
32
+ "properties": {
33
+ "search_terms": {
34
+ "type": "array",
35
+ "items": {"type": "string"},
36
+ "description": "The search queries for which the search is performed.",
37
+ "required": True,
38
+ }
39
+ }
40
+ },
41
+ }
42
+
43
+ messages = [
44
+ {
45
+ "role": "system",
46
+ "content": f"You are a helpful assistant with access to the following functions. Use them if required - {str(tool)}",
47
+ },
48
+ {"role": "user", "content": "Today's news in Melbourne, just for your information, today is April 27, 2014."},
49
+ ]
50
+
51
+ input_ids = tokenizer.apply_chat_template(
52
+ messages,
53
+ add_generation_prompt=True,
54
+ return_tensors="pt"
55
+ ).to(model.device)
56
+
57
+ terminators = [
58
+ tokenizer.eos_token_id,
59
+ tokenizer.convert_tokens_to_ids("<|eot_id|>")
60
+ ]
61
+
62
+ outputs = model.generate(
63
+ input_ids,
64
+ max_new_tokens=256,
65
+ eos_token_id=terminators,
66
+ do_sample=True,
67
+ temperature=0.1,
68
+ )
69
+ response = outputs[0]
70
+ print(tokenizer.decode(response))
71
+
72
+ # <|begin_of_text|><|start_header_id|>system<|end_header_id|>
73
+
74
+ # You are a helpful assistant with access to the following functions. Use them if required - {'name':'search_web', 'description': 'Perform a web search for a given search terms.', 'parameter': {'type': 'object', 'properties': {'search_terms': {'type': 'array', 'items': {'type':'string'}, 'description': 'The search queries for which the search is performed.','required': True}}}}<|eot_id|><|start_header_id|>user<|end_header_id|>
75
+
76
+ # Today's news in Melbourne, just for your information, today is April 27, 2014.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
77
+
78
+ # <functioncall> {"name": "search_web", "arguments": '{"search_terms": ["Melbourne news", "April 27, 2014"]}'}<|eot_id|>
79
+ ```
80
+ ## Training hyperparameters
81
+ ```yaml
82
+ # The path to the local model directory or Hugging Face repo.
83
+ model: "meta-llama/Meta-Llama-3-8B-Instruct"
84
+ # Whether or not to train (boolean)
85
+ train: true
86
+
87
+ # Directory with {train, valid, test}.jsonl files
88
+ data: "data"
89
+
90
+ # The PRNG seed
91
+ seed: 0
92
+
93
+ # Number of layers to fine-tune
94
+ lora_layers: 32
95
+
96
+ # Minibatch size.
97
+ batch_size: 1
98
+
99
+ # Iterations to train for.
100
+ iters: 113000
101
+
102
+ # Number of validation batches, -1 uses the entire validation set.
103
+ val_batches: 25
104
+
105
+ # Adam learning rate.
106
+ learning_rate: 1e-6
107
+
108
+ # Number of training steps between loss reporting.
109
+ steps_per_report: 10
110
+
111
+ # Number of training steps between validations.
112
+ steps_per_eval: 200
113
+
114
+ # Load path to resume training with the given adapter weights.
115
+ resume_adapter_file: null
116
+
117
+ # Save/load path for the trained adapter weights.
118
+ adapter_path: "adapters"
119
+
120
+ # Save the model every N iterations.
121
+ save_every: 1000
122
+
123
+ # Evaluate on the test set after training
124
+ test: false
125
+
126
+ # Number of test set batches, -1 uses the entire test set.
127
+ test_batches: 100
128
+
129
+ # Maximum sequence length.
130
+ max_seq_length: 8192
131
+
132
+ # Use gradient checkpointing to reduce memory use.
133
+ grad_checkpoint: true
134
+
135
+ # LoRA parameters can only be specified in a config file
136
+ lora_parameters:
137
+ # The layer keys to apply LoRA to.
138
+ # These will be applied for the last lora_layers
139
+ keys: ['mlp.gate_proj', 'mlp.down_proj', 'self_attn.q_proj', 'mlp.up_proj', 'self_attn.o_proj','self_attn.v_proj', 'self_attn.k_proj']
140
+ rank: 128
141
+ alpha: 256
142
+ scale: 10.0
143
+ dropout: 0.05
144
+
145
+ # Schedule can only be specified in a config file, uncomment to use.
146
+ lr_schedule:
147
+ name: cosine_decay
148
+ warmup: 100 # 0 for no warmup
149
+ warmup_init: 1e-7 # 0 if not specified
150
+ arguments: [1e-6, 1000, 1e-7] # passed to scheduler
151
+ ```