mlabonne commited on
Commit
b9aae69
1 Parent(s): 3e1bacd

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - moe
5
+ - mergekit
6
+ ---
7
+
8
+ # NeuralMix-2x7b
9
+
10
+ This model is a Mixure of Experts (MoE) made with [mergekit](https://github.com/cg123/mergekit) (mixtral branch). It uses the following base models:
11
+ * [OpenPipe/mistral-ft-optimized-1218](https://huggingface.co/OpenPipe/mistral-ft-optimized-1218)
12
+ * [mlabonne/NeuralHermes-2.5-Mistral-7B](https://huggingface.co/mlabonne/NeuralHermes-2.5-Mistral-7B)
13
+
14
+ ## 💻 Usage
15
+
16
+ ```python
17
+ !pip install -qU transformers bitsandbytes accelerate
18
+
19
+ from transformers import AutoTokenizer
20
+ import transformers
21
+ import torch
22
+
23
+ model = "mlabonne/NeuralMix-2x7b"
24
+
25
+ tokenizer = AutoTokenizer.from_pretrained(model)
26
+ pipeline = transformers.pipeline(
27
+ "text-generation",
28
+ model=model,
29
+ model_kwargs={"torch_dtype": torch.float16, "load_in_4bit": True},
30
+ )
31
+
32
+ messages = [{"role": "user", "content": "Explain what a Mixture of Experts is in less than 100 words."}]
33
+ prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
34
+ outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
35
+ print(outputs[0]["generated_text"])
36
+ ```
37
+
38
+ Output:
39
+ ```
40
+ A Mixture of Experts (ME) is a neural network architecture that allows for adaptive specialization of its hidden layers. It consists of an input layer, a mixture of expert layers with a set of hidden layers, and an output layer. The expert layers have different specializations and each one is responsible for predicting the output for a particular subset of the input data. The mixture of experts uses a gating network to dynamically select the expert layer that best fits the current input data. This adaptive approach can improve the performance and generalization capabilities of the neural network.
41
+
42
+ The Mixture of Experts model is particularly useful in situations where the data is complex, heterogeneous, or has varying structures. By enabling each expert to specialize in a particular type of input, the Mixture of Experts can learn to effectively handle diverse input data and provide more accurate predictions.
43
+
44
+ Overall, the Mixture of Experts can be seen as a type of neural network that combines the strengths of multiple models to create a more powerful and flexible predictive tool.
45
+ ```