Skip to content

orcalib.rac.rac#

RACModel #

1
2
3
4
5
6
7
8
9
RACModel(
    num_classes,
    *,
    head=SimpleMMOEHead,
    num_memories=None,
    memoryset=None,
    embedding_model=None,
    cross_encoder_model=None
)

Bases: Module

num_parameters property #

num_parameters

Number of trainable model parameters

reset #

reset()

Reset model parameters to before they were trained

predict #

1
2
3
4
5
6
7
predict(
    inpt,
    expected_label=None,
    log=False,
    curate=False,
    feedback_callback=None,
)

Predicts the label for the given input.

evaluate #

evaluate(dataset, log=False, batch_size=64, curate=True)

Benchmarks the model on the given dataset returning a bunch of different metrics.

For dict-like or list of dict-like datasets, there must be a label key and one of the following keys: text, image, or value. If there are only two keys and one is label, the other will be inferred to be value.

For list-like datasets, the first element of each tuple must be the value and the second must be the label.

evaluate_and_explain #

1
2
3
evaluate_and_explain(
    dataset, log=False, plot=False, curate=True
)

Benchmarks the model on the given dataset returning a bunch of different metrics.

For dict-like or list of dict-like datasets, there must be a label key and one of the following keys: text, image, or value. If there are only two keys and one is label, the other will be inferred to be value.

For list-like datasets, the first element of each tuple must be the value and the second must be the label.

inspect_last_run #

inspect_last_run()

Displays information about the memories accessed during the last run (incl weights etc.)

explain #

1
2
3
4
5
6
7
explain(
    prediction_result=None,
    inpt=None,
    interactive=False,
    plot=False,
    pretty_print=False,
)

Like predict but instead of the prediction result, returns an explanation of the prediction (accessed memories etc.)

:param inpt: The input to explain :param plot: If True, will display graphs via matplotlib :param pretty_print: If True, will return a pretty printed string of the explanation. If False, will return a dictionary :param interactive: DISABLED - If True, will display the explanation in an interactive way (e.g. with a GUI)

finetune #

1
2
3
4
5
6
7
8
9
finetune(
    dataset,
    log=False,
    config=TrainingConfig(),
    plot=False,
    show_running_mean=False,
    validation_dataset=None,
    **kwargs
)

Fine-tunes the model on a given dataset.

save #

save(path)

Saves the model to a file using safetensors

load #

load(path)

Loads a model from a safetensors file, verifying that the model is compatible with the current instance