-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GrammaticalExpression evaluate() and FOL statements #52
Comments
I was thinking about this problem and ultimately came to a solution, albeit perhaps a messy one, at https://github.com/Ashvin-Ranjan/ultk/tree/main/src/examples/family. The way it works is by having referents contain 4 attributes: their name, their gender, their mother, and their father. The mother and father are both also Referents (once the relations reach outside of the scope of the data they just become
With this system the expression for checking if a referent is the origin's mom would be: This is a very hacked together way of doing it but the basic tests in https://github.com/Ashvin-Ranjan/ultk/blob/main/src/examples/family/scripts/test.py show that it seems to work. |
I do agree things need to be changed, but I am not completely sure what. I am wondering if support for something like I was also able to work together some code to generate expressions and they seem to match natural languages. I put a quick test for English together at https://github.com/Ashvin-Ranjan/ultk/blob/main/src/examples/family/outputs/natural_languages.yml. I ended up expanding this to include priors from KR2012 and create a final plot, though I believe I made a mistake somewhere since English appears to be far away from optimal on the graph. |
I stand corrected re: changing the grammar. I was able to reimplement KR2012's grammar as described without changing ULTK at all (except for a minor type check in Rule.from_callable that was already anticipated): https://github.com/CLMBRs/ultk/blob/kinship/src/examples/kinship/grammar/full.py. I learned a lot about ULTK grammar in the process 🙂 Some of those lessons, which might be obvious, but for posterity:
@Ashvin-Ranjan So I'll close this issue, as I'm convinced there isn't one! Happy new year 🥳 |
Thanks, both! Really great discussion, and glad to hear y'all have found two solutions that both seem very natural. I'll ask one or both of you for a summary in conversation sometime in January, but also wanted to quickly mention two related things that came up when I was first working on (1) In (2) In an application that some CLMBRs are working on (to the RASP-L language for transformers), they also used a primitive |
In GrammaticalExpression.evaluate, when we construct self.meaning, we only call the self.func on each referent in the universe, and pass no other args: https://github.com/CLMBRs/ultk/blob/main/src/ultk/language/grammar.py#L154
I've been thinking about how to handle the kinship domain, from Kemp and Regier (2012), which is expressed in FOL expressions:
Maybe I haven't fully grocked Meaning as a mapping yet, but it's not clear to me how we can interpret (evaluate) FOL expressions as they're encoded in this figure without referencing the Universe. E.g., it seems the way to implement the func for 'sister' is:
If so, then I think the GrammaticalExpression.evaluate function might need to be changed so that when it's constructing a meaning on line 154 it calls the func on not just each referent but also the Universe. Alternatively store a Universe in each GrammaticalExpression as its self.universe, but that seems like it could cause inefficiency (?)
I took a look at the learn_quant PR branch, and it wasn't clear to me I should the quantifier grammar out of the box for this, but maybe I'm wrong?https://github.com/CLMBRs/ultk/blob/9e6ef27e56f466e5edca630ee3f291bee02164c6/src/examples/learn_quant/grammar.yml
The text was updated successfully, but these errors were encountered: