2026-07-14 | Maxwell
Goal: Understand RASP-L constituency parsing algorithm and causal mediation
Summary: Understanding loading ...
Work sessions
| In | Out | Task |
|---|---|---|
| 11:45 | 17:30 | RASP-L Algorithm |
| 17:45 | 18:30 | Causal Intervention |
Goals
- RASP-L Diagram, hypothesize minimum number of layers/heads per recursive depth D
- Finish causal abstraction code first pass
Meetings
- None
Summary
- 🟡 [in progress] RASP-L Diagram, hypothesize minimum number of layers/heads per recursive depth D
- Finished pseudocode translation up till Relative Noun phrase shifting
- 🟡 [in progress] Finish causal abstraction code first pass
- Finished patching at specific layer/token
- Next step is calculate metric (e.g. KL-divergence, top logit) for patching at all positions
Work in progress Pseudocode
3 points of info
1. what info is being stored
2. What position is that info being stored
## Setup
POS Tagging
Verb Type sub classification
## Helpers
dpFlat = where does the dp with just the (D)N(Adj) end?
- only matters for Ds and Ns
rcPos = 1 after the dpFlat
hasRC = T if rcPos is a D and has THAT as the category at the rcPos
hb = verb ends at itself or +1 if there's an adv
## Loop
### Loop Vars
dpfull = where the full DP ends, stored at the `D` or `N`
vpe = verb ends at the end of its complement if it has one, stored at `verb`
rce = where does the rel clause end, stored at `that`
cpe = where does the sentential clause end, stored at `that`
### Loop
1. update `dpfull`
1. dpfull = `intuition` should be where we think the RC ends if there is one
2. dpfull = where (dp_has_rc, rce[rc_that_pos], dp_end_flat)
3. Mechanically: have the `D` or `N` position go to the index where the RC `that` is, and check where the `that` ends
1. only applies if there is an RC
2. update `vpe`
1. Intuition
1. a verb ends where its complement ends
1. if the verb is intrans or transitivie in an obj gap rc, then we just keep the original flat_end position
2. if the verb is a transitive, then the verb phrase ends at the end of the dp complement
3. if the verb is a VP_CP, then the verb phrase ends at the end of the cp
2. Mechanically
1. dpfull_at_hb1 = look at the `D`/`N` end of the dp after the verb
2. cpe_at_hb1 = look at the `that` which stores the end of the CP
3. update `rce`
1. Intuition
1. if you are a VP_CP `that` then ignore the update
2. two types of `rce`, either `subj_gap` or `obj_gap`
1. `subj_gap`: "that knows a cat ..."
1. the end of the `rc` is stored in the end of the `vpe`
2. look at the verb to your right +1 over, and take its ending
2. `obj_gap`: "that a cat ... knows"
1. the end of the `rc` is the position of the verb
2. the position of the embedded verb is the dpfull + 1
3. mechanically: look for the dpfull by looking +1 over, then add 1 to be the ending
4. update `cpe`
1. intuition
1. a `cp` ends at the end of the VP of the sentence
2. Hop to the verb first using the `dpfull` + 1
3. Hop to the end of the vp using vpe stored at `dpfull + 1`
## Calculating depth
Goal is to aggregate all the information from rce and cpe into a single `e`
1. Intuition
1. `e` if you are a `that` which opens a relative clause
2. `cpe` if you are a `that` which opens a full sentential complement
3. else for all other words, just don't care
4. depth is the number of unclosed `(`
1. unclosed is the `end` index is > my current index\
2. Why is this called a stab?
1. imagine a ribbon going from each open that to closed `)`, well how many ribbons do you "stab" through?
## Displacement
1. Adverb displacement
1. `d_adv` = +1 if you are a verb and next to you is an adverb, -1 if you are an adv and there is a verb to your right, 0 otherwise
2. CP displacement
1. `span_clause` is the length of complement (e - idx) + 1
2. for each depth
1. -1 if you're non-`THAT`
2. shift over `span_clause - 1`
3. `d_nprel_core` = how much to shift forward the noun and adj in RC
1. the noun also needs to swap with the relativizer `that`
2. we calculate how long is the RC in front of us
3. Add that to the displacement for `d_nprel_core`
4. If an adjective exists, also place the shift together
4. `d_nprel_inside` how much to shift the complements back
1. Shift either by 1 or 2 depending on if there is an adjective
2. You are a "that"
1. if adj, then you should shift over 2x
2. if just noun you should shift over