pulsatrix 1.1.0
Loading...
Searching...
No Matches
pulsatrix::TokenRelevanceShift Class Reference

Collects RelevanceDiff results over a dataset by input token: which tokens a fine-tune made the model rely on more, and which less. More...

#include <fine_tune_diff.hpp>

Public Member Functions

void add (const Tensor &token_ids, const RelevanceDiff &diff)
 Adds one batch: token_ids (N, L) and a diff whose relevance is (N, L). Each score is divided by its sample's tuned or base score, so samples weigh alike.
 
std::vector< TokenShift > top (int64_t n, bool decrease=false, int64_t min_count=1) const
 The n tokens with the largest mean increase (or, with decrease, the largest mean decrease), among those seen at least min_count times.
 
std::vector< TokenShift > all () const
 Every token seen, by id.
 

Detailed Description

Collects RelevanceDiff results over a dataset by input token: which tokens a fine-tune made the model rely on more, and which less.

Member Function Documentation

◆ add()

void pulsatrix::TokenRelevanceShift::add ( const Tensor &  token_ids,
const RelevanceDiff &  diff 
)

Adds one batch: token_ids (N, L) and a diff whose relevance is (N, L). Each score is divided by its sample's tuned or base score, so samples weigh alike.

Exceptions
std::invalid_argumentif the shapes differ.

◆ all()

std::vector< TokenShift > pulsatrix::TokenRelevanceShift::all ( ) const

Every token seen, by id.

◆ top()

std::vector< TokenShift > pulsatrix::TokenRelevanceShift::top ( int64_t  n,
bool  decrease = false,
int64_t  min_count = 1 
) const

The n tokens with the largest mean increase (or, with decrease, the largest mean decrease), among those seen at least min_count times.


The documentation for this class was generated from the following file: