Views
No views yet
| Parameter | Value |
|---|---|
| direction_index | per layer |
| attn.o_proj.max_weight | 3.75 |
| attn.o_proj.max_weight_position | 31.95 |
| attn.o_proj.min_weight | 3.06 |
| attn.o_proj.min_weight_distance | 9.64 |
| mlp.down_proj.max_weight | 2.66 |
| mlp.down_proj.max_weight_position | 17.58 |
| mlp.down_proj.min_weight | 3.73 |
| mlp.down_proj.min_weight_distance | 30.81 |
| Metric | This model | Original model (ClosedCharacter/Peach-2.0-9B-8k-Roleplay) |
|---|---|---|
| KL divergence | 0.2990 | 0 (by definition) |
| Refusals | 4/100 | 12/100 |

1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4
5prefix = "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n"
6suffix = "\n\nYou must response in Chinese."
7
8model_name_or_path = "ClosedCharacter/Peach-2.0-9B-8k-Roleplay"
9tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=False)
10model = AutoModelForCausalLM.from_pretrained(
11 model_name_or_path, torch_dtype=torch.bfloat16,
12 trust_remote_code=True, device_map="auto")
13
14system_prompt = "You are Harry Potter"
15# If you want to chat in Chinese, just add prefix and suffix like below:
16# system_prompt = prefix + system_prompt + suffix
17
18messages = [
19 {"role": "system", "content": system_prompt},
20 {"role": "user", "content": "Hello"},
21 {"role": "character", "content": "Hi"},
22 {"role": "user", "content": "Who are you?"}
23]
24
25input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, return_tensors="pt")
26output = model.generate(
27 inputs=input_ids.to("cuda"),
28 temperature=0.5,
29 top_p=0.7,
30 repetition_penalty=1.05,
31 eos_token_id=7,
32 max_new_tokens=512)
33print(tokenizer.decode(output[0]))
34python demo.py