ayoubkirouane commited on
Commit
cd9fdc6
1 Parent(s): 741a805

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -1
README.md CHANGED
@@ -16,5 +16,39 @@ The following `bitsandbytes` quantization config was used during training:
16
  - bnb_4bit_compute_dtype: float16
17
  ### Framework versions
18
 
19
-
20
  - PEFT 0.4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  - bnb_4bit_compute_dtype: float16
17
  ### Framework versions
18
 
 
19
  - PEFT 0.4.0
20
+
21
+ ### How to Get Started with the Model
22
+
23
+ ```python
24
+ from transformers import pipeline
25
+ from transformers import AutoTokenizer
26
+ from peft import PeftModel, PeftConfig
27
+ from transformers import AutoModelForCausalLM , BitsAndBytesConfig
28
+ import torch
29
+ bnb_config = BitsAndBytesConfig(
30
+ load_in_4bit=True,
31
+ bnb_4bit_quant_type="nf4",
32
+ bnb_4bit_compute_dtype=getattr(torch, "float16"),
33
+ bnb_4bit_use_double_quant=False)
34
+ model = AutoModelForCausalLM.from_pretrained(
35
+ "meta-llama/Llama-2-13b-hf",
36
+ quantization_config=bnb_config,
37
+ device_map={"": 0})
38
+ model.config.use_cache = False
39
+ model.config.pretraining_tp = 1
40
+ model = PeftModel.from_pretrained(model, "TuningAI/Llama2_13B_startup_Assistant")
41
+
42
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-13b-hf", trust_remote_code=True)
43
+ tokenizer.pad_token = tokenizer.eos_token
44
+ tokenizer.padding_side = "right"
45
+ while 1:
46
+ input_text = input(">>>")
47
+ prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n {input_text}. [/INST]"
48
+ num_new_tokens = 60
49
+ num_prompt_tokens = len(tokenizer(prompt)['input_ids'])
50
+ max_length = num_prompt_tokens + num_new_tokens
51
+ pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=max_length)
52
+ result = pipe(prompt)
53
+ print(result[0]['generated_text'].replace(prompt, ''))
54
+ ```