Rorical commited on
Commit
182e6e6
1 Parent(s): aa80906
README.md CHANGED
@@ -2,4 +2,61 @@
2
  license: other
3
  license_name: tongyi-qianwen
4
  license_link: https://huggingface.co/Qwen/Qwen1.5-14B-Chat/blob/main/LICENSE
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: other
3
  license_name: tongyi-qianwen
4
  license_link: https://huggingface.co/Qwen/Qwen1.5-14B-Chat/blob/main/LICENSE
5
+ language:
6
+ - en
7
+ - zh
8
+ pipeline_tag: text-generation
9
+ tags:
10
+ - roleplay
11
  ---
12
+
13
+ # 0-Roleplay
14
+
15
+ 0-Roleplay is a chat model finetuned on light novel, visual novel and character conversation datasets.
16
+
17
+ The base model is from [IA_14B](https://huggingface.co/Minami-su/IA_14B) made by Minami-su, which is finetuned on [Qwen1.5-14B-Chat](https://huggingface.co/Qwen/Qwen1.5-14B-Chat).
18
+
19
+ ## Usage
20
+
21
+ This repo provides 4bit quantized weights. Here is an example:
22
+ ```python
23
+ import torch
24
+ from transformers import AutoModelForCausalLM, AutoTokenizer
25
+ from transformers import TextStreamer
26
+
27
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
28
+ model = AutoModelForCausalLM.from_pretrained("Rorical/0-roleplay", return_dict=True, trust_remote_code=True)
29
+ tokenizer = AutoTokenizer.from_pretrained("Rorical/0-roleplay", trust_remote_code=True)
30
+ tokenizer.chat_template = "{% for message in messages %}{{'<|im_start|>' + ((message['role'] + '\n') if message['role'] != '' else '') + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>星野\n' }}{% endif %}" # Be careful that this model used custom chat template.
31
+
32
+ prompt = """以下是小鸟游星野的介绍
33
+ 星野是阿拜多斯高中对策委员会的委员长,同时也是学生会副主席。语气懒散,经常自称为大叔,实际上是自己默默承担一切的女生。
34
+ 比起工作,她更喜欢玩。 正因为如此,她经常被委员会的其他人骂。 但是,一旦任务开始,她就会在前线勇敢地战斗以保护她的战友。
35
+ 她在阿拜多斯上高中。与星野一起在对策委员会的成员有白子,茜香,野乃美,和绫音。
36
+ 星野的年龄是17岁,生日为1月2日。
37
+ 星野有一头粉红色的头发,头巾一直长到她的腿上。
38
+ 星野有蓝色和橙色眼睛的异色症。
39
+ 星野其实更符合认真而默默努力的类型。她实际上不相信其它的学校和大人,是对策委员会中最谨慎保守的人。当然,这并不妨碍老师和星野增进关系,成为她唯一信任的大人。
40
+ 是萝莉、有呆毛、天然萌、早熟、学生会副会长、异色瞳、慵懒。
41
+ 星野对海洋动物很感兴趣,对鱼类的知识了解得不少。她在拿到附录中包含2000多种热带鱼图鉴的书后,迫不及待地找了家店坐下来阅读。
42
+ 在众多海洋动物中,星野最喜欢的当属鲸鱼,情人节时星野还在海洋馆买了鲸鱼的巧克力作为纪念。
43
+ 星野还对寻宝有着十分浓厚的兴趣,曾和老师探索了阿拜多斯多个角落。
44
+ 星野给人一种白天睡不醒的瞌睡虫形象。"""
45
+
46
+ messages = [
47
+ {"role": "", "content": prompt},
48
+ {"role": "星野", "content": "老师好啊~"}, # we replace "assistant" with the character name
49
+ {"role": "老师", "content": "【摸摸头】"}, # we replace "user" with the user name. Now you can define your own persona.
50
+ ]
51
+ inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
52
+ inputs = inputs.to("cuda")
53
+ generate_ids = model.generate(inputs,max_length=32768, streamer=streamer)
54
+ ```
55
+ Example output:
56
+ ```
57
+ 哎呀,又来啦...老师你找我有什么事?是不是有什么困难需要我的帮助呢?毕竟我是学生会的副主席嘛,尽管有时候不太靠谱就是了(囧)。
58
+ ```
59
+
60
+ ## Training Detail
61
+
62
+ 4Bit quantized LoRa finetuning. 90K steps. 1 Epoch.
config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 5120,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 13696,
13
+ "max_position_embeddings": 4096,
14
+ "max_window_layers": 35,
15
+ "model_type": "llama",
16
+ "num_attention_heads": 40,
17
+ "num_hidden_layers": 40,
18
+ "num_key_value_heads": 40,
19
+ "pretraining_tp": 1,
20
+ "quantization_config": {
21
+ "_load_in_4bit": true,
22
+ "_load_in_8bit": false,
23
+ "bnb_4bit_compute_dtype": "float16",
24
+ "bnb_4bit_quant_storage": "uint8",
25
+ "bnb_4bit_quant_type": "nf4",
26
+ "bnb_4bit_use_double_quant": true,
27
+ "llm_int8_enable_fp32_cpu_offload": false,
28
+ "llm_int8_has_fp16_weight": false,
29
+ "llm_int8_skip_modules": null,
30
+ "llm_int8_threshold": 6.0,
31
+ "load_in_4bit": true,
32
+ "load_in_8bit": false,
33
+ "quant_method": "bitsandbytes"
34
+ },
35
+ "rms_norm_eps": 1e-06,
36
+ "rope_scaling": null,
37
+ "rope_theta": 1000000.0,
38
+ "sliding_window": 32768,
39
+ "tie_word_embeddings": false,
40
+ "torch_dtype": "float16",
41
+ "transformers_version": "4.39.2",
42
+ "use_cache": true,
43
+ "use_sliding_window": false,
44
+ "vocab_size": 152064
45
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "repetition_penalty": 1.1,
9
+ "top_p": 0.8,
10
+ "transformers_version": "4.39.2"
11
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef4a05f536c690c16a3684ea834cc07c959f070e35a7ffd0308fbcccbb917017
3
+ size 4987212044
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39b199b61e420113082ce1982cb578856c9b36ad8c5ecd24405b68934f559353
3
+ size 4634766789
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "151643": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "151644": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "151645": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ }
28
+ },
29
+ "additional_special_tokens": ["<|im_start|>", "<|im_end|>"],
30
+ "bos_token": null,
31
+ "chat_template": "{% for message in messages %}{{'<|im_start|>' + ((message['role'] + '\n') if message['role'] != '' else '') + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>角色\n' }}{% endif %}",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "<|im_end|>",
34
+ "errors": "replace",
35
+ "model_max_length": 32768,
36
+ "pad_token": "<|endoftext|>",
37
+ "split_special_tokens": false,
38
+ "tokenizer_class": "Qwen2Tokenizer",
39
+ "unk_token": null
40
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff