Skip to content

Cache - #71

Draft
geoalgo wants to merge 3 commits into
mainfrom
cache
Draft

Cache#71
geoalgo wants to merge 3 commits into
mainfrom
cache

Conversation

@geoalgo

@geoalgo geoalgo commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@@ -0,0 +1,280 @@
"""SQLite-backed completion and judgement store.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have several concerns for this:

(1) We are not using model/judge/prompt configurations in the index. Maybe this is resolved later but any change to system prompt, in my opinion, should be reflected in a key (like some unique hash maybe)?

(2) instruction_index INTEGER PRIMARY KEY Works just fine for datasets where instruction_index is unique hash key, however if it is an integer for row index at some point, (for example ELO pipeline we have), then different filterings yielding same dataset idx can query the cache even if the language for example is entirely wrong.

(3) Related to (1), UNIQUE(instruction_index, model_A, model_B) does not include the content that is judged. If for example, we use a different temperature for model_A we will still get the old judgement even if the generated output is different.

return pd.read_sql(
"SELECT * FROM completions ORDER BY instruction_index", conn
)
placeholders = ",".join("?" * len(indices))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will fail if len(indices) is too large.

The Limit: 32,766 parameters

If we want to get ~40.000 row this will fail. Need some chunk up loading mechanism (would allow parallization as well)

Comment thread judgearena/generate.py
) -> pd.DataFrame:
# Filter to instructions not already in the shared store
if completion_store is not None:
all_indices = instructions.index.tolist()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should be sure about instructions.index is never changes under the filtering steps (category/language slices etc).

"sr",
"ar",
]
print(f"filtering with languages: {args.languages}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe lets use logging.debug as we are using it before so we keep track of the logs easily (also the users)

pairs = list(
zip(all_indices, model_A_per_row, model_B_per_row, strict=True)
)
cached_df = judgement_store.query(model=args.model)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cached_df contains every cached row for the evaluated model, but it is not restricted to the keys requested by the current run before being concatenated with new_df. This can include stale or out-of-range rows when sample size, language filters, or seed change.

)
row_our_pos_a = np.concatenate(
[our_model_is_position_a, our_model_is_position_a]
annotations, _, prefs = judge_and_parse_prefs(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We give args.swap_mode, if its both, then both annotation and reversed annotation is returned. However from what I know prefs are 2m

We run this function in judge_and_parse_prefs:

def combine_swapped_prefs(prefs_ab: pd.Series, prefs_ba: pd.Series) -> pd.Series:
    """Combine swap_mode='both' prefs into one P(B wins) series: [pref_AB, 1 - pref_BA].

    ``prefs_ab`` are P(B wins) from the AB ordering; ``prefs_ba`` are P(B wins)
    from the swapped BA ordering, so ``1 - prefs_ba`` re-orients them to the AB
    frame before stacking.
    """
    return pd.concat(
        [prefs_ab.reset_index(drop=True), 1 - prefs_ba.reset_index(drop=True)]
    ).reset_index(drop=True)

prefs = combine_swapped_prefs(prefs.apply(_none_to_nan), prefs_reversed)



try:
from textual import work

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add this to pyproject.toml?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants