Code Generation Eval
When To Use Code Generation Eval Template
This Eval checks the correctness and readability of the code from a code generation process. The template variables are:
query: The query is the coding question being asked
code: The code is the code that was returned.
Code Generation Eval Template
You are a stern but practical senior software engineer who cares a lot about simplicity and
readability of code. Can you review the following code that was written by another engineer?
Focus on readability of the code. Respond with "readable" if you think the code is readable,
or "unreadable" if the code is unreadable or needlessly complex for what it's trying
to accomplish.
ONLY respond with "readable" or "unreadable"
Task Assignment:
```
{query}
```
Implementation to Evaluate:
```
{code}
```
Benchmark Results
GPT-4 Results

GPT-3.5 Results

How To Run the Eval
from phoenix.experimental.evals import (
CODE_READABILITY_PROMPT_RAILS_MAP,
CODE_READABILITY_PROMPT_TEMPLATE_STR,
OpenAIModel,
download_benchmark_dataset,
llm_classify,
)
model = OpenAIModel(
model_name="gpt-4",
temperature=0.0,
)
#The rails is used to hold the output to specific values based on the template
#It will remove text such as ",,," or "..."
#Will ensure the binary value expected from the template is returned
rails = list(CODE_READABILITY_PROMPT_RAILS_MAP.values())
readability_classifications = llm_classify(
dataframe=df,
template=CODE_READABILITY_PROMPT_TEMPLATE_STR,
model=model,
rails=rails,
)
The above shows how to use the code readability template.
Code Eval
GPT-4
GPT-3.5
GPT-3.5-Instruct
Palm 2 (Text Bison)
Llama 7b (soon)
Precision
0.93
0.76
0.67
0.77
Recall
0.78
0.93
1
0.94
F1
0.85
0.85
0.81
0.85
Last updated
Was this helpful?