| --- |
| license: mit |
| datasets: |
| - LooksJuicy/ruozhiba-punchline |
| language: |
| - zh |
| - en |
| base_model: |
| - Qwen/Qwen3-14B |
| pipeline_tag: text-generation |
| tags: |
| - punchline |
| --- |
| |
| ## Purpose |
| Simple, just make your comments more eye-catching, like talk show style!!! |
|
|
|
|
|  |
|
|
|
|
|  |
|
|
|
|
| ## Train |
| It's a reasoning model. Train Qwen/Qwen3-14B with USLOTH's GRPO. |
|
|
|
|
| ## Test |
| ``` |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
| |
| model_name = "aipgpt/Punch-Line-Master" |
| |
| # load the tokenizer and the model |
| tokenizer = AutoTokenizer.from_pretrained(model_name) |
| model = AutoModelForCausalLM.from_pretrained( |
| model_name, |
| torch_dtype="auto", |
| device_map="auto" |
| ) |
| |
| # prepare the model input |
| user_prompt = "请用幽默的方式修改下面这句话,建议参考脱口秀方式。改后句子长度不超过原句长度的3倍。\n\n原来我和富豪的共同点是都会失眠,区别是他们后悔几千万的决策,我后悔半夜点开外卖软件的手……" |
| 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 completion |
| generated_ids = model.generate( |
| **model_inputs, |
| max_new_tokens=32768 |
| ) |
| output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() |
| |
| # parsing thinking content |
| try: |
| # rindex finding 151668 (</think>) |
| index = len(output_ids) - output_ids[::-1].index(151668) |
| except ValueError: |
| index = 0 |
| |
| thinking_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) |
| ``` |
|
|
|
|
| ## Contact |
| My wechat 229402265, if you ... |