Add README etc.
Browse files- README.md +137 -1
- config.json +25 -0
- generation_config.json +7 -0
- japanese-stablelm-robot.jpg +0 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,3 +1,139 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-Beta-70B
|
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-beta-70b` is a 70B-parameter decoder-only language model based on [Llama-2-70b](https://huggingface.co/meta-llama/Llama-2-70b) 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 |
+
For an instruction-following model, check [Japanese-StableLM-Instruct-Beta-70B](https://huggingface.co/stabilityai/japanese-stablelm-instruct-beta-70b). The base and instruct models are also available in smaller 7b sizes. For a model that has faster inference times, see [Japanese-StableLM-Base-JA_Vocab-Beta-7B](https://huggingface.co/stabilityai/japanese-stablelm-base-ja_vocab-beta-7b), or [the instruction-following version](https://huggingface.co/stabilityai/japanese-stablelm-instruct-ja_vocab-beta-7b).
|
36 |
+
|
37 |
+
## Usage
|
38 |
+
|
39 |
+
First install additional dependencies in [requirements.txt](./requirements.txt):
|
40 |
+
|
41 |
+
```sh
|
42 |
+
pip install -r requirements.txt
|
43 |
+
```
|
44 |
+
|
45 |
+
Then start generating text with `japanese-stablelm-base-beta-70b` by using the following code snippet:
|
46 |
+
|
47 |
+
```python
|
48 |
+
import torch
|
49 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
50 |
+
|
51 |
+
model_name = "stabilityai/japanese-stablelm-base-beta-70b"
|
52 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
53 |
+
|
54 |
+
# The next line may need to be modified depending on the environment
|
55 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, low_cpu_mem_usage=True, device_map="auto")
|
56 |
+
|
57 |
+
prompt = """
|
58 |
+
AI で科学研究を加速するには、
|
59 |
+
""".strip()
|
60 |
+
|
61 |
+
input_ids = tokenizer.encode(
|
62 |
+
prompt,
|
63 |
+
add_special_tokens=False,
|
64 |
+
return_tensors="pt"
|
65 |
+
)
|
66 |
+
|
67 |
+
# this is for reproducibility.
|
68 |
+
# feel free to change to get different result
|
69 |
+
seed = 23
|
70 |
+
torch.manual_seed(seed)
|
71 |
+
|
72 |
+
tokens = model.generate(
|
73 |
+
input_ids.to(device=model.device),
|
74 |
+
max_new_tokens=128,
|
75 |
+
temperature=0.99,
|
76 |
+
top_p=0.95,
|
77 |
+
do_sample=True,
|
78 |
+
)
|
79 |
+
|
80 |
+
out = tokenizer.decode(tokens[0], skip_special_tokens=True)
|
81 |
+
print(out)
|
82 |
+
```
|
83 |
+
|
84 |
+
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.
|
85 |
+
|
86 |
+
## Model Details
|
87 |
+
|
88 |
+
* **Model type**: `japanese-stablelm-base-beta-70b` model is an auto-regressive language model based on the Llama2 transformer architecture.
|
89 |
+
* **Language(s)**: Japanese
|
90 |
+
* **License**: [Llama2 Community License](https://ai.meta.com/llama/license/).
|
91 |
+
* **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.
|
92 |
+
|
93 |
+
## Training Dataset
|
94 |
+
|
95 |
+
Roughly 100B tokens from a mixture of the following corpora were used for continued pre-training.
|
96 |
+
|
97 |
+
- [Japanese/English Wikipedia](https://dumps.wikimedia.org/other/cirrussearch)
|
98 |
+
- [Japanese mc4](https://huggingface.co/datasets/mc4)
|
99 |
+
- [Japanese CC-100](http://data.statmt.org/cc-100/ja.txt.xz)
|
100 |
+
- [Japanese OSCAR](https://oscar-project.github.io/documentation/)
|
101 |
+
- [SlimPajama](https://huggingface.co/datasets/cerebras/SlimPajama-627B) (excluding the Books3 subset)
|
102 |
+
|
103 |
+
## Use and Limitations
|
104 |
+
|
105 |
+
### Intended Use
|
106 |
+
|
107 |
+
The model is intended to be used by all individuals as a foundation for application-specific fine-tuning without strict limitations on commercial use.
|
108 |
+
|
109 |
+
### Limitations and bias
|
110 |
+
|
111 |
+
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.
|
112 |
+
|
113 |
+
## Authors
|
114 |
+
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:
|
115 |
+
|
116 |
+
- [Meng Lee](https://huggingface.co/leemeng)
|
117 |
+
- [Fujiki Nakamura](https://huggingface.co/fujiki)
|
118 |
+
- [Makoto Shing](https://huggingface.co/mkshing)
|
119 |
+
- [Paul McCann](https://huggingface.co/polm-stability)
|
120 |
+
- [Takuya Akiba](https://huggingface.co/iwiwi)
|
121 |
+
- [Naoki Orii](https://huggingface.co/mrorii)
|
122 |
+
|
123 |
+
## Acknowledgements
|
124 |
+
|
125 |
+
We thank Meta Research for releasing Llama 2 under an open license for others to build on.
|
126 |
+
|
127 |
+
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.
|
128 |
+
|
129 |
+
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.
|
130 |
+
|
131 |
+
## How to cite
|
132 |
+
```
|
133 |
+
@misc{JapaneseStableLMBaseBeta70B,
|
134 |
+
url={[https://huggingface.co/stabilityai/japanese-stablelm-base-beta-70b](https://huggingface.co/stabilityai/japanese-stablelm-base-beta-70b)},
|
135 |
+
title={Japanese StableLM Base Beta 70B},
|
136 |
+
author={Lee, Meng and Nakamura, Fujiki and Shing, Makoto and McCann, Paul and Akiba, Takuya and Orii, Naoki}
|
137 |
+
}
|
138 |
+
```
|
139 |
+
|
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": 8192,
|
9 |
+
"initializer_range": 0.02,
|
10 |
+
"intermediate_size": 28672,
|
11 |
+
"max_position_embeddings": 4096,
|
12 |
+
"model_type": "llama",
|
13 |
+
"num_attention_heads": 64,
|
14 |
+
"num_hidden_layers": 80,
|
15 |
+
"num_key_value_heads": 8,
|
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": 32000
|
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
|