Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Invalid compilation caused by categorical Aggregate with default=None #25

@langosco

Description

@langosco

Raising a separate issue to track a problem mentioned in #11.

Programs containing multiple categorical aggregates can sometimes compile invalidly (i.e. the output of the compiled model doesn't match the output of the rasp program).

This probably happens because the value None is just propagated forward unchanged in the rasp program. In the compiled model, Nones are converted to 0s, on which further operations can be performed (if I'm not mistaken).

Example:

from tracr.rasp import rasp
from tracr.compiler import compiling, validating

sel = rasp.Select(rasp.indices, rasp.tokens, rasp.Comparison.EQ)
sop = rasp.Aggregate(sel, rasp.indices)
program = rasp.Aggregate(sel, sop)


model = compiling.compile_rasp_to_model(program, vocab={1,2,3,4}, max_seq_len=5, compiler_bos="BOS")
compiled_output = model.apply(["BOS", 1, 2, 3, 4]).decoded
rasp_output = program([1, 2, 3, 4])


# The output of the compiled model does not match the output of the RASP program:
print(rasp_output)  # [2.0, 3.0, None, None]
print(compiled_output) # ['BOS', 2, 3, 0, 1]

# The validator doesn't catch the error:
print(validating.validate(program, [1, 2, 3, 4])) # []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions