mlabonne commited on
Commit
f8a4f80
1 Parent(s): da38541

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -0
README.md CHANGED
@@ -71,4 +71,28 @@ experts:
71
  - "code"
72
  - "programming"
73
  - "storywriting"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  ```
 
71
  - "code"
72
  - "programming"
73
  - "storywriting"
74
+ ```
75
+
76
+ ## 💻 Usage
77
+
78
+ ```python
79
+ !pip install -qU transformers bitsandbytes accelerate
80
+
81
+ from transformers import AutoTokenizer
82
+ import transformers
83
+ import torch
84
+
85
+ model = "mlabonne/Beyonder-4x7b"
86
+
87
+ tokenizer = AutoTokenizer.from_pretrained(model)
88
+ pipeline = transformers.pipeline(
89
+ "text-generation",
90
+ model=model,
91
+ model_kwargs={"torch_dtype": torch.float16, "load_in_4bit": True},
92
+ )
93
+
94
+ messages = [{"role": "user", "content": "Explain what a Mixture of Experts is in less than 100 words."}]
95
+ prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
96
+ outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
97
+ print(outputs[0]["generated_text"])
98
  ```