V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
dong706
V2EX  ›  程序员

让 deepseek R1 大模型写一篇符合字数要求的文章,但是字数总是超标

  •  
  •   dong706 · 5 天前 · 753 次点击

    比如我让 deepseek R1 大模型指定主题写一篇 30-40 字的短文。它总是写出五六七十个字来。

    该怎么写提示词,让大模型的输出内容符合字数要求呢?求大佬们指教~

    dong706
        1
    dong706  
    OP
       5 天前
    这是 R1 自己的答案:

    要实现大模型生成英语作文时精准控制单词数量在 30-40 词范围内,可以尝试以下结构化方法(附示例):
    精确指令法(成功率 80%)
    提示词示例:
    "Write a 35-word English essay about summer vacation. Use exactly 6 sentences: 1 opening (5 words), 4 body sentences (6-8 words each), and 1 closing (5 words. Count words meticulously before responding."
    输出示例:
    Summer brings bright sunshine. Children play at sandy beaches. Families picnic under shady trees. Ice cream melts in warm hands. Fireworks light up night skies. These moments create lasting memories. (35 words)
    分步控制法(成功率 90%)
    提示词结构:
    [主题]:Spring Festival
    [要求]:
    总词数:35±2
    段落结构:
    Opening: 1 句 (5-7 词)
    3 个要点句:每句 8-10 词
    Closing: 1 句 (6-8 词)
    使用基数词代替序数词
    避免从句结构
    自我检查法(成功率 95%)
    提示词示例:
    "Generate a 38-word essay about online learning. After drafting, perform these steps:
    Remove all adjectives
    Replace phrasal verbs with single verbs
    Count words and adjust sentence length
    Final output in this format: [Essay] [Word count: X]"
    输出示例:
    Online learning offers flexibility. Students access courses anywhere. Teachers upload materials digitally. Discussions happen via forums. Tests are taken online. This method saves commute time. [Word count: 37]
    示例引导法(成功率 85%)
    提供模板:
    "Follow this exact structure:
    Sentence 1: 5-word topic introduction
    Sentence 2-4: 8-word explanations
    Sentence 5: 7-word conclusion
    Example:
    Pets teach responsibility. Children feed them daily. They learn cleaning habits. Walking dogs builds discipline. Caring develops lifelong skills. (35 words)"
    注意事项:
    使用短句结构(平均 6-8 词 / 句)
    避免缩略形式和所有格符号
    优先使用单音节词汇
    用分号替代连接词( and/but )
    指定具体主题(如 "My Last Birthday" 而非 "An Event")
    调试技巧:
    若输出超限,可追加指令:
    "Condense by:
    Removing all adverbs
    Converting phrases to single words (e.g. 'students who study' → 'studying students')
    Using numerals instead of words (3→three)"
    ziyeziye
        2
    ziyeziye  
       5 天前
    不管是哪个模型,无论是中文还是英文都很难做到准确字数
    AoEiuV020JP
        3
    AoEiuV020JP  
       5 天前
    讲道理 AI 数数都不一定能数清,你想要严格限制字数为难 AI 了,
    另外不要粘贴 AI 回复到这里,小心 404 ,
    8355
        4
    8355  
       5 天前
    把你的提示词法出来大家来优化一下咯
    0o0o0o0
        5
    0o0o0o0  
       5 天前
    ai 的回答可以考虑用分享链接替代,不然很容易被封号
    GiantHard
        6
    GiantHard  
       5 天前
    告诉 LLM ,「在输出的时候,每字一行,并在行首写上行号。」

    GiantHard
        7
    GiantHard  
       5 天前
    英文也是同理,只要规定输出的时候,每词一行,行首标明行号就行。
    coolfan
        8
    coolfan  
       5 天前
    @GiantHard #6 聪明
    GiantHard
        9
    GiantHard  
       5 天前
    我发现其实不用我在上面介绍的技巧,deepseek r1 其实不太容易写出太超长的句子,可能跟你的提示词有关?
    cheng6563
        10
    cheng6563  
       5 天前
    准确不了的,可以试着这样稍微优化。

    总字数约为 500 字,在每句话结束时使用 xml 标签标出当前字数和总字数,示例如下:<total_words current="5" max="50"/>

    还嫌不够准就让他和楼上说的那样每一个字都记录一下
    dong706
        12
    dong706  
    OP
       4 天前
    @GiantHard 哇!你这招厉害,学习啦!感谢~
    dong706
        13
    dong706  
    OP
       3 天前
    版主能否帮我删除 1 楼的回复,谢谢!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2538 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 11:00 · PVG 19:00 · LAX 03:00 · JFK 06:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.