israel commited on
Commit
28b4532
1 Parent(s): da572fc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -1
README.md CHANGED
@@ -111,4 +111,35 @@ print(outputs[0]["generated_text"])
111
  # what is the 3 biggest countrys in Africa?<eos>
112
  # <|assistant|>
113
  # The 3 biggest countries in Africa are Nigeria, Ethiopia and South Africa.
114
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  # what is the 3 biggest countrys in Africa?<eos>
112
  # <|assistant|>
113
  # The 3 biggest countries in Africa are Nigeria, Ethiopia and South Africa.
114
+ ```
115
+
116
+
117
+ ### Quantized Versions through bitsandbytes
118
+
119
+ ``` python
120
+
121
+ import torch
122
+ from transformers import pipeline
123
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
124
+
125
+
126
+ quantization_config = BitsAndBytesConfig(load_in_4bit=True)
127
+
128
+ tokenizer = AutoTokenizer.from_pretrained("masakhane/zephyr-7b-gemma-sft-african-alpaca")
129
+ model = AutoModelForCausalLM.from_pretrained("masakhane/zephyr-7b-gemma-sft-african-alpaca", quantization_config=quantization_config)
130
+
131
+
132
+ pipe = pipeline("text-generation", model=model,tokenizer=tokenizer, torch_dtype=torch.bfloat16, device_map="auto")
133
+
134
+ messages = [
135
+ {
136
+ "role": "system",
137
+ "content": "You are a friendly chatbot who answewrs question in given language",
138
+ },
139
+ {"role": "user", "content": "list languages in Africa?"},
140
+ ]
141
+ prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
142
+ outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
143
+ print(outputs[0]["generated_text"])
144
+
145
+ ```