Update README.md
Browse files25 unmodified lines2627282930313233343536373825 unmodified lines## TestUse streamlit style quick AI demo framework to write a testing program. <br>prompt:<br>[<br>{"role": "system", "content": "请使用中文按以下格式回答问题:\n<think>\n...\n</think>\n\n..."},<br>{"role": "user", "content": "你是抖音博主`<douyin_creator_name>`, 请把所给的文稿改写成`<douyin_creator_name>`的抖音口播稿文案,并用中文输出。你的文案从不用表情符号,也不包含拍摄指导脚本。n\n`<your_script>`"}<br>]## Effect<table>25 unmodified lines2627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858625 unmodified lines## Test```from transformers import AutoModelForCausalLM, AutoTokenizermodel_name = "aipgpt/Txt-Polisher-Douyin-Style-R-V2"# load the tokenizer and the modeltokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto")# prepare the model inputuser_prompt = "你是抖音博主'多多喂', 请把所给的文稿改写成'多多喂'风格的抖音口播稿文案,并用中文输出。你的文案从不用表情符号,也不包含拍摄指导脚本。\n\n20个智慧机器模型支撑(如百度文心和清华智谱),还有120个小机器模型为其分解工作难度(如办公PPT和方案、机关总结和机关公文、互联网短视频和小红薯文案等)。\n\n看它的短视频文案,不仅有直播脚本,还有对抖音运营的策划建议,既有文案建议,又有运营建议。\n\n以对话方式解决,即输入简洁的需求,可得到靠谱的文案答复。如输入短视频需求,具体需求关键点可以包括:短视频标题,与旅行相关,民宿和野炊一日游,安全、景美,成为一种周末游趋势。需求越细化,能得到的内容越趋向于目标需求。\n\n短视频功能强大,既包括了一般的通篇脚本撰写功能,还包括了开头5秒、赢流量,以及精品脚本打造、做精品。打包了短视频文案撰写常遇到的一些难点问题,最后还能链接到主推商品,主要可借助对话鸭的“视频脚本专家”功能来完成。"system_prompt = """请使用中文按以下格式回答问题:<think>...</think>..."""messages = [{"role": "system", "content": system_prompt},{"role": "user", "content": user_prompt}]text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True,enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.)model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completiongenerated_ids = model.generate(**model_inputs,max_new_tokens=32768)output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()# parsing thinking contenttry:# rindex finding 151668 (</think>)index = len(output_ids) - output_ids[::-1].index(151668)except ValueError:index = 0thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")print("thinking content:", thinking_content)print("content:", content)```## Effect<table>
README.md+53-5