You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
Issue #9 introduces a validator to check RASP programs that compile incorrectly.
Here's one case---a RASP program that computes the sum of all inputs up to the current index---in which I think the validator fails (or I've misunderstood how it works):
fromtracr.raspimportraspfromtracr.compilerimportvalidating, compilingdefsum_of_inputs() ->rasp.SOp:
before=rasp.Select(rasp.indices, rasp.indices, rasp.Comparison.LEQ)
means=rasp.Aggregate(before, rasp.tokens) # returns sequence s_i = mean_{j<=i} input_jsums=rasp.SequenceMap(lambdax, y: x*y, means, rasp.indices+1)
returnsumssums=sum_of_inputs()
# The output of the RASP program sums is different that the output of the compiled model:rasp_output=sums([3, 2, 1, 1])
compiled_model=compiling.compile_rasp_to_model(sums, vocab={1,2,3}, max_seq_len=5, compiler_bos="BOS")
compiled_output=compiled_model.apply(["BOS", 3, 2, 1, 1]).decodedprint(rasp_output) # output: [3.0, 5.0, 6.0, 7.0]print(compiled_output) # output: ['BOS', 3, 4, 3, 4]# However, it looks like the validator doesn't catch the error:print(validating.validate(sums, [1, 2, 3])) # returns an empty list