-
Notifications
You must be signed in to change notification settings - Fork 299
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
Purpose of method "foreach" in class CallFormula #217
Comments
Hi! The parent abstract class However, it looks like the |
Thanks for the explanations. However, I can't see yet where |
The Executor can use the I found |
Thanks again.- I'm at the chapter Batch Learning of the tutorial now, trying to understand the corresponding parts of the sempre code. The classes
Does this mean an anchored rule is applicable only if a (sub)span of tokens matches the phrase of the rule's definition exactly (and not just a rhs category) - and any rule without that property is floating? Thanks |
The anchored vs floating distinction is only applicable to the FloatingParser. Other parsers (e.g., BeamParser) assume that all rules are anchored.
|
Thanks for your elaborate explanation! |
|
Thanks again. The background of all my questions that I would like to create a plugin for an existing NLP java application that enhances it with sempre functionality. That requires some deeper understanding of the code. As I see, the real entry point to sempre is not the |
You might not need to understand the ruby script in detail. The ruby script is just a tool for creating a Java command (or multiple commands) to run. From any ruby command in README or TUTORIAL, you can add |
Thanks again. That will save me some time.
Could you please tell me if I understand the following points correctly:
|
Regarding rule computation: while one could freshly compute the |
Thanks again, ppasupat. While I get the idea, I can't seem to find where this recursive gathering of features and calculating of scores is actually located in the code. The class |
Background The method (Note: Let's use The Tracing the method calls from Feature extraction and scoring Feature extraction and scoring are actually not done recursively (sorry for my confusion earlier). Rather, it uses dynamic programming. Let's say a derivation A has one child B, A has local features {a1, a2}, and the total score of all features in B (including the features of its descendants) is already computed and stored in B.score. Then the total score of A, A.score, can be computed as A.score = params.getWeight(a1) + params.getWeight(a2) + B.score. The The In Note that this dynamic programming method only works for linear models (which SEMPRE uses). A model that consider interactions between features would not work. |
Thank you! With your explanations and further studying of the code I now believe to have understood the following:
Please correct me if I'm wrong. |
Yes, these are all correct. Different parsers might construct logical forms in different orders (e.g., the second stage of FloatingParser does not care about |
Thanks. Next thing will be to investigate the implementation of the math behind it, the actual calculation of parameters and probabilities. |
So I'm trying to get to the core of the math behind the lerning process. I've brushed up my knowledge on Stochastic Gradient Descent, but have problems mapping it to the code. The main method here is apparently
which looks like the weights are updated here (but with the constant |
Objective function and gradient
How all this is done in the code
|
A question about how to tell a |
Is it save to say, that for parsing relatively simple utterances into logical forms that are meant to be executed by |
Using the BeamParser should be sufficient for the parser. For the features, the
(Line 1093 in the |
Thanks for the hint. I was asking because I'd like to offer the user a reasonable selection of Features to choose from via checkboxes in my GUI. I'd also like to add a short description to of each Feature to the GUI.
registers appliance of |
Feature firing in SEMPRE is pretty complicated due to legacy reasons.
|
I'm back at investigating the features. |
The types of POS tags depend on the The POS tags returned by CoreNLP are the based on the model used, with the default using Penn Treebank tags. The class CoreNLPAnalyzer postprocesses some of the tags (e.g., marking auxiliary verbs), and more postprocessing could be hacked in there. |
Thanks. I will think over if I need this feature. It's probably more relevant for database queries than for the cases the |
Shouldn't it be possible to map Strings to categories, e.g.
as a part/base of a more complex grammar? In my application, using these rules, these city names aren't recognized. |
Could you try changing the rules to look like:
|
I had tried this; I then get:
(rest of the error message is referring to classes in my application) |
The current grammar looks like this:
and manages to parse e.g. "from munic" into "(string "place of departure:munic")
|
|
Thanks. With your hint, I have the grammar now set up that way:
The idea is to extract the main info from a passenger's utterance, who wants to order a ticket. There is still room for misunderstanding, e.g. "....preferably not by train.... " would still be parsed as "by train", but I'm planning to take care of this by sempre's learning capabilities.
The format created this way apparently can't be read with the |
Importing the trained parameters is the intended way. The params are saved in the experiment directory after training in the normal batch learning mode (where you supply the dataset files). From the interactive prompt mode (what you get when using the |
Thanks. In your tutorial, you use the example
and point out:
Now please assume that I'd like sempre to learn the order of operations (multiplication having precedence over addition). What would be a recommendable feature representation here? The |
...or maybe the |
To learn the order or operations, I think a more complex feature needs to be defined (e.g., depth of the derivation tree, or a binary feature indicating if the "add" rule was used in any child of the "multiple" rule). Such an ambiguity doesn't often occur in factoid questions, so there aren't features dealing with it. |
For some of the intended use cases I'd like to create and export training examples
If I have several examples in the same file, are there additional rules for correct fromatting to make them readable? E.g. seperators between the examples? Would this format be ok?
|
The additional spaces should be fine. Comments can also be added: begin the comment with |
Thanks for this confirmation. I'm back at the earlier example of a passenger ordering a ticket
or
Is there a way (a function) to write rules that create a list from non-list type of values? |
Probably I should try to write a sempre function that does this, but am a bit out of practice when it comes to coding. Would it have to look approximately like this:
? |
The code you have looks about right. New SemanticFn should be added to the SEMPRE code locally. SEMPRE uses reflection to resolve the name of the SemanticFn, so the SemanticFn has to be inside the SEMPRE library. |
Thanks. I'm back at trying to get a better understanding of the Features you listed earlier. Probably for simple subjects like the ticket order I won't need them all, but still: What does the |
Looks like skipPos is defined here. It's only defined on SelectFn, which selects a certain child as the output. It seems like skipPos looks at the children that were not chosen, and combine the part-of-speech of the tokens under them. Not sure how helpful this feature is in general. This seems pretty task-specific. |
Thanks. I'm trying to apply a grammar using the
So I have to add the
Does this look reasonable? Thanks |
This looks reasonable, though you should start the for loop (in |
Thanks! I'm back a t the features. I'm afraid I could get an intuitive understanding of what they do/represent only for the |
I don't think it's documented anywhere. When I was using SEMPRE (mostly the tables package) I defined my own features and didn't use any of the default ones. That said, I had some partial notes on what each feature does here:
|
Thanks for explaining!
did you mean the "softmax function" https://en.wikipedia.org/wiki/Softmax_function ? |
Yes, that's a softmax over the scores. |
Thanks.- In the internal handling of the machine learning algorithms, is there an any concept of negative training examples? Or does any result not "accepted" by the user implicitly count as negative? |
Hi,
I'm trying to get some deeper insight in the code of sempre.
For the moment, I'm looking at the simple Java logical forms
and their execution by the class JavaExecutor-
The class CallFormula features the method "forEach". I can't see
its exact purpose. Intuitively, I think it manages the recursive
decomposition of a more complex CallFormula, and I guess the
Boolean returned by func says if the base case of the recursion is
reached. But again, I don't get exactly how. Also it seems that this foreach
method is not even used in the JavaExecutor's methods execute and
processFormula, that apparently are responsible for the execution. Can someone help me to understand the logic behind all this please? Thanks!
The text was updated successfully, but these errors were encountered: