qnguyen3 commited on
Commit
ff2fa79
1 Parent(s): 7de9788

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -29
README.md CHANGED
@@ -21,32 +21,43 @@ What is the meaning of life?<|im_end|>
21
  <|im_start|>assistant
22
  ```
23
 
24
- ## Training procedure
25
-
26
- ### Training hyperparameters
27
-
28
- The following hyperparameters were used during training:
29
- - learning_rate: 2e-06
30
- - train_batch_size: 2
31
- - eval_batch_size: 2
32
- - seed: 42
33
- - distributed_type: multi-GPU
34
- - num_devices: 4
35
- - gradient_accumulation_steps: 4
36
- - total_train_batch_size: 32
37
- - total_eval_batch_size: 8
38
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
39
- - lr_scheduler_type: cosine
40
- - lr_scheduler_warmup_steps: 100
41
- - num_epochs: 1
42
-
43
- ### Training results
44
-
45
-
46
-
47
- ### Framework versions
48
-
49
- - Transformers 4.34.1
50
- - Pytorch 2.0.1+cu118
51
- - Datasets 2.14.6
52
- - Tokenizers 0.14.1
 
 
 
 
 
 
 
 
 
 
 
 
21
  <|im_start|>assistant
22
  ```
23
 
24
+ ## Examples
25
+
26
+ ```python
27
+ from transformers import AutoModelForCausalLM, AutoTokenizer
28
+ import torch
29
+ device = "cuda" # the device to load the model onto
30
+
31
+ model = AutoModelForCausalLM.from_pretrained(
32
+ "vilm/VinaLlama2-14B",
33
+ torch_dtype='auto',
34
+ device_map="auto"
35
+ )
36
+ tokenizer = AutoTokenizer.from_pretrained("vilm/VinaLlama2-14B")
37
+
38
+ prompt = "What is the mearning of life?"
39
+ messages = [
40
+ {"role": "system", "content": "You are a helpful AI assistant."},
41
+ {"role": "user", "content": prompt}
42
+ ]
43
+ text = tokenizer.apply_chat_template(
44
+ messages,
45
+ tokenize=False,
46
+ add_generation_prompt=True
47
+ )
48
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
49
+
50
+ generated_ids = model.generate(
51
+ model_inputs.input_ids,
52
+ max_new_tokens=1024,
53
+ eos_token_id=tokenizer.eos_token_id,
54
+ temperature=0.25,
55
+ )
56
+ generated_ids = [
57
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
58
+ ]
59
+
60
+ response = tokenizer.batch_decode(generated_ids)[0]
61
+ print(response)
62
+
63
+ ```