Skip to contents

Fine-tuning objectives (Kamath Eq 4.3-4.4)

Usage

morie_kamath_ch4_full_finetune_obj(Phi, x, y)

morie_kamath_ch4_lora_obj(Theta, Phi_0, x, y)

Arguments

Phi

Function (x_i, y_prefix, y_t) -> probability.

x

Contexts.

y

Target sequences.

Theta

Adapted model.

Phi_0

Frozen base model.

Value

List with estimate, per_pair, n_tokens.

Details

One core serves both Python modules exactly as km057 imports km056's _sequence_objective: km056 -> morie_kamath_ch4_full_finetune_obj, km057 -> morie_kamath_ch4_lora_obj (the same sum scored under Phi_0 + dPhi). Larger is better – this is the objective, not a loss.

Examples

morie_kamath_ch4_full_finetune_obj(function(xi, p, t) 0.5, list("doc"),
    list(list("a", "b")))
#> $estimate
#> [1] -1.386294
#> 
#> $per_pair
#> [1] -1.386294
#> 
#> $n_tokens
#> [1] 2
#> 
#> $n
#> [1] 1
#> 
#> $method
#> [1] "full-parameter fine-tuning objective (Kamath Eq 4.3)"
#>