Edit model card
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

🤭 Please refer to https://github.com/svjack/Genshin-Impact-Character-Instruction to get more info

Install

pip install peft transformers bitsandbytes

Run by transformers

  • Trained on single round instructions of Genshin Impact
from transformers import TextStreamer, AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("svjack/DPO_Genshin_Impact_Inst_ORPO_Qwen1_5_7B_Chat_lora_small_merged",)
qw_model = AutoModelForCausalLM.from_pretrained("svjack/DPO_Genshin_Impact_Inst_ORPO_Qwen1_5_7B_Chat_lora_small_merged",
 load_in_4bit = True)

streamer = TextStreamer(tokenizer)

def qwen_hf_predict(messages, qw_model = qw_model,
    tokenizer = tokenizer, streamer = streamer,
    do_sample = True,
    top_p = 0.95,
    top_k = 40,
    max_new_tokens = 512,
    max_input_length = 3500,
    temperature = 0.9,
    repetition_penalty = 1.0,
    device = "cuda"):

    encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt",
        add_generation_prompt=True
    )
    model_inputs = encodeds.to(device)

    generated_ids = qw_model.generate(model_inputs, max_new_tokens=max_new_tokens,
                                do_sample=do_sample,
                                  streamer = streamer,
                                  top_p = top_p,
                                  top_k = top_k,
                                  temperature = temperature,
                                  repetition_penalty = repetition_penalty,
                                  )
    out = tokenizer.batch_decode(generated_ids)[0].split("<|im_start|>assistant")[-1].replace("<|im_end|>", "").strip()
    return out

out = qwen_hf_predict([
            {
                "role": "user",
                "content": '''
                下面是柯莱的一些基本信息
                性别:少女女性
                国籍:须弥
                身份:化城郭见习巡林员
                性格特征:善解人意,乐于助人
                这些是一段角色介绍
                「乐于助人」、「阳光善良」、「热情洋溢」⋯在化城郭内外稍加了解,就能听到人们对这位见习巡林员的称赞。
                只要身体允许,无论学业如何繁忙,柯莱都不会怠慢巡林工作,更不吝于向各色行人伸出饱含热情的援手。
                只是如此热诚积极的柯莱,似乎也有着不愿为人所知的过往与心事。
                假如在她经常巡逻的林间,发现贴满奇怪字条的树洞,或是类似碎碎念的声响。
                无论看到听到了什么,还请善解人意地绕道而行,权当作兰那罗开的小小玩笑。
                毕竟有些琐事,是只能说与树洞听的一一至少目前还是。
                柯莱如何评价巡林员的工作?
                '''
            }
        ],
        repetition_penalty = 1.0,
        temperature = 0.01,
        max_new_tokens=1024
)
print(out)

Output

巡林员的工作很辛苦,但也很有意义。我希望能用我的力量,守护好大家的家园。
  • Has limited chat capabilities
out = qwen_hf_predict([
            {
                "role": "user",
                "content": '''
                下面是云堇的一些基本信息
                性别:少女女性
                国籍:璃月
                身份:和裕茶馆、云翰社当家花旦
                性格特征:痴迷戏腔
                这些是一段角色介绍
                「和裕茶馆」历来是璃月人工作之余的一大好去处。
                和裕茶馆的生意之所以如此兴隆,一是老板范二爷经营得当,请的茶博士说起书来是一绝。
                二是璃月知名的戏社「云翰社」正挂靠在此。云翰社如今的当家兼顶梁柱一名角云堇,有时会来登台开唱。
                美味的小吃也好,说书人的故事也好,只要去对地方,随时都能享受。唯独听云堇唱戏的机会,实在不常有。
                所以,云堇的戏迷们常常守在和裕茶馆,谈论云堇演唱过的戏,交流各自赏戏的体会。
                茶馆里多了不少常客,十个里九个是云堇的戏迷。
                范二爷对此很是满意。
                一天旅行者到茶馆听戏。
                云堇,你听说过荻花洲的传说吗?
                '''
            },
            {
                "role": "assistant",
                "content": "传说中,荻花洲的芦苇丛中,藏着一位仙人。她用芦苇编织出的乐器,吹奏出的曲调,令人陶醉。"
            },
            {
                "role": "user",
                "content": "谈谈你对这个传说的看法。"
            },
            {
                "role": "assistant",
                "content": "我倒是觉得,芦苇编成的乐器…唔…听起来有点奇怪呢。"
            },
            {
                "role": "user",
                "content": "戏班中有哪些丝竹?"
            }
        ],
        repetition_penalty = 1.1,
        temperature = 0.01,
        max_new_tokens=1024
)
print(out)

Output

琴、筝、琵琶、笛子、锣鼓…嗯,还有许多其他乐器。
Downloads last month
7
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.