add model
Browse files- README.md +16 -3
- config.json +2 -3
- init_model.py +26 -0
- model_bf16.safetensors/config.json +30 -0
- model_bf16.safetensors/generation_config.json +6 -0
README.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
This
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Micro Mistral
|
| 2 |
|
| 3 |
+
This is a small mistral model with 6 layers
|
| 4 |
|
| 5 |
+
It is similar to smol llama varaints uses GQA and tied embeddings.
|
| 6 |
+
Except it uses mistral style arch with GQA and sliding window attention
|
| 7 |
+
|
| 8 |
+
This architecture takes GQA and tied embeddings to create an effeceint 0.5B model that uses the mistral architecture(It is supported in downstream applications)
|
| 9 |
+
|
| 10 |
+
#### Dataset
|
| 11 |
+
|
| 12 |
+
Minipile
|
| 13 |
+
Instruct
|
| 14 |
+
Math
|
| 15 |
+
OpenOrca
|
| 16 |
+
Synthetic Data
|
| 17 |
+
|
| 18 |
+
TODO: Complete Dataset section
|
config.json
CHANGED
|
@@ -25,6 +25,5 @@
|
|
| 25 |
"torch_dtype": "bfloat16",
|
| 26 |
"transformers_version": "4.34.1",
|
| 27 |
"use_cache": true,
|
| 28 |
-
"vocab_size": 50304
|
| 29 |
-
|
| 30 |
-
}
|
|
|
|
| 25 |
"torch_dtype": "bfloat16",
|
| 26 |
"transformers_version": "4.34.1",
|
| 27 |
"use_cache": true,
|
| 28 |
+
"vocab_size": 50304
|
| 29 |
+
}
|
|
|
init_model.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import AutoConfig, AutoModelForCausalLM
|
| 3 |
+
|
| 4 |
+
# Load the configuration and initialize the model
|
| 5 |
+
config_path = "config.json" # Adjust path as necessary
|
| 6 |
+
config = AutoConfig.from_pretrained(config_path)
|
| 7 |
+
model = AutoModelForCausalLM.from_config(config)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Reinitialize weights with a standard deviation of 0.02 for a more controlled initialization
|
| 11 |
+
def reinitialize_weights(module):
|
| 12 |
+
if hasattr(module, "weight") and not isinstance(module, torch.nn.LayerNorm):
|
| 13 |
+
torch.nn.init.normal_(module.weight, mean=0.0, std=0.02)
|
| 14 |
+
if hasattr(module, "bias") and module.bias is not None:
|
| 15 |
+
torch.nn.init.constant_(module.bias, 0.0)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
model.apply(reinitialize_weights)
|
| 19 |
+
|
| 20 |
+
# Cast the model's parameters to bf16
|
| 21 |
+
model = model.to(
|
| 22 |
+
dtype=torch.bfloat16
|
| 23 |
+
) # Converts all floating point parameters to bfloat16
|
| 24 |
+
|
| 25 |
+
# Save the model with SafeTensors
|
| 26 |
+
model.save_pretrained("./model_bf16.safetensors", save_in_safe_tensors_format=True)
|
model_bf16.safetensors/config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "config.json",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"LlamaForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"bos_token_id": 1,
|
| 9 |
+
"dropout_p": 0.1,
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 1024,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 3072,
|
| 15 |
+
"max_position_embeddings": 4096,
|
| 16 |
+
"model_type": "llama",
|
| 17 |
+
"num_attention_heads": 128,
|
| 18 |
+
"num_hidden_layers": 6,
|
| 19 |
+
"num_key_value_heads": 16,
|
| 20 |
+
"pretraining_tp": 1,
|
| 21 |
+
"rms_norm_eps": 1e-05,
|
| 22 |
+
"rope_scaling": null,
|
| 23 |
+
"rope_theta": 10000.0,
|
| 24 |
+
"sliding_window": 1024,
|
| 25 |
+
"tie_word_embeddings": true,
|
| 26 |
+
"torch_dtype": "bfloat16",
|
| 27 |
+
"transformers_version": "4.36.2",
|
| 28 |
+
"use_cache": true,
|
| 29 |
+
"vocab_size": 50304
|
| 30 |
+
}
|
model_bf16.safetensors/generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"transformers_version": "4.36.2"
|
| 6 |
+
}
|