fujiki commited on
Commit
81414f9
1 Parent(s): 90a0061

Add README etc.

Browse files
README.md CHANGED
@@ -1,3 +1,133 @@
1
  ---
2
- license: llama2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ja
4
+ tags:
5
+ - japanese-stablelm
6
+ - causal-lm
7
+ pipeline_tag: text-generation
8
+ datasets:
9
+ - wikipedia
10
+ - mc4
11
+ - cc100
12
+ - oscar-corpus/OSCAR-2301
13
+ - oscar-corpus/OSCAR-2201
14
+ - cerebras/SlimPajama-627B
15
+ license:
16
+ - llama2
17
+ extra_gated_fields:
18
+ Name: text
19
+ Email: text
20
+ Country: text
21
+ Organization or Affiliation: text
22
+ I allow Stability AI to contact me about information related to its models and research: checkbox
23
  ---
24
+
25
+ # Japanese-StableLM-Base-JAVocab-Beta-7B
26
+
27
+ ![A cute robot wearing a kimono writes calligraphy with one single brush](./japanese-stablelm-robot.jpg)
28
+
29
+ > A cute robot wearing a kimono writes calligraphy with one single brush — [Stable Diffusion XL](https://clipdrop.co/stable-diffusion)
30
+
31
+ ## Model Description
32
+
33
+ `japanese-stablelm-base-ja_vocab-beta-7b` is a 7B-parameter decoder-only language model based on [Llama-2-7b](https://huggingface.co/meta-llama/Llama-2-7b) that has been fine-tuned on a diverse collection of Japanese data, with the intent of maximizing downstream performance on Japanese language tasks.
34
+
35
+ Compared to the [standard base model](https://huggingface.co/stabilityai/japanese-stablelm-base-beta-7b), this model uses a tokenizer with an expanded vocabulary derived from Japanese data. This allows it to represent the same amount of text with fewer tokens, which speeds up inference significantly.
36
+
37
+ For an instruction-following version of this model, see [Japanese-StableLM-Instruct-JAVocab-Beta-7B](https://huggingface.co/stabilityai/japanese-stablelm-instruct-ja_vocab-beta-7b).
38
+
39
+ ## Usage
40
+
41
+ First install additional dependencies in [requirements.txt](./requirements.txt):
42
+
43
+ ```sh
44
+ pip install -r requirements.txt
45
+ ```
46
+
47
+ Then start generating text with `japanese-stablelm-base-ja_vocab-beta-7b` by using the following code snippet:
48
+
49
+ ```python
50
+ import torch
51
+ from transformers import AutoTokenizer, AutoModelForCausalLM
52
+
53
+ model_name = "stabilityai/japanese-stablelm-base-beta-7b"
54
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
55
+
56
+ # The next line may need to be modified depending on the environment
57
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, low_cpu_mem_usage=True, device_map="auto")
58
+
59
+ prompt = """
60
+ AI で科学研究を加速するには、
61
+ """.strip()
62
+
63
+ input_ids = tokenizer.encode(
64
+ prompt,
65
+ add_special_tokens=False,
66
+ return_tensors="pt"
67
+ )
68
+
69
+ # this is for reproducibility.
70
+ # feel free to change to get different result
71
+ seed = 23
72
+ torch.manual_seed(seed)
73
+
74
+ tokens = model.generate(
75
+ input_ids.to(device=model.device),
76
+ max_new_tokens=128,
77
+ temperature=0.99,
78
+ top_p=0.95,
79
+ do_sample=True,
80
+ )
81
+
82
+ out = tokenizer.decode(tokens[0], skip_special_tokens=True)
83
+ print(out)
84
+ ```
85
+
86
+ We suggest playing with different generation config (`top_p`, `repetition_penalty` etc) to find the best setup for your tasks. For example, use higher temperature for roleplay task, lower temperature for reasoning.
87
+
88
+ ## Model Details
89
+
90
+ * **Model type**: `japanese-stablelm-base-ja_vocab-beta-7b` model is an auto-regressive language model based on the Llama2 transformer architecture.
91
+ * **Language(s)**: Japanese
92
+ * **Library**: [Tinypar](https://github.com/Stability-AI/jp-tinypar)
93
+ * **License**: [Llama2 Community License](https://ai.meta.com/llama/license/).
94
+ * **Contact**: For questions and comments about the model, please join [Stable Community Japan](https://discord.gg/StableJP). For future announcements / information about Stability AI models, research, and events, please follow https://twitter.com/StabilityAI_JP.
95
+
96
+ ## Training Dataset
97
+
98
+ Roughly 100B tokens from a mixture of the following corpora were used for continued pre-training.
99
+
100
+ - [Japanese/English Wikipedia](https://dumps.wikimedia.org/other/cirrussearch)
101
+ - [Japanese mc4](https://huggingface.co/datasets/mc4)
102
+ - [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz)
103
+ - [Japanese OSCAR](https://oscar-project.github.io/documentation/)
104
+ - [SlimPajama](https://huggingface.co/datasets/cerebras/SlimPajama-627B) (excluding the Books3 subset)
105
+
106
+ ## Use and Limitations
107
+
108
+ ### Intended Use
109
+
110
+ The model is intended to be used by all individuals as a foundation for application-specific fine-tuning without strict limitations on commercial use.
111
+
112
+ ### Limitations and bias
113
+
114
+ The pre-training dataset may have contained offensive or inappropriate content even after applying data cleansing filters which can be reflected in the model generated text. We recommend users exercise reasonable caution when using these models in production systems. Do not use the model for any applications that may cause harm or distress to individuals or groups.
115
+
116
+ ## Authors
117
+ This model was developed by the Research & Development team at Stability AI Japan, and the development was co-led by [Takuya Akiba](https://huggingface.co/iwiwi) and [Meng Lee](https://huggingface.co/leemeng). The members of the team are as follows:
118
+
119
+ - [Meng Lee](https://huggingface.co/leemeng)
120
+ - [Fujiki Nakamura](https://huggingface.co/fujiki)
121
+ - [Makoto Shing](https://huggingface.co/mkshing)
122
+ - [Paul McCann](https://huggingface.co/polm-stability)
123
+ - [Takuya Akiba](https://huggingface.co/iwiwi)
124
+ - [Naoki Orii](https://huggingface.co/mrorii)
125
+
126
+ ## Acknowledgements
127
+
128
+ We thank Meta Research for releasing Llama 2 under an open license for others to build on.
129
+
130
+ We are grateful for the contributions of the EleutherAI Polyglot-JA team in helping us to collect a large amount of pre-training data in Japanese. Polyglot-JA members includes Hyunwoong Ko (Project Lead), Fujiki Nakamura (originally started this project when he commited to the Polyglot team), Yunho Mo, Minji Jung, KeunSeok Im, and Su-Kyeong Jang.
131
+
132
+ We are also appreciative of [AI Novelist/Sta (Bit192, Inc.)](https://ai-novel.com/index.php) and the numerous contributors from [Stable Community Japan](https://discord.gg/VPrcE475HB) for assisting us in gathering a large amount of high-quality Japanese textual data for model training.
133
+
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "eos_token_id": 2,
7
+ "hidden_act": "silu",
8
+ "hidden_size": 4096,
9
+ "initializer_range": 0.02,
10
+ "intermediate_size": 11008,
11
+ "max_position_embeddings": 4096,
12
+ "model_type": "llama",
13
+ "num_attention_heads": 32,
14
+ "num_hidden_layers": 32,
15
+ "num_key_value_heads": 32,
16
+ "pad_token_id": 0,
17
+ "pretraining_tp": 1,
18
+ "rms_norm_eps": 1e-05,
19
+ "rope_scaling": null,
20
+ "tie_word_embeddings": false,
21
+ "torch_dtype": "float16",
22
+ "transformers_version": "4.31.0",
23
+ "use_cache": true,
24
+ "vocab_size": 49408
25
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.31.0"
7
+ }
japanese-stablelm-robot.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ sentencepiece
2
+ protobuf
3
+ accelerate