Free AI web copilot to create summaries, insights and extended knowledge, download it at here
4872
Abstract
nd prompting Arthur Mensch, CEO of Mistral, to remove the problematic clause.</p>
<figure id="4daa">
<div>
<div>
<img class="ratio" src="http://placehold.it/16x9">
<iframe class="" src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&key=a19fcc184b9711e1b4764040d3dc5c07&schema=twitter&url=https%3A//twitter.com/arthurmensch/status/1734470462451732839%3Fs%3D20&image=https%3A//i.embed.ly/1/image%3Furl%3Dhttps%253A%252F%252Fabs.twimg.com%252Ferrors%252Flogo46x38.png%26key%3Da19fcc184b9711e1b4764040d3dc5c07" allowfullscreen="" frameborder="0" height="281" width="500">
</div>
</div>
</figure></iframe></div></div></figure><p id="86d1">Lastly, to address the elephant in the room: Mistral isn’t a GitHub repository that drew a vast number of programmers tirelessly working to release a smart open-source LLM. Instead, it’s a company that raised over <a href="https://techcrunch.com/2023/12/11/mistral-ai-a-paris-based-openai-rival-closed-its-415-million-funding-round/?guccounter=1">500 million</a> in 2023 alone, with Bloomberg valuing the company at roughly <a href="https://mercury.bloomberg.com/images/405322296">2 billion</a>. Their choice not to release the training code, documentation, and dataset — in other words, keeping the model relatively closed-source — is a strategy for Mistral to maintain its competitive edge.</p><p id="7278">So to sum things up, Mixtral-8x7B is <b><i>the best open-weights model</i></b> that outperforms GPT3.5 and Llama 2 70B on most benchmarks.</p><h1 id="5b09">What is Mixture of Experts (MoE) Anyway?</h1><p id="f2c0">Let me remind you again of Mistral’s definition of the model:</p><blockquote id="5a42"><p>“<i>a high-quality <b>sparse mixture of experts model (SMoE)</b> with open weights</i>”.</p></blockquote><p id="7029">A lot of us (myself included) encountered this term for the first time thanks to the release of Mixtral. To TLDR it for you:</p><p id="45eb">MoEs originated from a <a href="https://www.cs.toronto.edu/~hinton/absps/jjnh91.pdf">1991 research paper </a>where a system uses <b>multiple neural networks.</b> These networks, or ‘experts’, are selected by a <b>gating network</b> that assigns their <b>roles and weights</b>. Both experts and the gating network are trained together to effectively handle diverse training cases.</p><figure id="ec1d"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*uSkP3yw0Pp4V_SPHPVbejw.png"><figcaption>MoE layer from the Outrageously Large Neural Network paper</figcaption></figure><p id="7463">For anyone interested going into more depth, I suggest this <a href="https://huggingface.co/blog/moe">HuggingFace article.</a></p><p id="5025">Sparsity in MoEs means that only <b><i>parts of the network</i></b> are active <b><i>for specific inputs</i></b>, allowing scaling without increasing total computation.</p><h2 id="c6eb">Pros of sparse MoEs:</h2><ol><li><b>Efficient Pretraining</b>: MoEs allow for faster and more compute-efficient. This means <a href="https://huggingface.co/google/switch-c-2048">larger models</a> or datasets can be trained with the <i>same computing budget</i>.</li><li><b>Faster Inference</b>: Although MoEs have many parameters, only a subset is active during inference, leading to <i>quicker processing</i>.</li></ol><h2 id="ae50">Cons of sparse MoEs:</h2><ol><li><b>Fine-Tuning</b>: sparse MoEs historically struggle with fine-tuning, often leading to overfitting, although <a href="https://arxiv.org/pdf/2305.14705.pdf">recent research</a> gives a lot of hope.</li><li><b>Memory Requirements</b>: All parameters of MoEs need to be loaded into memory, requiring substantial VRAM.</li><li><b>Load Balancing</b>: Ensuring even distribution of computation across experts is a challenge, often addressed by auxiliary loss functions and expert capacity thresholds.</li></ol><h1 id="97ce">How To Run it Locally</h1><p id="1622">2 most popular ways are:</p><h2 id="9cc2">VLLM</h2><div id="1433" class="link-block">
<a href="https://github.com/vllm-project/vllm/issues/1991">
<div>
<div>
<h2>Add Mixture of Experts: Mixtral 8x 7B release · Issue #1991 · vllm-project/vllm</h2>
<div><h3>Mistral AI released their new model called Mixtral which is an MoE architecture based on MegaBlocks. It includes 8…</h3></div>
<div><p>github.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*QvHrtfs08p-4dTnm)"></div>
</div>
</div>
</a>
</div><h2 id="5574">and LM Studio</h2><div id="35e2" class="link-block">
<a href="https://lmstudio.ai/">
<div>
<div>
Options
<h2>👾 LM Studio - Discover and run local LLMs</h2>
<div><h3>LM Studio is an easy to use desktop app for experimenting with local and open-source Large Language Models (LLMs). The…</h3></div>
<div><p>lmstudio.ai</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*wrcqbq68WvHRMNz6)"></div>
</div>
</div>
</a>
</div><h1 id="a68c">Mixtral-8x7B Demos</h1><p id="1f49">If you’d like to test out Mixtral but you don’t have an option to run it locally, here’s a list of the best platforms that offers Mixtral inference:</p><h2 id="9bd0">Perplexity labs</h2><figure id="d07a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*S8HBsiPol-ZcX6VbAa93SA.png"><figcaption>Screenshot of perplexity labs</figcaption></figure><h2 id="5c48">Vercel</h2><figure id="1ec1"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*M9s9yv5F_Ae3TfWmM9I42g.png"><figcaption>Screenshot of Vercel AI</figcaption></figure><h2 id="1759">Replicate</h2><figure id="eee8"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*_xR3t9xiwgAEPtu601flKA.png"><figcaption>Screenshot of Replicate</figcaption></figure><h1 id="87f1">Platform API endpoints</h1><p id="1826">Mistral AI currently provides access to Large Language Models through an <a href="https://docs.mistral.ai/platform/pricing">pay-as-you-go API</a>. It’s in beta right now and however wants access has to join the waitlist first.</p><p id="4b68">Mistral <a href="https://docs.mistral.ai/platform/endpoints">offers 3 models</a> for endpoints:</p><ol><li><b><i>mistral-tiny — </i></b>Mistral-7B-v0.2, a better fine-tuning of the initial Mistral-7B released. The most affordable model</li><li><b><i>mistral-small — </i></b>Mixtral-8X7B-v0.1, excellent choice for code generation and multilanguage output</li><li><b><i>mistral-medium — </i></b>This model is a mystery and many speculate that its <a href="https://www.reddit.com/r/LocalLLaMA/comments/18fq00r/mistral_has_an_even_more_powerfull_model_in_the/?utm_source=share&utm_medium=web2x&context=3">performance might match GPT4</a></li><li><b><i>mistral-embed — </i></b>Embeddings models for retrieval and RAG</li></ol><p id="3eb4">Mistral AI provides client codes in both <a href="https://docs.mistral.ai/platform/client">Python and Javascript</a>. For the sake of simplicity I’ll share the client code in Python, but you can find javascript code in their docs:</p><h2 id="22d8">Chat Completion</h2><div id="b6d1"><pre><span class="hljs-keyword">from</span> mistralai.client <span class="hljs-keyword">import</span> MistralClient
<span class="hljs-keyword">from</span> mistralai.models.chat_completion <span class="hljs-keyword">import</span> ChatMessage
api_key = os.environ[<span class="hljs-string">"MISTRAL_API_KEY"</span>]
model = <span class="hljs-string">"mistral-tiny"</span>
client = MistralClient(api_key=api_key)
messages = [
ChatMessage(role=<span class="hljs-string">"user"</span>, content=<span class="hljs-string">"What is the best French cheese?"</span>)
]
<span class="hljs-comment"># No streaming</span>
chat_response = client.chat(
model=model,
messages=messages,
)
<span class="hljs-comment"># With streaming</span>
<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> client.chat_stream(model=model, messages=messages):
<span class="hljs-built_in">print</span>(chunk)</pre></div><h2 id="d575">Embeddings</h2><div id="13c7"><pre><span class="hljs-keyword">from</span> mistralai.client <span class="hljs-keyword">import</span> MistralClient
api_key = os.environ[<span class="hljs-string">"MISTRAL_API_KEY"</span>]
client = MistralClient(api_key=api_key)
embeddings_batch_response = client.embeddings(
model=<span class="hljs-string">"mistral-embed"</span>,
<span class="hljs-built_in">input</span>=[<span class="hljs-string">"Embed this sentence."</span>, <span class="hljs-string">"As well as this one."</span>],
)</pre></div><h1 id="12b5">Conclusion</h1><p id="f125">Mixtral 8x7B stands out as an exceptional open-weights model. The Mistral team appears deeply attuned to their customers’ needs, consistently delivering products that resonate with a wide audience through clever, yet relatively low-key marketing strategies.</p><p id="02af">After several years of OpenAI’s market dominance, Mistral’s API access is set to offer millions of developers greater choice, enabling them to select the model that best meets their needs. With substantial funding behind them, we can anticipate not only amazing models from Mistral but also a potential shift towards more closed-source LLMs. I’m genuinely excited about Mistral and can’t wait to see what’s next!</p></article></body>