IlyaGusev commited on
Commit
d1d6a80
1 Parent(s): 0dead1b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -1
README.md CHANGED
@@ -34,6 +34,7 @@ Versions:
34
  - Hardware: 1x RTX 3090
35
 
36
  ```python
 
37
  from peft import PeftModel, PeftConfig
38
  from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
39
 
@@ -43,10 +44,19 @@ config = PeftConfig.from_pretrained(MODEL_NAME)
43
  model = AutoModelForCausalLM.from_pretrained(
44
  config.base_model_name_or_path,
45
  load_in_8bit=True,
 
46
  device_map="auto"
47
  )
48
- model = PeftModel.from_pretrained(model, MODEL_NAME, device_map={'': 0})
49
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
 
 
 
 
 
 
 
 
50
  ```
51
 
52
  Examples:
 
34
  - Hardware: 1x RTX 3090
35
 
36
  ```python
37
+ import torch
38
  from peft import PeftModel, PeftConfig
39
  from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
40
 
 
44
  model = AutoModelForCausalLM.from_pretrained(
45
  config.base_model_name_or_path,
46
  load_in_8bit=True,
47
+ torch_dtype=torch.float16,
48
  device_map="auto"
49
  )
50
+ model = PeftModel.from_pretrained(model, MODEL_NAME, torch_dtype=torch.float16)
51
  tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
52
+ model.eval()
53
+
54
+ generation_config = GenerationConfig.from_pretrained(MODEL_NAME)
55
+ data = tokenizer(["Вопрос: Почему трава зеленая?\n\nВыход:"], return_tensors="pt")
56
+ data = {k: v.to(model.device) for k, v in data.items() if k in ("input_ids", "attention_mask")}
57
+ output_ids = model.generate(**data, generation_config=generation_config)[0]
58
+ print(tokenizer.decode(output_ids, skip_special_tokens=True))
59
+
60
  ```
61
 
62
  Examples: