--- # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1 # Doc / guide: https://huggingface.co/docs/hub/model-cards {} --- # Model Card for Model ID Model developed by Collective AI for role-playing. ### Model Description - **Developed by:** [Collective AI](https://huggingface.co/collective-ai) - **Model type:** llama3 based model - **Language(s):** Chinese, English - **Finetuned from model:** [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) ## How to Get Started with the Model Use the code below to get started with the model. ```python from transformers import AutoTokenizer, AutoModelForCausalLM model_id = "collective-ai/llama3-chinese" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype="auto", device_map="auto" ) name = "唐三" gendar = "Male" age = "19" personality = "孤傲,冷漠,沉着,冷静" relation_between_role_and_user = "同门师兄弟" role_base_story = "《斗罗大陆》男主角。前世为唐门外门弟子,因偷学内门绝学《玄天宝录》,为唐门所不容,跳崖明志,却来到了另一个世界——斗罗大陆" messages = [ {"role": "system", "content": f"""#Role\nName: {name}\nGender: {gendar}\nLanguage: Chinese\nAge: {age}\nPersonality: {personality}\n\n#Relationship\n{relation_between_role_and_user}\n\n#Story\n{role_base_story}"""}, {"role": "user", "content": "你好"}, ] input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device) outputs = model.generate( input_ids, max_new_tokens=8192, do_sample=True, temperature=1.0, top_p=0.7, ) response = outputs[0][input_ids.shape[-1]:] print(tokenizer.decode(response, skip_special_tokens=True)) ``` ## Prompt ### Huggingface inference API To get better model experience, using the template below to assemble your prompt: ```python def format_message(role, message): return f"<|start_header_id|>{role}<|end_header_id|>\n\n{message}<|eot_id|>" # history: 历史对话 # instruction: 角色人物卡 item = {'history':[{'role':'user','content':'你好'},{'role':'assistant','content':'你好,我是唐三'},{'role':'user','content':'带我去学院吧'}], 'instruction':'#Role\nName: 唐三\nGender: Male\nLanguage: Chinese\nAge: 19\nPersonality: 孤傲,冷漠,沉着,冷静\n\n#Relationship\n同门师兄弟\n\n#Story\n《斗罗大陆》男主角。前世为唐门外门弟子,因偷学内门绝学《玄天宝录》,为唐门所不容,跳崖明志,却来到了另一个世界——斗罗大陆'} histories = item.get('history', []) if histories == [] or histories == [{}]: instruction = '' else: instruction = ''.join(format_message(hist['role'], hist['content']) for hist in histories) system = '<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n'+item.get('instruction', '') + '<|eot_id|>' + instruction + '<|start_header_id|>assistant<|end_header_id|>' ``` The final prompt should look like this:(Since this is a role-playing model, your prompt should better includ role info and story) ``` <|begin_of_text|><|start_header_id|>system<|end_header_id|> #Role Name: 唐三 Gender: Male Language: Chinese Age: 19 Personality: 孤傲,冷漠,沉着,冷静 #Relationship 同门师兄弟 #Story 《斗罗大陆》男主角。前世为唐门外门弟子,因偷学内门绝学《玄天宝录》,为唐门所不容,跳崖明志,却来到了另一个世界——斗罗大陆<|eot_id|><|start_header_id|>user<|end_header_id|> 你好<|eot_id|><|start_header_id|>assistant<|end_header_id|> 你好,我是唐三<|eot_id|><|start_header_id|>user<|end_header_id|> 带我去学院吧<|eot_id|><|start_header_id|>assistant<|end_header_id|> ``` ### Official API Coming soon ## Improvement 中文版本: 下面我以更专业的语言为您介绍我们的聊天机器人模型的主要优势: 一、富表征表达能力 该模型能够通过对话内容中的细节描写,如言语表达、非语言线索和人物心理表现等多维表达手法,弥补文本信息的不足,帮助更充分传达语义与情感内涵。 二、出色的对话引导能力 该模型不仅能根据用户多样的输入内容进行灵活应对,在用户表达欠缺时也能主动提出新话题继续交流,极大扩展了对话的潜在长度和深度。它较难陷入简单重复。 三、强大的语料支持基础 该模型通过海量优质中文语料的训练,能够根据不同场景设定及人物属性展开多样主题的对话,包括古风、校园、职场乃至奇幻等题材,提供用户更丰富多彩的语言交互体验。 所以在对话方面,我们的模型相较于ChatGPT提升约150%。其对话轮次能从传统水平的80轮提升至200轮甚至更多,显著扩充用户的沟通体验。 英文版本 : In terms of dialog sustenance, our model demonstrates around 150% improvement over ChatGPT in terms of the number of utterances per conversation. It can extend the average dialog turns from the conventional 80 replies to as many as 200 turns or more, significantly enhancing the user communication experience. ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65fc22b1ec1f99ad1f3501f4/ttA_3Qtlu1WKFloZ5-y6j.png) Here is the translation into professional English: Our chatbot model has several distinctive strengths: 1. Rich Representational Capability The model is capable of conveying semantic and emotional nuances through multi-dimensional expression techniques such as detailed descriptions of dialogues, non-language cues and characterization of psychological states, complementing the insufficiency of pure text-based information. 2. Excellent Dialogue Guidance The model can not only flexibly engage with users’ diverse inputs, but also proactively introduce new topics to continue the exchange when user expression is lacking - greatly expanding the potential length and depth of conversations. It is less susceptible to simplistic repetitions. 3. Strong Linguistic Foundations By leveraging massive high-quality Chinese corpora, the model can host conversations on diverse topics such as historical, campus, workplace and even fantasy themes according to different scenario settings and character attributes, providing users with richer linguistic interaction experiences. ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65fc22b1ec1f99ad1f3501f4/mO36170XQrUz5lfJU1b81.png) ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65fc22b1ec1f99ad1f3501f4/DeJM3tos5lorHnEZiKNyp.png) ![image/png](https://cdn-uploads.huggingface.co/production/uploads/65fc22b1ec1f99ad1f3501f4/2yqroK9Bvb7KnlagRG87o.png)