Repository: EleutherAI/lm-evaluation-harness
Issue: Llama-3.1-8B-Instruct Accuracy much lower for HumanEval_Instruct
Root cause: Algorithmic Error

Hi, 

Thanks a low for adding the **humaneval_instruct** dataset and supporting the prompt for Llama models! 

I was running the following command to evaluate the accuracy of humaneval_instruct on **Llama-3.1-8B-Instruct**:
```
python -m lm_eval  --model hf  --model_args pretrained="meta-llama/Llama-3.1-8B-Instruct"  --tasks humaneval_instruct  --confirm_run_unsafe_code  --batch_size 4 
```
But the accuracy for Llama-3.1-8B-Instruct is only **17.68**. I was using "transformers==4.43.1". I already followed #3092 to modify the humaneval_instruct.yaml.

Could you provide me with some suggestions? Thank you!
 

Hi! made a fix in the PR. Use with `--apply_chat_template`

Thank you very much for the quick reply! In my case, using "--apply_chat_template" will cause a warning 
```
A decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set padding_side='left' when initializing the tokenizer.
```
And the resulting accuracy became 0% in my case.
I tried to simply change the single quote to double quote 
```
doc_to_text: "Write a solution to the following problem and make sure that it passes the tests:\n```python\n{{ prompt }}\n```\n "
gen_prefix: "Here is the completed function:\n```python\n{{ prompt }}\n "
```
Yet still got accuracy 0%.

I did some ablation study, and eventually found out that 
1. By using "humaneval_instruct" of #2820  and change  "doc_to_text" to
```
doc_to_text: "Write a solution to the following problem and make sure that it passes the tests:\n```{{prompt}}```"
```
  which adds 3 backtick at the end.
2. Change ".**rfind()**" in [this line ](https://github.com/EleutherAI/lm-evaluation-harness/blob/74597ea1078482d991e15d6b25baff15a2a1e1d8/lm_eval/tasks/humaneval/utils.py#L35) to ".**find()**"

solves my problem and I got 67.07% accuracy.

I am not sure if this is due to a different environment setting in my computer. If this is a general solution, I can make a PR if needed. 

hmm. Thats similar to #3092. Can you run again now from main now that we fixed the quotes? I got:

hf (pretrained=meta-llama/Llama-3.1-8B-Instruct), gen_kwargs: (None), limit: None, num_fewshot: None, batch_size: 1
|      Tasks       |Version|  Filter   |n-shot|Metric|   |Value |   |Stderr|
|------------------|------:|-----------|-----:|------|---|-----:|---|-----:|
|humaneval_instruct|      3|create_test|     0|pass@1|   |0.6646|±  | 0.037|

Thanks for your reply. Yes. The observation is similar to #3092 in terms of using ".**find()**" instead of ".**rfind()**". But using #3092's "doc_to_text" also gives 0% in my case. 

I just tried building a completely new conda environment and cloning the most recent main repo, and ran "pip install -e ." followed by
```
python -m lm_eval  --model hf  --model_args pretrained="meta-llama/Llama-3.1-8B-Instruct"  --tasks humaneval_instruct  --confirm_run_unsafe_code  --batch_size 1
```
But still got 0% accuracy. 

![Image](https://github.com/user-attachments/assets/6d836784-667c-468c-ac5d-446a2f931bd5)
This is what I got.

> ![Image](https://github.com/user-attachments/assets/6d836784-667c-468c-ac5d-446a2f931bd5) This is what I got.

This is odd. Can you share the samples generated? you can save them using `--log_samples` (and pass `--output_path <dir>`)

Thank you very much for following up! Please see below for the samples (**logs.txt**) and results generated:
```
{
  "results": {
    "humaneval_instruct": {
      "alias": "humaneval_instruct",
      "pass@1,create_test": 0.0,
      "pass@1_stderr,create_test": 0.0
    }
  },
  "group_subtasks": {
    "humaneval_instruct": []
  },
  "configs": {
    "humaneval_instruct": {
      "task": "humaneval_instruct",
      "dataset_path": "openai/openai_humaneval",
      "test_split": "test",
      "doc_to_text": "Write a solution to the following problem and make sure that it passes the tests:\n```python\n{{ prompt }}\n```\n ",
      "doc_to_target": "{{test}}\ncheck({{entry_point}})",
      "unsafe_code": true,
      "description": "",
      "target_delimiter": " ",
      "fewshot_delimiter": "\n\n",
      "num_fewshot": 0,
      "metric_list": [
        {
          "metric": "def pass_at_k(references: list[str], predictions: list[list[str]], k: list[int] = None):\n    global compute_\n    assert k is not None\n    if isinstance(k, int):\n        k = [k]\n    res = compute_.compute(\n        references=references,\n        predictions=predictions,\n        k=k,\n    )\n    return res[0]\n",
          "aggregation": "mean",
          "higher_is_better": true,
          "k": [
            1
          ]
        }
      ],
      "output_type": "generate_until",
      "generation_kwargs": {
        "until": [
          "\nclass",
          "\ndef",
          "\n#",
          "\nif",
          "\nprint"
        ],
        "max_gen_toks": 1024,
        "do_sample": false
      },
      "repeats": 1,
      "filter_list": [
        {
          "name": "create_test",
          "filter": [
            {
              "function": "custom",
              "filter_fn": "<function build_predictions_instruct at 0x7fa788323be0>"
            }
          ]
        }
      ],
      "should_decontaminate": false,
      "gen_prefix": "Here is the completed function:\n```python\n{{ prompt }}\n ",
      "metadata": {
        "version": 3.0,
        "pretrained": "meta-llama/Llama-3.1-8B-Instruct"
      }
    }
  },
  "versions": {
    "humaneval_instruct": 3.0
  },
  "n-shot": {
    "humaneval_instruct": 0
  },
  "higher_is_better": {
    "humaneval_instruct": {
      "pass_at_k": true
    }
  },
  "n-samples": {
    "humaneval_instruct": {
      "original": 164,
      "effective": 164
    }
  },
  "config": {
    "model": "hf",
    "model_args": "pretrained=meta-llama/Llama-3.1-8B-Instruct",
    "model_num_parameters": 8030261248,
    "model_dtype": "torch.bfloat16",
    "model_revision": "main",
    "model_sha": "0e9e39f249a16976918f6564b8830bc894c89659",
    "batch_size": "1",
    "batch_sizes": [],
    "device": null,
    "use_cache": null,
    "limit": null,
    "bootstrap_iters": 100000,
    "gen_kwargs": null,
    "random_seed": 0,
    "numpy_seed": 1234,
    "torch_seed": 1234,
    "fewshot_seed": 1234
  },
  "git_hash": "ff41a85",
  "date": 1751568282.3481896,
  "pretty_env_info": "PyTorch version: 2.7.1+cu126\nIs debug build: False\nCUDA used to build PyTorch: 12.6\nROCM used to build PyTorch: N/A\n\nOS: Ubuntu 20.04.6 LTS (x86_64)\nGCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0\nClang version: 10.0.0-4ubuntu1 \nCMake version: version 3.16.3\nLibc version: glibc-2.31\n\nPython version: 3.10.18 | packaged by conda-forge | (main, Jun  4 2025, 14:45:41) [GCC 13.3.0] (64-bit runtime)\nPython platform: Linux-5.4.0-216-generic-x86_64-with-glibc2.31\nIs CUDA available: True\nCUDA runtime version: 12.1.66\nCUDA_MODULE_LOADING set to: LAZY\nGPU models and configuration: GPU 0: NVIDIA RTX A6000\nNvidia driver version: 530.30.02\ncuDNN version: Probably one of the following:\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.5\n/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.5\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.1\n/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.1.1\n/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.1.1\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.2.2\n/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.2.2\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.8.1\n/usr/local/cuda-12.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.8.1\nHIP runtime version: N/A\nMIOpen runtime version: N/A\nIs XNNPACK available: True\n\nCPU:\nArchitecture:                       x86_64\nCPU op-mode(s):                     32-bit, 64-bit\nByte Order:                         Little Endian\nAddress sizes:                      46 bits physical, 57 bits virtual\nCPU(s):                             64\nOn-line CPU(s) list:                0-63\nThread(s) per core:                 1\nCore(s) per socket:                 32\nSocket(s):                          2\nNUMA node(s):                       2\nVendor ID:                          GenuineIntel\nCPU family:                         6\nModel:                              143\nModel name:                         Intel(R) Xeon(R) Gold 6448Y\nStepping:                           8\nFrequency boost:                    enabled\nCPU MHz:                            1761.992\nCPU max MHz:                        2101.0000\nCPU min MHz:                        800.0000\nBogoMIPS:                           4200.00\nVirtualization:                     VT-x\nL1d cache:                          3 MiB\nL1i cache:                          2 MiB\nL2 cache:                           128 MiB\nL3 cache:                           120 MiB\nNUMA node0 CPU(s):                  0-31\nNUMA node1 CPU(s):                  32-63\nVulnerability Gather data sampling: Not affected\nVulnerability Itlb multihit:        Not affected\nVulnerability L1tf:                 Not affected\nVulnerability Mds:                  Not affected\nVulnerability Meltdown:             Not affected\nVulnerability Mmio stale data:      Not affected\nVulnerability Retbleed:             Not affected\nVulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp\nVulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization\nVulnerability Spectre v2:           Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S\nVulnerability Srbds:                Not affected\nVulnerability Tsx async abort:      Not affected\nFlags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid cldemote movdiri movdir64b md_clear pconfig flush_l1d arch_capabilities\n\nVersions of relevant libraries:\n[pip3] numpy==2.2.6\n[pip3] nvidia-cublas-cu12==12.6.4.1\n[pip3] nvidia-cuda-cupti-cu12==12.6.80\n[pip3] nvidia-cuda-nvrtc-cu12==12.6.77\n[pip3] nvidia-cuda-runtime-cu12==12.6.77\n[pip3] nvidia-cudnn-cu12==9.5.1.17\n[pip3] nvidia-cufft-cu12==11.3.0.4\n[pip3] nvidia-curand-cu12==10.3.7.77\n[pip3] nvidia-cusolver-cu12==11.7.1.2\n[pip3] nvidia-cusparse-cu12==12.5.4.2\n[pip3] nvidia-cusparselt-cu12==0.6.3\n[pip3] nvidia-nccl-cu12==2.26.2\n[pip3] nvidia-nvjitlink-cu12==12.6.85\n[pip3] nvidia-nvtx-cu12==12.6.77\n[pip3] torch==2.7.1\n[pip3] triton==3.3.1\n[conda] numpy                     2.2.6                    pypi_0    pypi\n[conda] nvidia-cublas-cu12        12.6.4.1                 pypi_0    pypi\n[conda] nvidia-cuda-cupti-cu12    12.6.80                  pypi_0    pypi\n[conda] nvidia-cuda-nvrtc-cu12    12.6.77                  pypi_0    pypi\n[conda] nvidia-cuda-runtime-cu12  12.6.77                  pypi_0    pypi\n[conda] nvidia-cudnn-cu12         9.5.1.17                 pypi_0    pypi\n[conda] nvidia-cufft-cu12         11.3.0.4                 pypi_0    pypi\n[conda] nvidia-curand-cu12        10.3.7.77                pypi_0    pypi\n[conda] nvidia-cusolver-cu12      11.7.1.2                 pypi_0    pypi\n[conda] nvidia-cusparse-cu12      12.5.4.2                 pypi_0    pypi\n[conda] nvidia-cusparselt-cu12    0.6.3                    pypi_0    pypi\n[conda] nvidia-nccl-cu12          2.26.2                   pypi_0    pypi\n[conda] nvidia-nvjitlink-cu12     12.6.85                  pypi_0    pypi\n[conda] nvidia-nvtx-cu12          12.6.77                  pypi_0    pypi\n[conda] torch                     2.7.1                    pypi_0    pypi\n[conda] triton                    3.3.1                    pypi_0    pypi",
  "transformers_version": "4.53.0",
  "lm_eval_version": "0.4.9",
  "upper_git_hash": null,
  "tokenizer_pad_token": [
    "
",
    "128009"
  ],
  "tokenizer_eos_token": [
    "
",
    "128009"
  ],
  "tokenizer_bos_token": [
    "
",
    "128000"
  ],
  "eot_token_id": 128009,
  "max_length": 131072,
  "task_hashes": {
    "humaneval_instruct": "3023ddb944d18a8453b3bf9b640972edeb64e1490d505c48c44f50439fc3256e"
  },
  "model_source": "hf",
  "model_name": "meta-llama/Llama-3.1-8B-Instruct",
  "model_name_sanitized": "meta-llama__Llama-3.1-8B-Instruct",
  "system_instruction": null,
  "system_instruction_sha": null,
  "fewshot_as_multiturn": false,
  "chat_template": null,
  "chat_template_sha": null,
  "start_time": 2088410.113188985,
  "end_time": 2091443.951197271,
  "total_evaluation_time_seconds": "3033.8380082859658"
}
```

[logs.txt](https://github.com/user-attachments/files/21045785/logs.txt)

https://github.com/EleutherAI/lm-evaluation-harness/issues/3100#issuecomment-3032672109
I meet the same problem for Llama-3-8B-Instruct. The acc of reproduced result acc is 0.5488, which is much lower for HumanEval_Instruct.

<img width="1015" height="113" alt="Image" src="https://github.com/user-attachments/assets/5a22d68e-977c-48ac-be1c-09afdced8340" />