stuser2023 commited on
Commit
673a1b8
1 Parent(s): c4883b1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -9
README.md CHANGED
@@ -37,22 +37,20 @@ lora_r = 8
37
 
38
  ```python
39
  import torch
40
- from transformers import AutoTokenizer, AutoModelForCausalLM
41
- from peft import PeftModel,PeftConfig
42
 
43
- finetune_model_path="stuser2023/Llama2-7b-finetuned"
44
- config = PeftConfig.from_pretrained(finetune_model_path)
 
45
 
46
  model = AutoModelForCausalLM.from_pretrained(
47
- config.base_model_name_or_path,
48
- load_in_8bit=True,
49
  device_map={'': 0}, # 設定使用的設備,此處指定為 GPU 0
50
  trust_remote_code=True,
51
  )
52
  model.config.use_cache = False
53
-
54
- model = PeftModel.from_pretrained(model, finetune_model_path, device_map={"": 0})
55
- model =model.eval()
56
  ```
57
 
58
  **3.進行推論(文字生成)**
 
37
 
38
  ```python
39
  import torch
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
 
41
 
42
+ model_name = "stuser2023/Llama2-7b-finetuned"
43
+
44
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
45
 
46
  model = AutoModelForCausalLM.from_pretrained(
47
+ model_name,
48
+ quantization_config=quantization_config,
49
  device_map={'': 0}, # 設定使用的設備,此處指定為 GPU 0
50
  trust_remote_code=True,
51
  )
52
  model.config.use_cache = False
53
+ model=model.eval() #把Dropout功能關掉
 
 
54
  ```
55
 
56
  **3.進行推論(文字生成)**