Evaling llm-jp-eval (evals are hard)

<p>

With training of <a href="https://wandb.ai/augmxnt/shisa-v2/" rel="nofollow">shisa-v2</a> starting in earnest, I've been digging a bit more into <a href="https://github.com/llm-jp/llm-jp-eval" rel="nofollow">llm-jp-eval</a>, which I used as a quick and simple benchmark to help to track shisa-v1 (especially the base model) performance during development.</p>
<p>WandB has implement the <a href="https://wandb.ai/wandb-japan/llm-leaderboard/reports/Nejumi-LLM-Leaderboard-Evaluating-Japanese-Language-Proficiency--Vmlldzo2MzU3NzIy" rel="nofollow">Nejumi LLM Leaderboard</a> which has a <a href="https://github.com/wandb/llm-leaderboard" rel="nofollow">test harness</a> for modifying settings and uploading/viewing on WandB (here's my workspace: <a href="https://wandb.ai/augmxnt/nejumi" rel="nofollow">https://wandb.ai/augmxnt/nejumi</a>).</p>
<p>First I was curious to see if I could replicate the <a href="https://huggingface.co/augmxnt/shisa-gamma-7b-v1">shisa-gamma-7b-v1</a> results, which despite (IMO) being superceded by generally stronger JA models, still actually ranks at the top of the JA-tuned open models. But if you look for <a href="https://huggingface.co/augmxnt/shisa-7b-v1">shisa-7b-v1</a> you'll find that it basically does not complete. These models are basically tuned on the same dataset, so what's going on exactly?</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/CoQ7eYMhzZxryfIVmex5_.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/CoQ7eYMhzZxryfIVmex5_.png"/></a></p>
<p>Well, for the second part, that's actually relatively easy to answer. Both the <a href="https://huggingface.co/augmxnt/shisa-base-7b-v1">base model</a> and final <a href="https://huggingface.co/augmxnt/shisa-7b-v1">shisa-7b</a> were trained requiring a <code>bos_token</code> (see <a href="https://huggingface.co/augmxnt/shisa-7b-v1#prompt-format">note</a>) and it simply won't output sensible output without it. You can see that when using a <a href="https://github.com/shisa-ai/nejumi/blob/main/configs/shisa-7b-v1.prompt-jaster-bostoken.yaml" rel="nofollow">config with the default prompt with a bos_token</a> prepended, it <a href="https://wandb.ai/augmxnt/nejumi/runs/ahzrypj9" rel="nofollow">scores almost as well as shisa-gamma-7b-v1</a>.</p>
<p>Now as for untangling the other mystery - surprisingly, when testing with the native (llama2) chat template, it actually performs much worse. Why is this? Well, <a href="https://wandb.ai/augmxnt/nejumi/reports/Weave-jaster_output_table_dev-24-05-17-23-44-51---Vmlldzo3OTkxMjE3" rel="nofollow">let's look at the output</a>. It turns out that when you use the Japanese prompt... the model tends to want to answer in Japanese:</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/Jv1_jdxnvn-CdrdKUOkVL.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/Jv1_jdxnvn-CdrdKUOkVL.png"/></a></p>
<p>This is significantly less likely to happen when not using fine-tuned chat formatting (and it reverts to act as more of a base model). As logprobs aren't used, well, if you reply in Japanese, the scores are a big fat zero on those benchmarks. I did some clicking around and found this and other "formatting" related correctness issues to be prevalent as many of the scores collected are exact match scores (this is important because below a certain size/capability level, LLMs will be pretty brittle; also fine-tuning for single word answers tends to destroy general performance for smaller models). Let's just dive in to one example.</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/P-MyvwWAs3PgWNxKq_aPW.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/P-MyvwWAs3PgWNxKq_aPW.png"/></a></p>
<p>If you order on the Nejumi Leaderboard by JA MT-Bench scores, you can see Lightblue's <a href="https://huggingface.co/lightblue/qarasu-14B-chat-plus-unleashed">lightblue/qarasu-14B-chat-plus-unleashed</a> is the top scoring JA open model for MT-Bench, but it has a relatively abysmal <code>0.1437</code> on the llm-jp-eval. WandB has <a href="https://wandb.ai/wandb-japan/llm-leaderboard" rel="nofollow">info on all the runs they've done</a> as well, so clicking in, let's <a href="https://wandb.ai/wandb-japan/llm-leaderboard/runs/xwmmpnly" rel="nofollow">take a look</a>. This model scores straight 0's on many tests/categories. Let's see for <code>janli</code>:</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/KawWXTNJhvsGxzC43EaZM.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/KawWXTNJhvsGxzC43EaZM.png"/></a></p>
<p>Here it's returning Japanese, not English. How about for <code>jcommonsense</code>?</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/oxwk045F1L6IA1xQbkOrz.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/oxwk045F1L6IA1xQbkOrz.png"/></a></p>
<p>This requires more checking, but I believe it has to be a parsing error... And how about <code>mawps_exact</code>?</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/fU-0EGq5grpPsUUwc9Oy3.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/fU-0EGq5grpPsUUwc9Oy3.png"/></a></p>
<p>OK, well, looks like Qarasu is not the best at math, but even when it <em>does</em> get the right answer, it still gets a 0, since it's scored as an exact match of <em>only</em> a number as an answer. I mean, maybe this tests 0-shot instruction following, but I'm not sure it's as meaningful as it could be (or testing what people think it is) when they look at a "math" score.</p>
<p><code>llm-jp-eval</code> 1.1.0 runs very quickly (for <code>shisa-7b-v1</code>, with it's speedy tokenizer, it runs in 3min on an H100) and I think it has its place, but I've seen most of that Japanese LLM community has decided to use it as a "gold standard" type of benchmark, and I'm not sure that everyone realizes what exactly a good score does or does not mean. Some thoughts on improving it:</p>
<ul>
<li><p>While NLP performance is and important aspect for LLMs, randomly clicking through responses, I see for many models, the score reflects formatting as much as performance. I think the instructions/prompts probably need to be improved, along with few-shotting.</p>
</li>
<li><p>I believe that templating is defintely an issue and I think that moving forward, everyone should be supporting a model's <a href="https://github.com/chujiezheng/chat_templates" rel="nofollow">chat_template</a> if provided in the tokenizer. I think there probably needs to be some thought as well as for whether JA language models are supposed to reply to JA questions in EN or not... Rather than exact match, maybe logprob is the way to go, like what <a href="https://github.com/EleutherAI/lm-evaluation-harness" rel="nofollow">lm-eval</a> does?</p>
</li>
<li><p>Of course, all of these tests have <a href="https://github.com/llm-jp/llm-jp-eval/blob/main/DATASET.md" rel="nofollow">train sets</a> available, and you could train on them (we threw the train sets into <a href="https://huggingface.co/datasets/augmxnt/ultra-orca-boros-en-ja-v1">ultra-orca-boros-en-ja-v1</a> and found it improved our overall JA performance, but <a href="https://github.com/llm-jp/llm-jp-sft#for-the-13b-model-single-node-single-a100-40gb-gpu-1" rel="nofollow">when used as the primary sft</a>, it actually obliterated all general performance (eg basic Japanese coherence, ability to respond in more than one word answers) when I tested their original 1.0 "jaster" fine tunes of models.</p>
</li>
</ul>
<p>llm-jp-eval continues to iterate, and it looks like with 1.3.0, they've been adding wiki and other comprehensions tests, but without moving to multiple choice logprob or oracle/llm-as-judge, well, maybe something to revisit. Here's some <a href="https://wandb.ai/llm-jp-eval/test-eval/reports/llm-jp---Vmlldzo1NzE0NjA1?accessToken=s09hm7xrqg43ls8i25am6t0r7iwjpninwzeelqqgbx53zivlm9s04ixfpv3xgiwm" rel="nofollow">more information (and their own leaderboard) from the llm-jp-eval team</a>.</p>
<p>Anyway, was a bit surprising when I started digging in today, so just thought I'd share.</p>
<p>BTW, JA MT-Bench has its own problems. Non-JA trained models sometimes score surprisngly well on it (GPT-4 as judge). Well, running some simple JA detection code, shows that some of the highest scoring models are <em>simply not outputting Japanese</em>:</p>
<p><a href="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/EW1Ql9lELArXEakMZCTMo.png" rel="nofollow"><img alt="image/png" src="https://cdn-uploads.huggingface.co/production/uploads/63a7422854f1d0225b075bfc/EW1Ql9lELArXEakMZCTMo.png"/></a></p>
<p>~80% is the cutoff for whether it's actually replying in Japanese or not.</p>
<p>Note for those looking to run similar testing, I used a dead simple (but good enough for rough cut) heuristic:</p>
<pre><code>def is_japanese_char(char):
    # Check if the character falls within the Japanese Unicode codepoint ranges
    return any([
        0x3040 &lt;= ord(char) &lt;= 0x309F,  # Hiragana
        0x30A0 &lt;= ord(char) &lt;= 0x30FF,  # Katakana
        0x4E00 &lt;= ord(char) &lt;= 0x9FFF   # Kanji
    ])
</code></pre>
