Downloads · 30 days
14
16% of all-time downloads
keras/magistral_small_2507_en
magistral_small_2507_en is a text generation model from keras. Use it when you need the model to write or continue text. It is set up for keras-hub.
Magistral is MistralAI's family of reasoning-focused large language models, fine-tuned from Mistral Small 3.1 using supervised fine-tuning (SFT) on reasoning traces and reinforcement learning (RL). Magistral models ar…
Downloads · 30 days
14
16% of all-time downloads
All-time downloads
86
Public
Repo size
47.1 GB
Likes
0
Public
Click a slice to open those files.
.h547.1 GB · 100%
From the Hugging Face model README
Magistral is MistralAI's family of reasoning-focused large language models, fine-tuned from Mistral Small 3.1 using supervised fine-tuning (SFT) on reasoning traces and reinforcement learning (RL). Magistral models are designed for complex, multi-step reasoning tasks including mathematics, coding, logic, and scientific analysis.
Key features:
-Architecture: Based on Mistral with explicit head_dim=128 and no sliding window attention
-**Reasoning:**Uses [THINK]/[/THINK] special tokens for chain-of-thought reasoning
-**Context:**128K token context window (recommended up to 40K for optimal performance)
Keras and KerasHub can be installed with:
pip install -U -q keras-hub
pip install -U -q keras
Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the Keras Getting Started page.
| Preset Name | Parameters | Description |
|---|---|---|
| A | B | C |
import os
# Configure Keras to use the JAX backend
os.environ["KERAS_BACKEND"] = "jax"
import keras
import keras_hub
# Load the Magistral Small 2507 model
# This will automatically download the weights from Kaggle
causal_lm = keras_hub.models.MistralCausalLM.from_preset("magistral_small_2507_en")
# Generate text
prompt = "The most important concepts to understand in machine learning are"
output = causal_lm.generate(prompt, max_length=100)
print(output)
# Load only the feature extractor backbone
backbone = keras_hub.models.MistralBackbone.from_preset("magistral_small_2507_en")
# Pass a batch of tokenized sequences to get hidden states
import numpy as np
dummy_tokens = np.random.randint(0, 1000, size=(2, 64))
hidden_states = backbone(dummy_tokens)
print(hidden_states.shape)
import os
# Configure Keras to use the JAX backend
os.environ["KERAS_BACKEND"] = "jax"
import keras
import keras_hub
# Load the Magistral Small 2507 model
# This will automatically download the weights from Kaggle
causal_lm = keras_hub.models.MistralCausalLM.from_preset("hf://keras/magistral_small_2507_en")
# Generate text
prompt = "The most important concepts to understand in machine learning are"
output = causal_lm.generate(prompt, max_length=100)
print(output)
# Load only the feature extractor backbone
backbone = keras_hub.models.MistralBackbone.from_preset("hf://keras/magistral_small_2507_en")
# Pass a batch of tokenized sequences to get hidden states
import numpy as np
dummy_tokens = np.random.randint(0, 1000, size=(2, 64))
hidden_states = backbone(dummy_tokens)
print(hidden_states.shape)