Home

Awesome

Julia LLM Leaderboard

Stable Dev SciML Code Style

Comparison of Julia language generation capabilities of various Large Language Models

Introduction

Welcome to the Julia Code Generation Benchmark Repository!

This project is designed for the Julia community to compare the code generation capabilities of various AI models. Unlike academic benchmarks, our focus is practicality and simplicity: "Generate code, run it, and see if it works(-ish)."

This repository aims to understand how different AI models and prompting strategies perform in generating syntactically correct Julia code to guide users in choosing the best model for their needs.

Itchy fingers? Jump to examples/ or just run your own benchmark with run_benchmark() (eg, examples/code_gen_benchmark.jl).

Test Cases

Test cases are defined in a definition.toml file, providing a standard structure for each test. If you want to contribute a test case, please follow the instructions in the Contributing Your Test Case section.

Automated Evaluation Methodology

Each model's and prompt's performance is evaluated based on several criteria:

  1. Parsing: Does the generated code parse correctly in Julia?
  2. Execution: Can the code execute without errors?
  3. Unit Tests: Do the included unit tests pass?
  4. Example Runs: Does the code run in a provided example scenario?

At the moment, all criteria are weighed equally and each test case can earn a maximum of 100 points. If a code passes all criteria, it gets 100/100 points. If it fails one criterion (eg, all unit tests), it gets 75/100 points. If it fails two criteria (eg, it runs but all examples and unit tests are broken), it gets 50 points, and so on.

Results (Preview)

To provide a glimpse of the repository's functionality, we have included example results for the first 14 test cases. Open the documentation for the full results and a deep dive on each test case.

[!WARNING]
These scores might change as we evolve the supporting functionality and add more models.

Remember that the benchmark is quite challenging for any model - a single extra space or parentheses and the score might become 0 (="unable to parse")!

Paid APIs

Claude 3.5 Sonnet is the highest-performing model. For the best value-for-money, look to Mistral Codestral, Claude 3 Haiku and, recently released, GPT 4o mini (60% cheaper than GPT3.5!!!).

ModelElapsedScoreScore Std DeviationCount Zero ScoreCount Full ScoreCost Cents
claude-3-5-sonnet-202406206.385.821.1133550.73
claude-3-opus-2024022920.383.219.623293.9
claude-3-sonnet-202402298.778.826.2223080.73
gpt-4o-2024-08-064.676.627.9263100.0
codestral-24051.976.329.3332760.0
gpt-4-turbo-2024-04-0910.875.329.6382901.38
chatgpt-4o-latest4.875.027.9252630.0
claude-3-haiku-202403074.074.927.292610.05
gpt-4-0125-preview30.374.430.3392841.29
gpt-4-1106-preview22.474.429.9191421.21
gpt-4o-mini-2024-07-185.174.029.4322760.03
mistral-large-240711.373.629.5151370.49
gpt-4o-2024-05-134.372.929.1292570.0
deepseek-coder13.071.632.6391150.01
mistral-large-24028.571.627.2132230.0
deepseek-chat17.971.332.9301400.01
claude-2.110.167.930.8472290.8
gpt-3.5-turbo-01251.261.736.61251920.03
mistral-medium18.160.833.222900.41
mistral-small5.960.130.227760.09
mistral-small-24025.359.929.4311690.0
gpt-3.5-turbo-11062.158.439.282970.04
mistral-tiny4.646.932.075420.02
gpt-3.5-turbo3.642.338.2132540.04
gemini-1.0-pro-latest4.234.827.4181250.0

Note: From mid-February 2024, "gpt-3.5-turbo" will point to the latest release, "gpt-3.5-turbo-0125" (deprecating the June release).

Same information, but as a bar chart:

Model-Prompt-Scores-for-Paid-API

In addition, we can consider the performance (score) versus the cost (measured in US cents):

Cost-vs-Score

Local Models

Locally-hosted models are generally not as good as the best paid APIs, but they are getting close! Note that the "mistral-small" is already available to be run locally and there will be many future finetunes!

[!NOTE] Big thank you to 01.ai and Jun Tian in particular for providing the compute for several parts of this benchmark!

The best trade-off performance vs size is the latest Meta llama3 8bn. Otherwise, the leading model is Mixtral-8x22bn.

ModelElapsedElapsed MedianScoreScore MedianScore Std DeviationCount Zero ScoreCount Full Score
Mixtral-8x22B-Instruct-v0.1(Together.ai)14.111.077.690.025.85.0151.0
Llama-3-70b-chat-hf(Together.ai)4.34.176.888.325.20.0160.0
Llama-3-8b-chat-hf(Together.ai)1.51.467.766.726.45.070.0
WizardLM-2-8x22B(Together.ai)34.731.062.760.033.833.0118.0
phind-codellama:34b-v237.136.461.862.533.536.058.0
magicoder:7b-s-cl-q6_K15.615.859.960.029.918.035.0
codellama:13b-instruct-q4_K_M3.23.056.454.633.056.061.0
deepseek-coder:33b-instruct-q4_K_M46.744.655.050.036.862.068.0
magicoder12.810.753.750.033.249.052.0
nous-hermes2:34b-yi-q4_K_M56.852.850.750.034.778.056.0
dbrx-instruct(Fireworks.ai)3.73.650.050.041.2121.075.0
codellama:13b-instruct18.116.750.050.034.465.044.0
openchat:7b-v3.5-1210-q4_K_M14.413.749.450.030.348.023.0
openhermes2.5-mistral12.912.248.950.031.355.027.0
starling-lm:latest13.712.548.450.030.258.026.0
codellama:7b-instruct-q4_K_M2.12.047.850.035.395.038.0
qwen-72b-chat(Fireworks.ai)3.23.845.950.038.8117.063.0
yi:34b-chat43.941.345.650.030.545.034.0
mistral:7b-instruct-v0.2-q6_K21.720.945.450.031.344.023.0
mistral:7b-instruct-v0.2-q4_012.412.344.350.030.675.032.0
mistral:7b-instruct-v0.2-q4_K_M15.615.142.650.028.671.023.0
codellama:34b-instruct-q4_K_M7.56.839.750.036.1127.035.0
codellama:70b-instruct-q4_K_M16.313.836.40.041.2179.058.0
solar:10.7b-instruct-v1-q4_K_M18.817.735.250.031.1107.010.0
mistral:7b-instruct-q4_K_M13.913.034.850.026.580.00.0
codellama:70b-instruct-q2_K11.29.429.80.037.7198.029.0
llama217.116.326.525.026.5131.00.0
gemma:7b-instruct-q6_K20.922.125.925.025.2147.02.0
orca2:13b20.118.323.10.030.6166.011.0
stablelm-zephyr9.97.715.40.023.5192.01.0
dolphin-phi:2.7b-v2.6-q6_K8.98.414.90.022.9188.00.0
codellama:13b-python12.510.712.80.022.1155.00.0
phi:2.7b-chat-v2-q6_K13.011.68.90.019.4222.00.0

Same information, but as a bar chart:

Model-Scores-for-local-models-by-size

And with a separate bar for each prompt template: Model-Prompt-Scores-for-local-models

[!NOTE] Qwen-1.5 models have been removed from the overviews as the underlying model on Ollama repository (and HF) is not correct and has very low performance.

[!NOTE] I have noticed that some evals in Ollama/llama.cpp now score slightly higher now than in Dec-23, so it's on a roadmap to re-run the above evals.

Overall Time to Run vs Score

Clearly, the paid APIs win (the latest release: GPT-3.5-Turbo-1106), but that's not the whole story.

Elapsed-vs-Score-Paid-APIs

Elapsed-vs-Score-Local-models

Prompting Templates

We hope to be able to provide some guidance around prompting strategies, eg, when is it better to use a "JuliaExpert*" prompt template vs an "In Julia, answer XYZ" prompt.

Learnings so far:

Prompt TemplateElapsed (s, average)Elapsed (s, median)Avg. Score (Max 100 pts)Median Score (Max 100 pts)
InJulia14.09.655.250.0
JuliaExpertAsk9.96.453.850.0
JuliaRecapTask16.711.552.050.0
JuliaExpertCoTTask15.410.449.550.0
JuliaRecapCoTTask16.111.348.650.0

Note: The XML-based templates are tested only for Claude 3 models (Haiku and Sonnet), that's why we removed them from the comparison.

Make your own analysis with examples/summarize_results.jl!

Running Evaluation / Adding More Results

  1. Existing Evaluations: Check scripts/code_gen_benchmark.jl for the example of previous evaluations.
  2. Run Your Evaluation: Choose your model and prompt, and run the test.
  3. Save Results: Store both the conversation and the evaluation.
  4. Open a PR: Include the part of the code snippet you changed in the PR comments. We generally require 1-2 independent verifications of your result.

Want to run some experiments and save the results? Check out examples/experiment_hyperparameter_scan.jl!

Debugging

Want to review some of the past benchmark runs? Check out examples/summarize_results.jl for overall statistics and examples/debugging_results.jl for reviewing the individual conversations/model responses.

Contributing Your Test Case

To contribute a test case:

  1. Naming Convention: Create nested folders following the format code_generation/category/test_case_name/definition.toml.
  2. Saving Results: Store the full conversation and the evaluation results in a path nested by a model name like code_generation/category/test case/model/evaluation__PROMPT__STRATEGY__TIMESTAMP.json and code_generation/category/test case/model/conversation__PROMPT__STRATEGY__TIMESTAMP.json

Anatomy of definition.toml

Required fields in definition.toml include:

There are several optional fields:

The above fields can improve re-use of code across the examples/unit tests.

See an example in examples/create_definition.jl. You can validate your test case definitions with validate_definition().

Contributing GenAI Conversations with/about Julia

Please PR and add any relevant and MOSTLY CORRECT conversations with/in/about Julia in folder julia_conversations/.

The goal is to have a collection of conversations that are useful for finetuning Julia knowledge in smaller models.

Feedback and Improvements

We highly value community input. If you have suggestions or ideas for improvement, please open an issue. All contributions are welcome!