Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TREC DL and LLM AggreFact experiments for relevance benchmark + prompts comparisons and groundedness vs Bespoke Minicheck 7B #1660

Merged
merged 23 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
save
  • Loading branch information
sfc-gh-dhuang committed Nov 25, 2024
commit 7968d5218afdf68605986367bdfc137c92855faf
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
" 1 if label >= 0.5 else 0 for label in qags_xsum_true_labels\n",
"]\n",
"combined_dataset = pd.concat(\n",
" [qags_cnn_dm, qags_xsum, summeval], ignore_index=True\n",
" [qags_cnn_dm, qags_xsum, summeval], ignore_index=False\n",
")\n",
"combined_true_labels = (\n",
" qags_cnn_dm_true_labels + qags_xsum_true_labels + summeval_true_labels\n",
Expand All @@ -123,6 +123,15 @@
"print(f\"Total number of samples: {len(combined_dataset)}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"combined_dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -158,6 +167,9 @@
"from ragas.llms import llm_factory\n",
"from ragas.metrics import faithfulness as faithfulness_ragas\n",
"from trulens.apps.basic import TruBasicApp\n",
"from trulens.core import Feedback\n",
"from trulens.core import Select\n",
"from trulens.feedback import GroundTruthAgreement\n",
"from trulens.providers.openai import OpenAI\n",
"\n",
"OPENAI_LLM_NAME = \"gpt-4o-mini\"\n",
Expand Down Expand Up @@ -233,8 +245,20 @@
" if len(dataset_df) != len(true_labels):\n",
" raise ValueError(\"dataset df must have the same length as labels\")\n",
"\n",
" ground_truth = GroundTruthAgreement(dataset_df, provider=gpt_4o_mini)\n",
"\n",
" f_mae = (\n",
" Feedback(ground_truth.absolute_error, name=\"Mean Absolute Error\")\n",
" .on(Select.Record.calls[0].args.args[0])\n",
" .on(Select.Record.calls[0].args.args[1])\n",
" .on_output()\n",
" )\n",
"\n",
" tru_wrapped_basic_app = TruBasicApp(\n",
" evaluate_func_wrapper, app_name=app_name, app_version=app_version\n",
" evaluate_func_wrapper,\n",
" app_name=app_name,\n",
" app_version=app_version,\n",
" feedbacks=[f_mae],\n",
" )\n",
"\n",
" for i in range(len(dataset_df)):\n",
Expand All @@ -261,26 +285,26 @@
"run_experiment_and_record(\n",
" evaluate_func_wrapper=trulens_groundedness,\n",
" app_name=\"trulens-groundedness\",\n",
" app_version=\"10302024\",\n",
" dataset_df=combined_dataset,\n",
" true_labels=combined_true_labels,\n",
")\n",
"\n",
"run_experiment_and_record(\n",
" evaluate_func_wrapper=ragas_faithfulness,\n",
" app_name=\"ragas-faithfulness\",\n",
" app_version=\"10302024\",\n",
" dataset_df=combined_dataset,\n",
" true_labels=combined_true_labels,\n",
" app_version=\"10312024\",\n",
" dataset_df=combined_dataset[:2],\n",
" true_labels=combined_true_labels[:2],\n",
")\n",
"\n",
"run_experiment_and_record(\n",
" evaluate_func_wrapper=mlflow_faithfulness,\n",
" app_name=\"mlflow-faithfulness\",\n",
" app_version=\"10302024\",\n",
" dataset_df=combined_dataset,\n",
" true_labels=combined_true_labels,\n",
")"
"# run_experiment_and_record(\n",
"# evaluate_func_wrapper=ragas_faithfulness,\n",
"# app_name=\"ragas-faithfulness\",\n",
"# app_version=\"10312024\",\n",
"# dataset_df=combined_dataset,\n",
"# true_labels=combined_true_labels,\n",
"# )\n",
"\n",
"# run_experiment_and_record(\n",
"# evaluate_func_wrapper=mlflow_faithfulness,\n",
"# app_name=\"mlflow-faithfulness\",\n",
"# app_version=\"1032024\",\n",
"# dataset_df=combined_dataset,\n",
"# true_labels=combined_true_labels,\n",
"# )"
]
},
{
Expand Down