debug-parse4.js 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. // Verify: the truncation is due to max_tokens limit
  2. // Check roughly how many tokens 9867 Chinese chars would be
  3. const content = `每一个200字,都是对一个日常思维盲区的温柔颠覆——让你在下一个转角遇见不同的自己`;
  4. // Rough estimate: Chinese chars ~= tokens when using BPE-like tokenizers
  5. // For MiniMax M2.7 with 128k context, 9867 chars would be roughly 5000+ tokens
  6. // Check: does the response have roughly the right size for 4096 tokens?
  7. const fs = require('fs');
  8. const fileContent = fs.readFileSync('temp/rich-outline-fail_57_1779014018760.txt', 'utf-8');
  9. const marker = '========== AI 原始响应 ';
  10. const markerIdx = fileContent.indexOf(marker);
  11. const headerEndIdx = fileContent.indexOf(' ==========', markerIdx);
  12. const aiStart = fileContent.indexOf('\n', headerEndIdx) + 1;
  13. const aiEnd = fileContent.indexOf('\n\n', aiStart);
  14. const aiResponse = fileContent.substring(aiStart, aiEnd);
  15. console.log('AI response length (chars):', aiResponse.length);
  16. // Chinese chars ratio
  17. const chineseChars = (aiResponse.match(/[一-鿿]/g) || []).length;
  18. console.log('Chinese chars:', chineseChars);
  19. console.log('Non-Chinese chars:', aiResponse.length - chineseChars);
  20. // Rough token estimate: Chinese chars ~= 1.5-2 tokens each for MiniMax
  21. // Plus English/punctuation ~= 0.5 tokens each
  22. const estimatedTokens = chineseChars * 1.5 + (aiResponse.length - chineseChars) * 0.5;
  23. console.log('Estimated tokens (rough):', Math.round(estimatedTokens));
  24. // The model has maxTokens=4096, so if estimatedTokens > 4096, truncation happened
  25. console.log('\nmaxTokens setting: 4096');
  26. console.log('Would be truncated:', estimatedTokens > 4096 ? 'YES' : 'NO');