Update README.md
Browse files
README.md
CHANGED
@@ -6,11 +6,12 @@ A frankenMoE of [TinyLlama-1.1B-1T-OpenOrca](https://huggingface.co/jeff31415/Ti
|
|
6 |
[TinyLlama-1.1B-intermediate-step-1195k-token-2.5T](https://huggingface.co/TinyLlama/TinyLlama-1.1B-intermediate-step-1195k-token-2.5T),
|
7 |
and [tiny-llama-1.1b-chat-medical](https://huggingface.co/SumayyaAli/tiny-llama-1.1b-chat-medical).
|
8 |
|
9 |
-
### Most 1.1B models are incoherent and can't even answer simple questions. I picked out some models that aren't as bad, then
|
10 |
|
11 |
OpenOrca experts have been given the task of creating responses for simple questions about things like pop culture, history, and science...step-1195k experts have been chosen to provide warmth and a positive environment, while chat-medical experts have been chosen to provide further detail about human subjects, and to give small little bits of medical advice: I.E. "how do I get rid of this headache I gave myself from making you?"
|
12 |
|
13 |
-
# What is a Mixture of Experts (MoE)?
|
|
|
14 |
|
15 |
The scale of a model is one of the most important axes for better model quality. Given a fixed computing budget, training a larger model for fewer steps is better than training a smaller model for more steps.
|
16 |
|
@@ -22,6 +23,7 @@ So, what exactly is a MoE? In the context of transformer models, a MoE consists
|
|
22 |
|
23 |
A gate network or router, that determines which tokens are sent to which expert. For example, in the image below, the token “More” is sent to the second expert, and the token "Parameters” is sent to the first network. As we’ll explore later, we can send a token to more than one expert. How to route a token to an expert is one of the big decisions when working with MoEs - the router is composed of learned parameters and is pretrained at the same time as the rest of the network.
|
24 |
|
|
|
25 |
|
26 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6589d7e6586088fd2784a12c/up_I0R2TQGjqTShZp_1Sz.png)
|
27 |
|
@@ -33,7 +35,9 @@ So, to recap, in MoEs we replace every FFN layer of the transformer model with a
|
|
33 |
Although MoEs provide benefits like efficient pretraining and faster inference compared to dense models, they also come with challenges:
|
34 |
|
35 |
Training: MoEs enable significantly more compute-efficient pretraining, but they’ve historically struggled to generalize during fine-tuning, leading to overfitting.
|
36 |
-
Inference: Although a MoE might have many parameters, only some of them are used during inference. This leads to much faster inference compared to a dense model with the same number of parameters. However, all parameters need to be loaded in RAM, so memory requirements are high. For example, given a MoE like Mixtral 8x7B, we’ll need to have enough VRAM to hold a dense 47B parameter model. Why 47B parameters and not 8 x 7B = 56B? That’s because in MoE models, only the FFN layers are treated as individual experts, and the rest of the model parameters are shared. At the same time, assuming just two experts are being used per token, the inference speed (FLOPs) is like using a 12B model (as opposed to a 14B model), because it computes 2x7B matrix multiplications, but with some layers shared (more on this soon).
|
|
|
|
|
37 |
|
38 |
|
39 |
## "Wait...but you called this a frankenMoE?"
|
|
|
6 |
[TinyLlama-1.1B-intermediate-step-1195k-token-2.5T](https://huggingface.co/TinyLlama/TinyLlama-1.1B-intermediate-step-1195k-token-2.5T),
|
7 |
and [tiny-llama-1.1b-chat-medical](https://huggingface.co/SumayyaAli/tiny-llama-1.1b-chat-medical).
|
8 |
|
9 |
+
### Most 1.1B models are incoherent and can't even answer simple questions. I picked out some models that aren't as bad, then scripted for them to be split into different fields properly based on what their training data made them excel at. [The mergekit-moe script can be found here](https://drive.google.com/file/d/1JMdqQ1eTcOUAT6uuWVGgpEKenF2m3gwi/view?usp=drive_link). It is based on [Undi95's config.yaml for his MoE RP here](https://huggingface.co/Undi95/Mixtral-8x7B-MoE-RP-Story/blob/main/config.yaml)
|
10 |
|
11 |
OpenOrca experts have been given the task of creating responses for simple questions about things like pop culture, history, and science...step-1195k experts have been chosen to provide warmth and a positive environment, while chat-medical experts have been chosen to provide further detail about human subjects, and to give small little bits of medical advice: I.E. "how do I get rid of this headache I gave myself from making you?"
|
12 |
|
13 |
+
# ["What is a Mixture of Experts (MoE)?"](https://huggingface.co/blog/moe)
|
14 |
+
### (from the MistralAI papers...click the quoted question above to navigate to it directly.)
|
15 |
|
16 |
The scale of a model is one of the most important axes for better model quality. Given a fixed computing budget, training a larger model for fewer steps is better than training a smaller model for more steps.
|
17 |
|
|
|
23 |
|
24 |
A gate network or router, that determines which tokens are sent to which expert. For example, in the image below, the token “More” is sent to the second expert, and the token "Parameters” is sent to the first network. As we’ll explore later, we can send a token to more than one expert. How to route a token to an expert is one of the big decisions when working with MoEs - the router is composed of learned parameters and is pretrained at the same time as the rest of the network.
|
25 |
|
26 |
+
At every layer, for every token, a router network chooses two of these groups (the “experts”) to process the token and combine their output additively.
|
27 |
|
28 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/6589d7e6586088fd2784a12c/up_I0R2TQGjqTShZp_1Sz.png)
|
29 |
|
|
|
35 |
Although MoEs provide benefits like efficient pretraining and faster inference compared to dense models, they also come with challenges:
|
36 |
|
37 |
Training: MoEs enable significantly more compute-efficient pretraining, but they’ve historically struggled to generalize during fine-tuning, leading to overfitting.
|
38 |
+
Inference: Although a MoE might have many parameters, only some of them are used during inference. This leads to much faster inference compared to a dense model with the same number of parameters. However, all parameters need to be loaded in RAM, so memory requirements are high. For example, [given a MoE like Mixtral 8x7B](https://huggingface.co/blog/moe), we’ll need to have enough VRAM to hold a dense 47B parameter model. Why 47B parameters and not 8 x 7B = 56B? That’s because in MoE models, only the FFN layers are treated as individual experts, and the rest of the model parameters are shared. At the same time, assuming just two experts are being used per token, the inference speed (FLOPs) is like using a 12B model (as opposed to a 14B model), because it computes 2x7B matrix multiplications, but with some layers shared (more on this soon).
|
39 |
+
|
40 |
+
If all our tokens are sent to just a few popular experts, that will make training inefficient. In a normal MoE training, the gating network converges to mostly activate the same few experts. This self-reinforces as favored experts are trained quicker and hence selected more. To mitigate this, an auxiliary loss is added to encourage giving all experts equal importance. This loss ensures that all experts receive a roughly equal number of training examples. The following sections will also explore the concept of expert capacity, which introduces a threshold of how many tokens can be processed by an expert. In transformers, the auxiliary loss is exposed via the aux_loss parameter.
|
41 |
|
42 |
|
43 |
## "Wait...but you called this a frankenMoE?"
|