One method of using JudgeIt is through the JudgeIt Python framework. The framework contains Python modules for different types of LLM Judge evaluations. There are three types of LLM Judges:
- RAG Evaluation (Similarity): evaluate generated text against golden text
- RAG Evaluation (Rating): evaluate generated text against golden text
- Multi-turn evaluation: evaluate rewritten queries given a mult-turn conversation
The JudgeIt framework takes input data in the form of excel or csv files for any of these evaluations.
- Deployment Option
- Getting Started
- Usage Example
- Configuring your Input File
- Understanding the Results
- SaaS: If you are using SaaS based LLM service (watsonx.ai), you can set the value of
wml_platform
assaas
in the Config file.
- On Prem: If you have an LLM deployed on premise on CP4D, you can set the value of
wml_platform
asonpremise
in the Config file.
The following prerequisites are required to run the tester:
- Python3
- IBM Cloud api key (this must be for the same cloud account that hosts your watsonx.ai instance)
- watsonx.ai project id: watsonx.ai project's Manage tab (Project -> Manage -> General -> Details)
- This project must be associated with a WML instance
-
Change directory into the JudgeIt Framework
cd JudgeIt-LLM-as-a-Judge/Framework
-
Configure your parameters in config.ini. This repository contains the below sample_config.ini that you can paste and edit:
[Default] home_dir = /home_directory/JudgeIt-LLM-as-a-Judge/ model_id = meta-llama/llama-3-1-70b-instruct input_file_name = Framework/data/input/sample_rag_answer_similarity_input.xlsx output_file_name = Framework/data/output/sample_rag_answer_similarity_output.xlsx judge_type = rag_eval_answer_similarity [WML_CRED] wml_platform = saas wml_user = '' wml_url = https://us-south.ml.cloud.ibm.com api_key = ibm_cloud_api_key project_id = watsonx.ai_project_id
home_dir
: the path to the folder where you have downloaded the repositorymodel_id
: the watsonx.ai model id that will be used for your LLM Judge. We recommendmeta-llama/llama-3-1-70b-instruct
input_file_name
:- specify the path and name of your inputfile
- a sample input file for each evaluation type is located in JudgeIt-LLM-as-a-Judge/Framework/data/input
- see Configuring Your Input File for more details
output_file_name
: specify the path and name of your output filejudge_type
: specify the LLM Judge type. Possible values:rag_eval_answer_similarity
rag_eval_answer_rating
multi_turn_eval
wml_platform
: There are two options available:saas
oronpremise
. If you're using the IBM Watsonx platform, choosesaas
, but if you're using the on-premise Watsonx platform on CP4D, selectonpremise
.wml_url
: you watsonx.ai url: https://<your_region>.ml.cloud.ibm.comwml_user
: wml user is required when you choose the platformonpremise
api_key
: your IBM Cloud apikey: https://cloud.ibm.com/iam/apikeysproject_id
: you watsonx.ai project id: watsonx.ai project's Manage tab (Project -> Manage -> General -> Details)
-
Run the following to evaluate.
python main.py
The output of the evaluation will be printed in your terminal, and a copy of the results will be saved to /JudgeIt-LLM-as-a-Judge/Framework/data/output
-
Run the following command to exit the python virtual environment:
deactivate
Each type of LLM Judge will accept an excel/csv file as an input file. The repository contains a sample input file for each type of LLM Judge that you can copy, edit, and use to test. They are located at: JudgeIt-LLM-as-a-Judge/Framework/data/input
- RAG Evaluation (Similarity): provide an excel/csv file with a
golden_text
column andgenerated_text
column to compare - RAG Evaluation (Rating): provide an excel/csv file with a
golden_text
column andgenerated_text
column to compare - Multi-turn Evaluation: provide an excel/csv file with the following columns:
previous_question
,previous_answer
,current_question
,golden_rewritten_question
, andrewritten_question
Note: Your input files can contain additional columns than the ones specified above. These columns will have no effect on the LLM Judge and will be perserved in the output file.
The generated results will be saved to an excel/csv file at the location specified in your config file. Each file will contain all the columns provided in the input file.
- For RAG Evaluation (Similarity), the LLM Judge will output a
Grade
andExplanation
. A grade of 0 means the texts are dissimilar, while a grade of 1 means the texts are similar. - For RAG Evaluation (Rating), the LLM Judge will output a
Grade
andExplanation
. A grade of 1 means the texts are dissimilar, a grade of 2 means the texts are partially similar, and a text of 3 means the texts are significantly similar. - For Multi-turn Evaluation, the LLM Judge will output a
Grade
. A grade of 0 means the golden rewritten question and rewritten question are dissimilar, while a grade of 1 means the questions are similar.