初始化项目,由ModelHub XC社区提供模型
Model: stockmark/stockmark-13b Source: Original Platform
This commit is contained in:
47
.gitattributes
vendored
Normal file
47
.gitattributes
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.db* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ark* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ggml filter=lfs diff=lfs merge=lfs -text
|
||||
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
82
README.md
Normal file
82
README.md
Normal file
@@ -0,0 +1,82 @@
|
||||
---
|
||||
license: mit
|
||||
language:
|
||||
- ja
|
||||
library_name: transformers
|
||||
pipeline_tag: text-generation
|
||||
tags:
|
||||
- japanese
|
||||
- llama-2
|
||||
- Powered by AWS Trainium
|
||||
---
|
||||
|
||||
# stockmark/stockmark-13b
|
||||
|
||||
Stockmark-13b is a 13 billion parameter LLM pretrained from scratch based on Japanese corpus of about 220B tokens. This model is developed by [Stockmark Inc.](https://stockmark.co.jp/)
|
||||
|
||||
Please see our [blog](https://tech.stockmark.co.jp/blog/202310_stockmark_13b/) for more details.
|
||||
|
||||
This project is supported by [AWS LLM development support program](https://aws.amazon.com/jp/local/llm-development-support-program/).
|
||||
|
||||
We also provide [stockmark-13b-instruct](https://huggingface.co/stockmark/stockmark-13b-instruct), which is the instruction tuned version of stockmark-13b.
|
||||
|
||||
## How to use
|
||||
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
# For A100 or H100 GPU
|
||||
model = AutoModelForCausalLM.from_pretrained("stockmark/stockmark-13b", device_map="auto", torch_dtype=torch.bfloat16)
|
||||
|
||||
# If you use a T4 or V100 GPU, please load a model in 8 bit with the below code.
|
||||
# To do so, you need to install `bitsandbytes` via `pip install bitsandbytes`.
|
||||
# model = AutoModelForCausalLM.from_pretrained("stockmark/stockmark-13b", device_map={"": 0}, load_in_8bit=True)
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained("stockmark/stockmark-13b")
|
||||
|
||||
inputs = tokenizer("自然言語処理とは", return_tensors="pt").to(model.device)
|
||||
with torch.no_grad():
|
||||
tokens = model.generate(
|
||||
**inputs,
|
||||
max_new_tokens=128,
|
||||
do_sample=True,
|
||||
temperature=0.7
|
||||
)
|
||||
|
||||
output = tokenizer.decode(tokens[0], skip_special_tokens=True)
|
||||
print(output)
|
||||
```
|
||||
|
||||
## Examples:
|
||||
|
||||
- LoRA tuning: https://huggingface.co/stockmark/stockmark-13b/blob/main/notebooks/LoRA.ipynb
|
||||
|
||||
## Training dataset
|
||||
|
||||
We have used Japanese corpus of total of about 220 billion tokens.
|
||||
|
||||
|corpus|tokens after preprocessing|
|
||||
|:---:|:---:|
|
||||
|Stockmark Web Corpus (This dataset will not be released)|9.1 billion|
|
||||
|Patent|34.8 billion|
|
||||
|Wikipedia|1.0 billion|
|
||||
|CC100|10.9 billion|
|
||||
|mC4|53.2 billion|
|
||||
|CommonCrawl (snapshot: 2023-23, 2022-49, 2022-21, 2021-21)|112.9 billion|
|
||||
|
||||
|
||||
## Accelerator and Library
|
||||
- Accelerator: AWS Trainium
|
||||
- https://aws.amazon.com/machine-learning/trainium/
|
||||
- Library for distributed training: neuronx-nemo-megatron
|
||||
- https://github.com/aws-neuron/neuronx-nemo-megatron
|
||||
|
||||
## License
|
||||
[MIT](https://opensource.org/licenses/MIT)
|
||||
|
||||
## Developed by
|
||||
[Stockmark Inc.](https://stockmark.co.jp/)
|
||||
|
||||
## Author
|
||||
[Takahiro Omi](https://huggingface.co/omitakahiro)
|
||||
27
config.json
Normal file
27
config.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"_name_or_path": "stockmark/stockmark-13b",
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"bos_token_id": 0,
|
||||
"eos_token_id": 1,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 5120,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 13824,
|
||||
"max_position_embeddings": 2048,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 40,
|
||||
"num_hidden_layers": 40,
|
||||
"num_key_value_heads": 40,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 10000.0,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.34.1",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50000
|
||||
}
|
||||
1
configuration.json
Normal file
1
configuration.json
Normal file
@@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "text-generation", "allow_remote": true}
|
||||
6
generation_config.json
Normal file
6
generation_config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"bos_token_id": 0,
|
||||
"eos_token_id": 1,
|
||||
"pad_token_id": 2,
|
||||
"transformers_version": "4.34.1"
|
||||
}
|
||||
3
model-00001-of-00003.safetensors
Normal file
3
model-00001-of-00003.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:31c1e7b440275d3440c657caa63437741e7804c422b545667545bf48d2099986
|
||||
size 9886571608
|
||||
3
model-00002-of-00003.safetensors
Normal file
3
model-00002-of-00003.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:52ee34892166223b15204b0475357ce1305db78793c268df71a0b75e38c0201d
|
||||
size 9867444424
|
||||
3
model-00003-of-00003.safetensors
Normal file
3
model-00003-of-00003.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a3b7958f53171ebeb1c831c944ed7fde6ae6c4117eecc52ac12bb9d2c20b6944
|
||||
size 6646394880
|
||||
370
model.safetensors.index.json
Normal file
370
model.safetensors.index.json
Normal file
@@ -0,0 +1,370 @@
|
||||
{
|
||||
"metadata": {
|
||||
"total_size": 26400368640
|
||||
},
|
||||
"weight_map": {
|
||||
"lm_head.weight": "model-00003-of-00003.safetensors",
|
||||
"model.embed_tokens.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.11.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.12.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.14.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.14.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.15.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.18.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.19.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.2.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.20.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.20.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.21.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.22.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.23.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.24.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.25.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.26.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.27.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.28.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.input_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.29.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.3.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.30.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.30.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.30.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.30.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.30.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.30.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.30.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.30.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.30.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
|
||||
"model.layers.31.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.31.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.32.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.33.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.34.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.35.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.36.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.37.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.38.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.input_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.39.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
|
||||
"model.layers.4.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.input_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
|
||||
"model.norm.weight": "model-00003-of-00003.safetensors"
|
||||
}
|
||||
}
|
||||
235
notebooks/LoRA.ipynb
Normal file
235
notebooks/LoRA.ipynb
Normal file
@@ -0,0 +1,235 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1a884871-7a65-4501-9063-c85ad260d0da",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"このnotebookはstockmark/stockmark-13bのモデルをkunishou/databricks-dolly-15k-jaのデータセットを用いてLoRA tuningするためのコードの例です。A100またはH100のGPUを用いることを想定しています。\n",
|
||||
"\n",
|
||||
"- モデル:https://huggingface.co/stockmark/stockmark-13b\n",
|
||||
"- データ:https://github.com/kunishou/databricks-dolly-15k-ja\n",
|
||||
"\n",
|
||||
"以下の例では、学習を1 epochを行います。A100 GPUで実行すると30分ほどかかります。\n",
|
||||
"\n",
|
||||
"また、ここで用いられているハイパーパラメータは最適化されたものではありませんので、必要に応じて調整してください。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "93b3f4b5-2825-4ef3-a0ee-7a60155aee5d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 準備"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "6a694ba9-a0fa-4f14-81cf-f35f683ba889",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"import datasets\n",
|
||||
"from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments\n",
|
||||
"from peft import get_peft_model, LoraConfig, PeftModel, PeftConfig\n",
|
||||
"\n",
|
||||
"model_name = \"stockmark/stockmark-13b\"\n",
|
||||
"peft_model_name = \"stockmark-13b-adapter\"\n",
|
||||
"\n",
|
||||
"prompt_template = \"\"\"### Instruction:\n",
|
||||
"{instruction}\n",
|
||||
"\n",
|
||||
"### Input:\n",
|
||||
"{input}\n",
|
||||
"\n",
|
||||
"### Response:\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"def encode(sample):\n",
|
||||
" prompt = prompt_template.format(instruction=sample[\"instruction\"], input=sample[\"input\"])\n",
|
||||
" target = sample[\"output\"]\n",
|
||||
" input_ids_prompt, input_ids_target = tokenizer([prompt, target], add_special_tokens=False).input_ids\n",
|
||||
" input_ids_prompt = [ tokenizer.bos_token_id ] + input_ids_prompt\n",
|
||||
" input_ids_target = input_ids_target + [ tokenizer.eos_token_id ]\n",
|
||||
" input_ids = input_ids_prompt + input_ids_target\n",
|
||||
" labels = input_ids.copy()\n",
|
||||
" labels[:len(input_ids_prompt)] = [-100] * len(input_ids_prompt) # ignore label tokens in a prompt for loss calculation\n",
|
||||
" return {\"input_ids\": input_ids, \"labels\": labels}\n",
|
||||
"\n",
|
||||
"def get_collator(tokenizer, max_length):\n",
|
||||
" def collator(batch):\n",
|
||||
" batch = [{ key: value[:max_length] for key, value in sample.items() } for sample in batch ]\n",
|
||||
" batch = tokenizer.pad(batch)\n",
|
||||
" batch[\"labels\"] = [ e + [-100] * (len(batch[\"input_ids\"][0]) - len(e)) for e in batch[\"labels\"] ]\n",
|
||||
" batch = { key: torch.tensor(value) for key, value in batch.items() }\n",
|
||||
" return batch\n",
|
||||
"\n",
|
||||
" return collator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "51e6cfcf-1ac1-400e-a4bc-ea64375d0f9e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# データセットとモデルのロード"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3ac80067-4e60-46c4-90da-05647cf96ccd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# load_tokenizer\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
||||
"\n",
|
||||
"# prepare dataset\n",
|
||||
"dataset_name = \"kunishou/databricks-dolly-15k-ja\"\n",
|
||||
"dataset = datasets.load_dataset(dataset_name)\n",
|
||||
"dataset = dataset.map(encode)\n",
|
||||
"dataset = dataset[\"train\"].train_test_split(0.1)\n",
|
||||
"train_dataset = dataset[\"train\"]\n",
|
||||
"val_dataset = dataset[\"test\"]\n",
|
||||
"\n",
|
||||
"# load model\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(model_name, device_map=\"auto\", torch_dtype=torch.bfloat16)\n",
|
||||
"\n",
|
||||
"peft_config = LoraConfig(\n",
|
||||
" task_type=\"CAUSAL_LM\",\n",
|
||||
" inference_mode=False,\n",
|
||||
" target_modules=[\"q_proj\", \"k_proj\", \"v_proj\", \"o_proj\"],\n",
|
||||
" r=16,\n",
|
||||
" lora_alpha=32,\n",
|
||||
" lora_dropout=0.05\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"model = get_peft_model(model, peft_config)\n",
|
||||
"model.print_trainable_parameters()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9b471da0-7fba-4127-8b07-22da4cbee6a9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# LoRA Tuning"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b9bafa12-538c-4abb-b8b3-bffeb0990b46",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"training_args = TrainingArguments(\n",
|
||||
" output_dir=\"./log_stockmark_13b\",\n",
|
||||
" learning_rate=2e-4,\n",
|
||||
" per_device_train_batch_size=2,\n",
|
||||
" gradient_accumulation_steps=8,\n",
|
||||
" per_device_eval_batch_size=16,\n",
|
||||
" num_train_epochs=1,\n",
|
||||
" logging_strategy='steps',\n",
|
||||
" logging_steps=10,\n",
|
||||
" save_strategy='epoch',\n",
|
||||
" evaluation_strategy='epoch',\n",
|
||||
" load_best_model_at_end=True,\n",
|
||||
" metric_for_best_model=\"eval_loss\",\n",
|
||||
" greater_is_better=False,\n",
|
||||
" save_total_limit=2\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"trainer = Trainer(\n",
|
||||
" model=model,\n",
|
||||
" args=training_args,\n",
|
||||
" train_dataset=train_dataset,\n",
|
||||
" eval_dataset=val_dataset,\n",
|
||||
" data_collator=get_collator(tokenizer, 320)\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# LoRA tuning\n",
|
||||
"trainer.train()\n",
|
||||
"\n",
|
||||
"# save model\n",
|
||||
"model = trainer.model\n",
|
||||
"model.save_pretrained(peft_model_name)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a3f80a8e-1ac2-4bdc-8232-fe0ee18ffff5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 学習したモデルのロード(Optional)\n",
|
||||
"異なるセッションでモデルを読み込む場合、まず最初の準備のセクションのコードを実行して、このコードを実行してください。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "43241395-3035-4cb9-8c1c-45ffe8cd48be",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
||||
"model = AutoModelForCausalLM.from_pretrained(model_name, device_map=\"auto\", torch_dtype=torch.bfloat16)\n",
|
||||
"model = PeftModel.from_pretrained(model, peft_model_name)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2ce4db1f-9bad-4c8e-9c04-d1102b299f24",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 推論"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d7d6359b-e0ac-49df-a178-39bb9f79ca93",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prompt = prompt_template.format(instruction=\"自然言語処理とは?\", input=\"\")\n",
|
||||
"\n",
|
||||
"inputs = tokenizer(prompt, return_tensors=\"pt\").to(model.device)\n",
|
||||
"with torch.no_grad():\n",
|
||||
" tokens = model.generate(\n",
|
||||
" **inputs,\n",
|
||||
" max_new_tokens=128,\n",
|
||||
" do_sample=True,\n",
|
||||
" temperature=0.7\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
"output = tokenizer.decode(tokens[0], skip_special_tokens=True)\n",
|
||||
"print(output)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
138
notebooks/inferentia2.ipynb
Normal file
138
notebooks/inferentia2.ipynb
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "74c647e6-d096-4e89-af82-a6ca26f80864",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# AWS Inferentia2を用いたstockmark/stockmark-13bの推論\n",
|
||||
"\n",
|
||||
"このノートブックでは、`AWS Inferentia2`上で`stockmark-13b`の推論を実行する方法について説明します。\n",
|
||||
"\n",
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"`AWS Inferentia2`を搭載した`AMAZON EC2 inf2`インスタンスを起動します。AMIは`Deep Learning AMI Neuron PyTorch 1.13`の最新版を、インスタンスタイプは`inf2.8xlarge`を選びます。より高い推論パフォーマンスを得るために、`inf2.24xlarge`や`inf2.48xlarge`などの大きなインスタンスタイプを用いることもできます。\n",
|
||||
"\n",
|
||||
"参考:[Get Started with Latest Release of PyTorch Neuron (torch-neuronx)](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/setup/neuron-setup/pytorch/neuronx/ubuntu/torch-neuronx-ubuntu20-pytorch-dlami.html#setup-torch-neuronx-ubuntu20-dlami-pytorch)\n",
|
||||
"\n",
|
||||
"インスタンスの起動後にインスタンスに接続し、まず仮想環境を作成します。\n",
|
||||
"\n",
|
||||
"`source /opt/aws_neuron_venv_pytorch/bin/activate`\n",
|
||||
"\n",
|
||||
"その後に、`transformers-neuronx`のライブラリをインストールします。\n",
|
||||
"\n",
|
||||
"`pip install transformers-neuronx --extra-index-url=https://pip.repos.neuron.amazonaws.com`\n",
|
||||
"\n",
|
||||
"参考:[Transformers NeuronX (transformers-neuronx)](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/libraries/transformers-neuronx/index.html)\n",
|
||||
"\n",
|
||||
"## Quickstart\n",
|
||||
"\n",
|
||||
"以下では、`AWS Inferentia2`上で`stockmark-13b`の推論(テキスト生成)を行うコードを紹介します。このノートブックは以下のチュートリアルをもとに作成しました。詳しくはこちらもご覧ください。\n",
|
||||
"\n",
|
||||
"参考:[Run Hugging Face meta-llama/Llama-2-13b autoregressive sampling on Inf2 & Trn1](https://github.com/aws-neuron/aws-neuron-samples/blob/master/torch-neuronx/transformers-neuronx/inference/meta-llama-2-13b-sampling.ipynb)\n",
|
||||
"\n",
|
||||
"`transformers-neuronx`を用いて推論を行うためには、事前にモデルファイルをライブラリに対応した形式に変換しておく必要があります。以下のコードは、`stockmark-13b`のモデルをHuggingface Hubからダウンロードし、`./stockmark-13b-split`というディレクトリに保存します。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0475c514-6eb6-4457-aa34-62e1d42517a2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"from transformers_neuronx.module import save_pretrained_split\n",
|
||||
"from transformers import LlamaForCausalLM\n",
|
||||
"\n",
|
||||
"model = LlamaForCausalLM.from_pretrained('stockmark/stockmark-13b', torch_dtype=torch.bfloat16)\n",
|
||||
"save_pretrained_split(model, './stockmark-13b-split')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2a85d74d-757e-4d4c-b81a-9a5b5286207a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"コードが終了したらJupyterLabのカーネルを再起動してください。\n",
|
||||
"\n",
|
||||
"次のコードで、`stockmark-13b`の推論を実行することができます。\n",
|
||||
"\n",
|
||||
"PyTorchでの推論と異なり、AWS Inferentia2で推論を行うために、計算グラフをコンパイルする必要があり、それに数分程度の時間がかかります。次回以降は、キャッシュされた結果が用いられます。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ef9a9a2d-43a7-4611-8708-e2dea60454c5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import torch\n",
|
||||
"from transformers import AutoTokenizer\n",
|
||||
"from transformers_neuronx.llama.model import LlamaForSampling\n",
|
||||
"\n",
|
||||
"os.environ['NEURON_CC_FLAGS'] = '-O1'\n",
|
||||
"\n",
|
||||
"## load tokenizer\n",
|
||||
"tokenizer = AutoTokenizer.from_pretrained('stockmark/stockmark-13b')\n",
|
||||
"\n",
|
||||
"## load model\n",
|
||||
"model = LlamaForSampling.from_pretrained(\"./stockmark-13b-split\", batch_size=1, tp_degree=2, amp='f16')\n",
|
||||
"model.to_neuron() # compile\n",
|
||||
"\n",
|
||||
"## inference\n",
|
||||
"prompt = \"自然言語処理とは?\"\n",
|
||||
"inputs = tokenizer(prompt, return_tensors=\"pt\")\n",
|
||||
"\n",
|
||||
"with torch.inference_mode():\n",
|
||||
" tokens = model.sample(inputs.input_ids, temperature = 1.0, sequence_length = 256)\n",
|
||||
" \n",
|
||||
"generated_text = tokenizer.decode(tokens[0], skip_special_tokens=True)\n",
|
||||
"\n",
|
||||
"print(generated_text)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e19998fa-2db4-4bf2-b914-10d0885f5388",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Tensor parallelism\n",
|
||||
"\n",
|
||||
"`transformers-neuronx`のライブラリではテンソル並列化をサポートされています。これにより、モデルを複数のNeuronCoreに配置し、計算を並列に行うことで、推論のパフォーマンスを高めることができます。並列数(いくつのNeuronCoreを用いるか)は、モデルのロードを行う関数`LlamaForSampling.from_pretrained`の引数`tp_degree`から指定することができます。上の例では、`tp_degree=2`を指定しています。\n",
|
||||
"\n",
|
||||
"指定可能な`tp_degree`の値は、インスタンスタイプに依存します。大きなインスタンスを用いて、`tp_degree`の値を大きくすることで、latencyを小さくすることができます。\n",
|
||||
"\n",
|
||||
"| インスタンスタイプ | 指定可能なtp_degreeの最大数 |\n",
|
||||
"|:---:|:---:|\n",
|
||||
"|inf2.8xlarge|2|\n",
|
||||
"|inf2.24xlarge|12|\n",
|
||||
"|inf2.48xlarge|24|"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
6
special_tokens_map.json
Normal file
6
special_tokens_map.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"bos_token": "<s>",
|
||||
"eos_token": "</s>",
|
||||
"pad_token": "<pad>",
|
||||
"unk_token": "<unk>"
|
||||
}
|
||||
99874
tokenizer.json
Normal file
99874
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
11
tokenizer_config.json
Normal file
11
tokenizer_config.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"bos_token": "<s>",
|
||||
"clean_up_tokenization_spaces": false,
|
||||
"eos_token": "</s>",
|
||||
"model_max_length": 1000000000000000019884624838656,
|
||||
"pad_token": "<pad>",
|
||||
"padding_side": "right",
|
||||
"tokenizer_class": "LlamaTokenizerFast",
|
||||
"unk_token": "<unk>",
|
||||
"use_default_system_prompt": true
|
||||
}
|
||||
Reference in New Issue
Block a user