U
You
14:32
What makes Mistral's mixture-of-experts architecture different from a dense model, and when should I choose one over the other for production?
M
Le Chat
14:32
The core distinction is how parameters are activated per token:
- Dense models use 100% of their parameters for every token. Computation scales with total parameter count.
- Mixture-of-Experts (MoE) models route each token to a small subset of "expert" networks. Mixtral 8×7B activates only ~13B of its 47B parameters per token.
This gives you the quality of a larger model at the inference cost of a smaller one:
from mistralai import Mistral
client = Mistral(api_key="...")
response = client.chat.complete(
model="mistral-large-latest",
messages=[{"role": "user", "content": "Explain MoE"}]
)
Choose MoE when you want high quality with controlled latency. Choose dense when you need predictable per-token cost and simpler deployment.
U
You
14:34
Can you show me how to stream the response with function calling?
M
Le Chat
14:34
Yes — here's a streaming example with a tool definition. The stream yields chunks you can aggregate as they arrive:
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
stream = client.chat.stream(
model="mistral-large-latest",
messages=messages,
tools=tools
)
for chunk in stream:
print(chunk.data.choices[0].delta.content, end="")
The model emits a tool_calls object when it decides to call a function — you execute it locally and feed the result back.
Select model
Mistral Large 2
Flagship — top-tier reasoning
Mistral Medium 3
Balanced — ideal for work
Mistral Small
Fast — lightweight tasks
Codestral
22B — code generation
Le Chat can make mistakes. Verify important information.