nroggendorff commited on
Commit
42e1ff4
1 Parent(s): 325dd23

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -0
README.md CHANGED
@@ -38,6 +38,33 @@ response = pipe(conv, max_new_tokens=2048)[0]['generated_text'][-1]['content']
38
  print(response)
39
  ```
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  ## License
42
 
43
  This project is licensed under the MIT License.
 
38
  print(response)
39
  ```
40
 
41
+ To use the model with quantization:
42
+
43
+ ```python
44
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
45
+ import torch
46
+
47
+ bnb_config = BitsAndBytesConfig(
48
+ load_in_4bit=True,
49
+ bnb_4bit_use_double_quant=True,
50
+ bnb_4bit_quant_type="nf4",
51
+ bnb_4bit_compute_dtype=torch.bfloat16
52
+ )
53
+
54
+ model_id = "nroggendorff/mayo"
55
+
56
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
57
+ model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config)
58
+
59
+ prompt = "<|user|>What color is the sky?</s>"
60
+ inputs = tokenizer(prompt, return_tensors="pt")
61
+
62
+ outputs = model.generate(**inputs, max_new_tokens=10)
63
+
64
+ generated_text = tokenizer.batch_decode(outputs)[0]
65
+ print(generated_text)
66
+ ```
67
+
68
  ## License
69
 
70
  This project is licensed under the MIT License.