Skip to content

Implement Ask details pipeline evaluation process - #42

Merged
cyyeh merged 32 commits into
mainfrom
feature/3-ask-details-pipeline-evaluation-process
Apr 2, 2024
Merged

Implement Ask details pipeline evaluation process#42
cyyeh merged 32 commits into
mainfrom
feature/3-ask-details-pipeline-evaluation-process

Conversation

@paopa

@paopa paopa commented Mar 27, 2024

Copy link
Copy Markdown

This PR aims to make the evaluation process more easily executed. and support a Streamlit app to present and compare the evaluation results. And, it includes a few metrics to support us in comparing and analyzing the reports.

Metrics

Metric Catalog Approach Description
Accuracy Ragas Answer Correctness Measures the correctness of the answer provided by the model. Learn more
Accuracy Wren Execution Correct Evaluates whether the SQL generated by the model can be executed without errors.
Accuracy Wren LLM as the Judge Uses the model as a judge to compare the ground truth and the candidate answer.
Latency - - Measures the time taken to complete a task or process.
Cost - - Refers to the monetary expense incurred for a particular task or process.

Run the evaluation process

Execute the evaluation process via make command

make eval pipeline=src.eval.ask_details

The process will reproduce the report in JSON format, which includes the summary and details for each record.

{
    "total": 1,
    "accuracy": {
        "ragas": {
            "answer_correctness": 0.6310689639982272
        },
        "wren": {
            "execution_correct": {
                "true": 0,
                "false": 1
            },
            "llm_judge": 1.0
        }
    },
    "latency": 6.410386032075621,
    "cost": 0.00045299999999999995,
    "collection": [
        {
            "accuracy": {
                "ragas": {
                    "answer_correctness": 0.6310689639982272
                },
                "wren": {
                    "execution_correct": false,
                    "llm_judge": {
                        "explanation": "The candidate SQL provided captures the essence of the user's intent fairly accurately. The initial query to join the 'college' and 'player_college' tables is correct, which is crucial for identifying the college with the highest number of players. However, there are some discrepancies in the subsequent steps. The use of GROUP BY 'college_id' instead of 'name_full' in the second SELECT statement could potentially lead to incorrect results, as the query should focus on the college with the highest number of players, not just any college ID. Additionally, the missing CTE (Common Table Expression) declaration in the second step creates a gap in the query flow, affecting the overall execution logic.",
                        "score": 1.0
                    }
                }
            },
            "latency": 6.410386032075621,
            "cost": 0.00045299999999999995,
            "model": "gpt-3.5-turbo-0125",
            "usage": {
                "completion_tokens": 193,
                "prompt_tokens": 327,
                "total_tokens": 520
            },
            "question": {
                "query": "what is the full name and id of the college with the largest number of baseball players?",
                "sql": "SELECT T1.name_full, T1.college_id FROM college AS T1 JOIN player_college AS T2 ON T1.college_id = T2.college_id GROUP BY T1.college_id ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1",
                "summary": null
            },
            "response": {
                "description": "Retrieve the full name and college ID of the college with the highest number of players, handling NULL values last.",
                "steps": [
                    {
                        "sql": "SELECT T1.name_full, T1.college_id FROM college AS T1 JOIN player_college AS T2 ON T1.college_id = T2.college_id",
                        "summary": "Select the full name and college ID from the college table and join it with the player_college table.",
                        "cte_name": "step1"
                    },
                    {
                        "sql": "SELECT name_full, college_id FROM step1 GROUP BY college_id ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1",
                        "summary": "Group the result by college ID, order by the count of players in descending order with NULLs last, and limit the output to 1 row.",
                        "cte_name": ""
                    }
                ]
            },
            "ground_truth": {
                "description": "Retrieve the full name and college ID of the college with the highest number of players, handling NULL values last.",
                "steps": [
                    {
                        "sql": "WITH college_players_count AS (SELECT T1.name_full, T1.college_id, COUNT(*) AS player_count FROM college AS T1 JOIN player_college AS T2 ON T1.college_id = T2.college_id GROUP BY T1.name_full, T1.college_id) ",
                        "summary": "Calculate the count of players for each college.",
                        "cte_name": "college_players_count"
                    },
                    {
                        "sql": "SELECT name_full, college_id FROM college_players_count ORDER BY player_count DESC NULLS LAST LIMIT 1",
                        "summary": "Retrieve the full name and college ID of the college with the highest number of players, handling NULL values last.",
                        "cte_name": ""
                    }
                ]
            }
        }
    ]
}

Run the dashboard to compare and analyze the results

Start the Streamlit app to present the report via make command

make streamlit pipeline=src/eval/ask_details/streamlit_app.py
image image

@paopa paopa added the module/ai-service ai-service related label Mar 27, 2024
@paopa paopa linked an issue Mar 27, 2024 that may be closed by this pull request
@paopa
paopa force-pushed the feature/3-ask-details-pipeline-evaluation-process branch from 1464a67 to 5453798 Compare March 27, 2024 04:02
@paopa paopa changed the title [WIP] Implement Ask details pipeline evaluation process Implement Ask details pipeline evaluation process Mar 27, 2024
@paopa
paopa requested a review from cyyeh March 27, 2024 06:29
@paopa
paopa force-pushed the feature/3-ask-details-pipeline-evaluation-process branch from 1345571 to 6beb846 Compare March 28, 2024 06:24
@paopa
paopa force-pushed the feature/3-ask-details-pipeline-evaluation-process branch from 6beb846 to 24f973e Compare March 28, 2024 09:37

@cyyeh cyyeh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyyeh
cyyeh merged commit 946f727 into main Apr 2, 2024
@cyyeh
cyyeh deleted the feature/3-ask-details-pipeline-evaluation-process branch April 2, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/ai-service ai-service related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ask_details pipeline evaluation process

2 participants