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
Show file tree
Hide file tree
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
add llm-aggrefact experiment notebook
  • Loading branch information
sfc-gh-dhuang committed Dec 5, 2024
commit 35432e79a0bfc293b5c1e50b37ffa95cb6903057
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
from typing import Any, List, Tuple

from datasets import load_dataset
import ir_datasets
import matplotlib.pyplot as plt
import pandas as pd
Expand All @@ -13,6 +14,43 @@
from trulens.feedback import GroundTruthAggregator


def generate_balanced_llm_aggrefact_benchmark(split="test", random_seed=42):
llm_aggrefact_dataset = load_dataset("lytang/LLM-AggreFact")

# Convert to pandas DataFrame
df = pd.DataFrame(llm_aggrefact_dataset[split])

# Initialize an empty list to store balanced DataFrames
balanced_dfs = []

# Iterate over each unique dataset
for dataset_name in df["dataset"].unique():
# Filter the DataFrame for the current dataset
df_subset = df[df["dataset"] == dataset_name]

# Count the number of instances for each class
class_counts = df_subset["label"].value_counts()

# Determine the minimum count between the two classes
min_count = class_counts.min()

# Sample min_count instances from each class
df_balanced = (
df_subset.groupby("label")
.apply(lambda x: x.sample(min_count, random_state=random_seed))
.reset_index(drop=True)
)

# Append the balanced DataFrame to the list
balanced_dfs.append(df_balanced)

# Concatenate all balanced DataFrames into a final DataFrame
final_balanced_df = pd.concat(balanced_dfs, ignore_index=True)

# Display the balanced DataFrame
return final_balanced_df


def generate_summeval_groundedness_golden_set(
file_path: str, max_samples_per_bucket: int = 200
):
Expand Down

Large diffs are not rendered by default.

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/trulens/core/feedback/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def run(

else:
assert isinstance(
result_val, (int, float, list)
result_val, (int, float, list, dict)
), f"Feedback function output must be a float or an int, a list of floats, or dict but was {type(result_val)}."
feedback_call = feedback_schema.FeedbackCall(
args=ins, ret=result_val, meta=meta
Expand Down
Loading