From 2d3fbd5ed16018136cc162eebc4cb18aefa53efb Mon Sep 17 00:00:00 2001 From: ModelHub XC Date: Sun, 14 Jun 2026 11:28:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E7=94=B1ModelHub=20XC=E7=A4=BE=E5=8C=BA=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Model: sbintuitions/tiny-lm-chat Source: Original Platform --- .gitattributes | 36 ++++++++++++++ LICENSE | 7 +++ README.md | 40 +++++++++++++++ added_tokens.json | 5 ++ config.json | 28 +++++++++++ configuration.json | 1 + generation_config.json | 6 +++ pytorch_model.bin | 3 ++ special_tokens_map.json | 56 +++++++++++++++++++++ spiece.model | 3 ++ tokenizer_config.json | 107 ++++++++++++++++++++++++++++++++++++++++ 11 files changed, 292 insertions(+) create mode 100644 .gitattributes create mode 100644 LICENSE create mode 100644 README.md create mode 100644 added_tokens.json create mode 100644 config.json create mode 100644 configuration.json create mode 100644 generation_config.json create mode 100644 pytorch_model.bin create mode 100644 special_tokens_map.json create mode 100644 spiece.model create mode 100644 tokenizer_config.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2ef8cfb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,36 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt 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 +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz 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 +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl 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 +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* 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 +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +pytorch_model.bin filter=lfs diff=lfs merge=lfs -text diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5d5d252 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2024 SB Intuitions. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..edce301 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +--- +license: mit +datasets: +- wikipedia +- llm-jp/oasst1-21k-ja +- llm-jp/oasst1-21k-en +language: +- ja +- en +--- + +# tiny-lm + +This repository provides a tiny 16M parameters language model for debugging and testing purposes. +This is created by tuning [sbintuitions/tiny-lm](https://huggingface.co/sbintuitions) with oasset1 datasets in Japanese and English. + +## How to use + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline + +model = AutoModelForCausalLM.from_pretrained("sbintuitions/tiny-lm-chat", torch_dtype="auto") +tokenizer = AutoTokenizer.from_pretrained("sbintuitions/tiny-lm-chat", use_fast=False) +generator = pipeline("text-generation", model=model, tokenizer=tokenizer) + +prompt = tokenizer.apply_chat_template([{"role": "user", "content": "Hello!"}], add_generation_prompt=True, tokenize=False) +print(generator(prompt, max_length=30, do_sample=True, top_k=100)) +``` + +## Model architecture +A 4-layer, 512-hidden-size transformer-based language model. + +## Training +The model was first pre-trained on English Wikipedia and Japanese Wikipedia to optimize a traditional language modelling objective for 25B tokens. +And then it was fine-tuned on oasst1 datasets in Japanese and English for 15 epochs. + +## License +[MIT License](https://huggingface.co/sbintuitions/tiny-lm-chat/resolve/main/LICENSE) + + diff --git a/added_tokens.json b/added_tokens.json new file mode 100644 index 0000000..01d1036 --- /dev/null +++ b/added_tokens.json @@ -0,0 +1,5 @@ +{ + "<|assistant|>": 51201, + "<|system|>": 51200, + "<|user|>": 51202 +} diff --git a/config.json b/config.json new file mode 100644 index 0000000..f62a357 --- /dev/null +++ b/config.json @@ -0,0 +1,28 @@ +{ + "architectures": [ + "LlamaForCausalLM" + ], + "attention_bias": false, + "attention_dropout": 0.0, + "bos_token_id": 1, + "eos_token_id": 2, + "hidden_act": "silu", + "hidden_size": 256, + "initializer_range": 0.02, + "intermediate_size": 640, + "max_position_embeddings": 2048, + "mlp_bias": false, + "model_type": "llama", + "num_attention_heads": 4, + "num_hidden_layers": 4, + "num_key_value_heads": 4, + "pretraining_tp": 1, + "rms_norm_eps": 1e-05, + "rope_scaling": null, + "rope_theta": 10000.0, + "tie_word_embeddings": false, + "torch_dtype": "float32", + "transformers_version": "4.41.2", + "use_cache": true, + "vocab_size": 51203 +} diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..bbeeda1 --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "text-generation", "allow_remote": true} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..e8111d8 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,6 @@ +{ + "_from_model_config": true, + "bos_token_id": 1, + "eos_token_id": 2, + "transformers_version": "4.41.2" +} diff --git a/pytorch_model.bin b/pytorch_model.bin new file mode 100644 index 0000000..1cf37dc --- /dev/null +++ b/pytorch_model.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f5d796774360efdda5a4ee04740fd2e09d8001d15b3c66f0d4ce4e64b96dcfb +size 58478499 diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..b79467c --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,56 @@ +{ + "additional_special_tokens": [ + "<|system|>", + "<|assistant|>", + "<|user|>" + ], + "bos_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "cls_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "eos_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "mask_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "pad_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "sep_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + }, + "unk_token": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false + } +} diff --git a/spiece.model b/spiece.model new file mode 100644 index 0000000..30b8ae4 --- /dev/null +++ b/spiece.model @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:362dfed338d41958f7c4dcefcf997ecf7cb9a6d67b6146347d3cafd59339cc94 +size 1117982 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..a272d1c --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,107 @@ +{ + "add_prefix_space": true, + "added_tokens_decoder": { + "0": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "1": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "2": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "3": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "4": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "5": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "6": { + "content": "", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "51200": { + "content": "<|system|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "51201": { + "content": "<|assistant|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + }, + "51202": { + "content": "<|user|>", + "lstrip": false, + "normalized": false, + "rstrip": false, + "single_word": false, + "special": true + } + }, + "additional_special_tokens": [ + "<|system|>", + "<|assistant|>", + "<|user|>" + ], + "bos_token": "", + "chat_template": "{%- for message in messages -%}\n{%- if message['role'] == 'assistant' -%}\n{{ '<|assistant|>' + message['content'] + eos_token }}\n{%- elif message['role'] == 'system' -%}\n{{ '<|system|>' + message['content'] + eos_token }}\n{%- elif message['role'] == 'user' -%}\n{{ '<|user|>' + message['content'] + eos_token }}\n{%- endif -%}\n{%- if loop.last and add_generation_prompt -%}\n{{ '<|assistant|>' }}\n{%- endif -%}\n{%- endfor -%}", + "clean_up_tokenization_spaces": true, + "cls_token": "", + "do_lower_case": false, + "eos_token": "", + "extra_ids": 0, + "keep_accents": true, + "legacy": true, + "mask_token": "", + "model_max_length": 1000000000000000019884624838656, + "pad_token": "", + "padding_side": "right", + "sep_token": "", + "sp_model_kwargs": {}, + "tokenizer_class": "T5Tokenizer", + "unk_token": "" +}