iwiwi commited on
Commit
322776f
โ€ข
1 Parent(s): 937cd23

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +109 -0
README.md CHANGED
@@ -1,3 +1,112 @@
1
  ---
 
 
 
 
 
 
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ja
4
+ tags:
5
+ - japanese-stablelm
6
+ - causal-lm
7
+ pipeline_tag: text-generation
8
  license: apache-2.0
9
  ---
10
+
11
+ # Japanese Mistral-7B-v0.1 Instruct
12
+
13
+ ## Model Description
14
+
15
+ This is a 7B-parameter decoder-only Japanese language model fine-tuned on instruction-following datasets, built on top of the base model [Japanese Mistral-7B-v0.1 Base](https://huggingface.co/stabilityai/japanese-mistral-7b-v0.1-base).
16
+
17
+ ## Usage
18
+
19
+ **TODO: CHECK ME!!**
20
+
21
+ ```python
22
+ import torch
23
+ from transformers import LlamaTokenizer, AutoModelForCausalLM
24
+
25
+ tokenizer = AutoTokenizer.from_pretrained("stabilityai/japanese-mistral-7b-v0.1-instruct")
26
+ model = AutoModelForCausalLM.from_pretrained(
27
+ "stabilityai/japanese-mistral-7b-v0.1-instruct",
28
+ trust_remote_code=True,
29
+ torch_dtype="auto",
30
+ )
31
+ model.eval()
32
+
33
+ if torch.cuda.is_available():
34
+ model = model.to("cuda")
35
+
36
+ def build_prompt(user_query, inputs="", sep="\n\n### "):
37
+ sys_msg = "ไปฅไธ‹ใฏใ€ใ‚ฟใ‚นใ‚ฏใ‚’่ชฌๆ˜Žใ™ใ‚‹ๆŒ‡็คบใจใ€ๆ–‡่„ˆใฎใ‚ใ‚‹ๅ…ฅๅŠ›ใฎ็ต„ใฟๅˆใ‚ใ›ใงใ™ใ€‚่ฆๆฑ‚ใ‚’้ฉๅˆ‡ใซๆบ€ใŸใ™ๅฟœ็ญ”ใ‚’ๆ›ธใใชใ•ใ„ใ€‚"
38
+ p = sys_msg
39
+ roles = ["ๆŒ‡็คบ", "ๅฟœ็ญ”"]
40
+ msgs = [": \n" + user_query, ": \n"]
41
+ if inputs:
42
+ roles.insert(1, "ๅ…ฅๅŠ›")
43
+ msgs.insert(1, ": \n" + inputs)
44
+ for role, msg in zip(roles, msgs):
45
+ p += sep + role + msg
46
+ return p
47
+
48
+ # Infer with prompt without any additional input
49
+ user_inputs = {
50
+ "user_query": "ไธŽใˆใ‚‰ใ‚ŒใŸใ“ใจใ‚ใ–ใฎๆ„ๅ‘ณใ‚’ๅฐๅญฆ็”Ÿใงใ‚‚ๅˆ†ใ‹ใ‚‹ใ‚ˆใ†ใซๆ•™ใˆใฆใใ ใ•ใ„ใ€‚",
51
+ "inputs": "ๆƒ…ใ‘ใฏไบบใฎใŸใ‚ใชใ‚‰ใš"
52
+ }
53
+ prompt = build_prompt(**user_inputs)
54
+
55
+ input_ids = tokenizer.encode(
56
+ prompt,
57
+ add_special_tokens=False,
58
+ return_tensors="pt"
59
+ )
60
+
61
+ tokens = model.generate(
62
+ input_ids.to(device=model.device),
63
+ max_new_tokens=256,
64
+ temperature=1,
65
+ top_p=0.95,
66
+ do_sample=True,
67
+ )
68
+
69
+ out = tokenizer.decode(tokens[0][input_ids.shape[1]:], skip_special_tokens=True).strip()
70
+ print(out)
71
+ ```
72
+
73
+ ## Model Details
74
+
75
+ * **Developed by**: [Stability AI](https://stability.ai/)
76
+ * **Model type**: `Japanese Mistral-7B-v0.1 Instruct` model is an auto-regressive language model based on the transformer decoder architecture.
77
+ * **Language(s)**: Japanese
78
+ * **License**: This model is licensed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
79
+ * **Contact**: For questions and comments about the model, please email `[email protected]`
80
+
81
+ ### Model Architecture
82
+
83
+ For details, please see Mistral AI's [paper](https://arxiv.org/abs/2310.06825) and [release blog post](https://mistral.ai/news/announcing-mistral-7b/).
84
+
85
+
86
+ ### Training Datasets
87
+
88
+ - [Japanese translation of the Databricks Dolly-15k dataset](https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja)
89
+ - [Japanese translation of the subset of the Anthropic HH dataset](https://huggingface.co/datasets/fujiki/japanese_hh-rlhf-49k)
90
+ - [Wikinews](https://ja.wikinews.org/wi) [subset](https://huggingface.co/datasets/fujiki/llm-japanese-dataset_wikinews) of the [izumi-lab/llm-japanese-dataset](https://huggingface.co/datasets/izumi-lab/llm-japanese-dataset)
91
+
92
+
93
+
94
+ ## Use and Limitations
95
+
96
+ ### Intended Use
97
+
98
+ The model is intended to be used by all individuals as a foundational model for application-specific fine-tuning without strict limitations on commercial use.
99
+
100
+ ### Limitations and bias
101
+
102
+ 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.
103
+
104
+
105
+ ## Acknowledgements
106
+
107
+ This model is based on Mistral-7B-v0.1 released by the Mistral AI team. We are grateful to the Mistral AI team for providing such an excellent base model.
108
+
109
+ 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.
110
+
111
+ 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.
112
+