torotoki commited on
Commit
7fc0fb2
1 Parent(s): b2fe1a3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -55
README.md CHANGED
@@ -7,96 +7,118 @@ library_name: transformers
7
  pipeline_tag: text-generation
8
  ---
9
 
10
- # PLaMo-13B
11
 
12
  ## Model Description
13
- PLaMo-13B is a LLaMA-based 13B model pre-trained on English and Japanese open datasets, developed by Preferred Networks, Inc.
14
- PLaMo-13B is released under Apache v2.0 license.
15
 
16
- [PLaMo-13B Release blog (Japanese)](https://tech.preferred.jp/ja/blog/llm-plamo/)
17
 
18
- ## Usage
19
 
20
- ### Requirements
 
 
 
21
 
22
- - numpy
23
- - safetensors
24
- - sentencepiece
25
- - torch
26
- - transformers
27
 
28
- ### Use a pipeline as a high-level helper
29
  ```python
30
- import transformers
31
- pipeline = transformers.pipeline("text-generation", model="pfnet/plamo-13b", trust_remote_code=True)
32
- print(pipeline("The future of artificial intelligence technology is ", max_new_tokens=32))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  ```
34
 
35
- ### Load model directly
36
  ```python
37
- from transformers import AutoTokenizer, AutoModelForCausalLM
38
- tokenizer = AutoTokenizer.from_pretrained("pfnet/plamo-13b", trust_remote_code=True)
39
- model = AutoModelForCausalLM.from_pretrained("pfnet/plamo-13b", trust_remote_code=True)
40
- text = "これからの人工知能技術は"
41
- input_ids = tokenizer(text, return_tensors="pt").input_ids
42
- generated_tokens = model.generate(
43
- inputs=input_ids,
44
- max_new_tokens=32,
45
- do_sample=True,
46
- top_k=50,
47
- top_p=0.95,
48
- temperature=1.0,
49
- )[0]
50
- generated_text = tokenizer.decode(generated_tokens)
51
- print(generated_text)
52
  ```
53
 
54
  ## Model Details
55
 
56
  - Model size: 13B
57
  - Trained tokens: 1.5T tokens (English: 1.32T tokens, Japanese: 0.18T tokens)
58
- - Context length: 4096
59
- - Developed by: Preferred Networkfs, Inc
 
60
  - Model type: Causal decoder-only
61
- - Language(s): English, Japanese
62
- - License: Apache v2.0
63
 
64
  ## Training Dataset
65
 
66
- ### English
67
-
68
- - C4 - English
69
- - Project Gutenberg
70
- - RedPajama - Arxiv
71
- - RedPajama - CommonCrawl - English
72
- - RedPajama - Github
73
- - RedPajama - StackExchange
74
- - RedPajama - Wikipedia
75
 
76
- ### Japanese
77
 
78
- - mC4 - Japanese
79
- - Wikipedia - Japanese
80
-
81
- ## Tokenizer
82
- PLaMo-13B uses sentencepiece tokenizer which is trained on a subset of the datasets for model pre-training.
83
 
84
  ## Bias, Risks, and Limitations
85
- PLaMo-13B is a new technology that carries risks with use. Testing conducted to date has been in English and Japanese, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, PLaMo-13B’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate, biased or other objectionable responses to user prompts. Therefore, before deploying any applications of PLaMo-13B, developers should perform safety testing and tuning tailored to their specific applications of the model.
86
 
87
  ## How to cite
88
  ```tex
89
- @online{PLaMo2023Introducing,
90
  author = {Preferred Networks, Inc},
91
- title = {PLaMo-13B},
92
  year = {2023},
93
- url = {https://huggingface.co/pfnet/plamo-13b},
94
- urldate = {2023-09-28}
95
  }
96
  ```
97
 
98
  ## References
99
  ```tex
 
 
 
 
 
 
 
 
 
 
100
  @article{touvron2023llama,
101
  title={LLaMA: Open and Efficient Foundation Language Models},
102
  author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and Rodriguez, Aurelien and Joulin, Armand and Grave, Edouard and Lample, Guillaume},
 
7
  pipeline_tag: text-generation
8
  ---
9
 
10
+ # PLaMo-13B-Instruct-NC
11
 
12
  ## Model Description
13
+ PLaMo-13B-Instruct-NC is a noncommercial instruct fine-tuned model built upon the 8192 context length version of [Plamo-13B](https://huggingface.co/pfnet/plamo-13b) text generation model. PLaMo-13B-Instruct-NC is fine-tuned using multiple publicly available Japanese datasets.
14
+ This model is released under the Apache License 2.0.
15
 
16
+ [PLaMo-13B-Instruct Release blog (Japanese)](https://tech.preferred.jp/ja/blog/llm-plamo/)
17
 
 
18
 
19
+ ## Usage
20
+ Install the required libraries as follows:
21
+ ```sh
22
+ >>> python -m pip install numpy safetensors sentencepiece torch transformers
23
 
24
+ ```
 
 
 
 
25
 
26
+ Execute the following python code:
27
  ```python
28
+ tokenizer = AutoTokenizer.from_pretrained(
29
+ "pfnet/plamo-13b-instruct-nc",
30
+ trust_remote_code=True,
31
+ )
32
+ model = AutoModelForCausalLM.from_pretrained(
33
+ "pfnet/plamo-13b-instruct-nc",
34
+ trust_remote_code=True,
35
+ torch_dtype=torch.bfloat16,
36
+ device_map="auto",
37
+ )
38
+
39
+ def completion(prompt: str, max_new_tokens: int = 128) -> str:
40
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
41
+ generated_ids = model.generate(
42
+ inputs.input_ids,
43
+ eos_token_id=2,
44
+ pad_token_id=3,
45
+ max_new_tokens=max_new_tokens,
46
+ temperature=1,
47
+ top_p=0.95,
48
+ top_k=50,
49
+ do_sample=True,
50
+ )
51
+ return tokenizer.decode(generated_ids[0], skip_special_tokens=True, clean_up_tokenization_spaces=True)
52
+
53
+ def generate_prompt(messages: list) -> str:
54
+ sep = "\n\n### "
55
+ prompt = [
56
+ "以下はタスクを説明する指示で、文脈を説明した入力とペアになっています。",
57
+ "要求を適切に補完するよう応答を書いてください。",
58
+ ]
59
+ roles = {"instruction": "指示", "response": "応答", "input": "入力"}
60
+ for msg in messages:
61
+ prompt.append(sep + roles[msg["role"]] + ":\n" + msg['content'])
62
+ prompt.append(sep + roles["response"] + ":\n")
63
+ return "".join(prompt)
64
  ```
65
 
 
66
  ```python
67
+ prompt = generate_prompt([
68
+ {"role": "instruction", "content": "日本の首都はどこですか?"},
69
+ # {"role": "input", "content": "..."} ## An extra input (optional)
70
+ ])
71
+ print(completion(prompt, max_new_tokens=128))
 
 
 
 
 
 
 
 
 
 
72
  ```
73
 
74
  ## Model Details
75
 
76
  - Model size: 13B
77
  - Trained tokens: 1.5T tokens (English: 1.32T tokens, Japanese: 0.18T tokens)
78
+ - Tokenizer: sentencepiece tokenizer trained on a subset of the pretraining datasets.
79
+ - Context length: 8192
80
+ - Developed by: Preferred Networks, Inc
81
  - Model type: Causal decoder-only
82
+ - Language(s): Japanese and English
83
+ - License: Apache License 2.0
84
 
85
  ## Training Dataset
86
 
87
+ - [Stanford Alpaca (Japanese translation)](https://huggingface.co/datasets/fujiki/japanese_alpaca_data)
88
+ - [databricks-dolly-15k (Japanese translation)](https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja)
89
+ - [Anthropic HH-RLHF (Japanese translation, subset)](https://huggingface.co/datasets/fujiki/japanese_hh-rlhf-49k)
90
+ - [OpenAssistant Conversations Dataset (Japanese translation, oasst1)](https://huggingface.co/datasets/kunishou/oasst1-89k-ja)
91
+ - [Wikinews subset of Izumi-lab llm-japanese-dataset](https://huggingface.co/datasets/izumi-lab/llm-japanese-dataset)
 
 
 
 
92
 
93
+ For the pretraining model, see [Plamo-13B](https://huggingface.co/pfnet/plamo-13b).
94
 
 
 
 
 
 
95
 
96
  ## Bias, Risks, and Limitations
97
+ PLaMo-13B-Instruct-NC is a new technology that carries risks with use. Testing conducted to date has been in English and Japanese, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, PLaMo-13B’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate, biased or other objectionable responses to user prompts. Therefore, before deploying any applications of PLaMo-13B-Instruct-NC, developers should perform safety testing and tuning tailored to their specific applications of the model.
98
 
99
  ## How to cite
100
  ```tex
101
+ @online{PLaMoInstruct2023Introducing,
102
  author = {Preferred Networks, Inc},
103
+ title = {PLaMo-13B-Instruct-NC},
104
  year = {2023},
105
+ url = {https://huggingface.co/pfnet/plamo-13b-instruct-nc},
106
+ urldate = {2023-10-26}
107
  }
108
  ```
109
 
110
  ## References
111
  ```tex
112
+ @misc{alpaca,
113
+ author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
114
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
115
+ year = {2023},
116
+ publisher = {GitHub},
117
+ journal = {GitHub repository},
118
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
119
+ }
120
+ ```
121
+ ```tex
122
  @article{touvron2023llama,
123
  title={LLaMA: Open and Efficient Foundation Language Models},
124
  author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and Rodriguez, Aurelien and Joulin, Armand and Grave, Edouard and Lample, Guillaume},