Model Details of Mistral-7B-Instruct-v0.2-expanded
Mistral-7B-Instruct-v0.2-expanded
This method employs mergekit's passthrough method to expand blocks within the "mistralai/Mistral-7B-Instruct-v0.2" model. For every 5th layer,
a new layer is added, with the
o_proj
and
down_proj
parameters of these added layers initialized to zero, mirroring the approach used in LLaMA Pro.
It's important to note that this configuration has not undergone fine-tuning. So this won't work. Therefore, when fine-tuning, ensure that only every 5th layer is trainable,while all other layers remain frozen.
from transformers import AutoModelForCausalLM
def enable_grad_only_every_nth(model, n):
"""
This function configures the specified model to enable gradient calculations exclusively for every nth layer, starting
from the first layer (0-indexed), to accommodate newly added blocks for training. Concurrently, it freezes the gradients
for all other components of the model, including the embedding layers and the model's head. This setup is particularly
useful for fine-tuning processes where only a subset of layers are targeted for updates, ensuring efficient training and
adaptation of newly integrated layers while maintaining the pre-trained behavior of other model components.
"""
# Freeze embeddings.
for param in model.model.embed_tokens.parameters():
param.requires_grad = False
# Freeze lm_head.
for param in model.lm_head.parameters():
param.requires_grad = False
# Enable gradients for every nth layer
layers = model.model.layers # Access the ModuleList containing the layers
for index, layer in enumerate(layers):
if (index + 1) % n == 0: # Enables gradients for every nth layer, starting from the layer after the 0th
for param in layer.parameters():
param.requires_grad = True
else:
for param in layer.parameters():
param.requires_grad = False
model = transformers.AutoModelForCausalLM.from_pretrained(
"arcee-ai/Mistral-7B-Instruct-v0.2-expanded"
)
# Update layer gradients, specify the correct value for n based on your model's architecture
n =5
enable_grad_only_every_nth(model, n)
Runs of arcee-ai Mistral-7B-Instruct-v0.2-expanded on huggingface.co
98
Total runs
-2
24-hour runs
-5
3-day runs
-9
7-day runs
4
30-day runs
More Information About Mistral-7B-Instruct-v0.2-expanded huggingface.co Model
Mistral-7B-Instruct-v0.2-expanded huggingface.co
Mistral-7B-Instruct-v0.2-expanded huggingface.co is an AI model on huggingface.co that provides Mistral-7B-Instruct-v0.2-expanded's model effect (), which can be used instantly with this arcee-ai Mistral-7B-Instruct-v0.2-expanded model. huggingface.co supports a free trial of the Mistral-7B-Instruct-v0.2-expanded model, and also provides paid use of the Mistral-7B-Instruct-v0.2-expanded. Support call Mistral-7B-Instruct-v0.2-expanded model through api, including Node.js, Python, http.
Mistral-7B-Instruct-v0.2-expanded huggingface.co is an online trial and call api platform, which integrates Mistral-7B-Instruct-v0.2-expanded's modeling effects, including api services, and provides a free online trial of Mistral-7B-Instruct-v0.2-expanded, you can try Mistral-7B-Instruct-v0.2-expanded online for free by clicking the link below.
arcee-ai Mistral-7B-Instruct-v0.2-expanded online free url in huggingface.co:
Mistral-7B-Instruct-v0.2-expanded is an open source model from GitHub that offers a free installation service, and any user can find Mistral-7B-Instruct-v0.2-expanded on GitHub to install. At the same time, huggingface.co provides the effect of Mistral-7B-Instruct-v0.2-expanded install, users can directly use Mistral-7B-Instruct-v0.2-expanded installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Mistral-7B-Instruct-v0.2-expanded install url in huggingface.co: