models icon indicating copy to clipboard operation
models copied to clipboard

linked feature

Open jingcangcang opened this issue 9 years ago • 4 comments

I am confused about the linked feature. The linked feature have these contributes: name/fml/embedding_dim/size/source_component/source_translator/source_layer, i am confused about the embedding_dim and the source_layer_size, and what relationshilps between the features given by fml and the source_layer of source_component. And source_translator "shift-reduce-step" means? Thanks.

jingcangcang avatar Apr 18 '17 08:04 jingcangcang

Good questions, I agree we should document this better.

  • embedding_dim is the dimesionality of the embedding of the feature. So when you pull a linked feature, say from tagger to parser, it gets re-embedded (basically multiplied by a matrix) by default. If you do not want to re-embed, set embedding_dim = -1

  • The lifecycle of a linked feature is as follows. First, a number is produced by a feature defined in fml. Then that number is tranformed by a translator, say the output is STEP. So then you look into the neural network activations of source_layer of source_component at step STEP. Those activations (re-embedded as mentioned above) are the linked features.

  • A practical example: you can set fml to be bias(0), which produces 0, and then set translator to be history, thus translating 0 into the total number of steps in that component. So then you pull the last activation of the source_component, without having to explicitly define how many steps were there. (this can be useful, for example, when you are building a seq2seq architecture)

  • shift-reduce-step returns, given a token index, the neural network activation from when it was placed on the stack. The corresponding fml to use here is typically stack.focus or stack(1).focus to basically pull the representations of top two tokens on the stack.

bogatyy avatar Apr 18 '17 16:04 bogatyy

@bogatyy Thanks.In the lifecycle of a linked feature, I am still confused about " First, a number is produced by a feature defined in fml. Then that number is tranformed by a translator, say the output is STEP", for example, the first component is shift-only transition, the second component is tagger, and the fml of linked features of the second component is "stack.focus stack(1).focus",can you explain how this work?the second component input of each time step are(is this similar to each time-step)?how they connect to the first component?

And the differences of translators "identity","reverse-token","history", can you explain this use an example?

jingcangcang avatar Apr 19 '17 02:04 jingcangcang

(1) stack.focus cannot be used with neither shift-only nor tagger. It points to the top token currently on the stack. So it only works with 'arc-standard' transition system (i.e. for the parser). https://en.wikipedia.org/wiki/Shift-reduce_parser

(2) "identity" just outputs whatever "fml" produced. So you get IDENTITY(N) = N. "reverse-token" counts from the end of the sentence. So REVERSE-TOKEN(N) = COUNT_TOKENS(INPUT) - N "history" is similar, but counts from the end of the sequence of steps. Notice the difference to reverse-token: for example, a shift-reduce parser on L tokens will have 2*L+1 steps.

bogatyy avatar Apr 20 '17 15:04 bogatyy

@bogatyy
linked_feature { name: "features" fml: "input.focus" embedding_dim: -1 size: 1 source_component: "tagger-features" source_translator: "identity" source_layer: "logits" } in this case, this linked feature means? "identity" means outputs is "input.focus", how can this relate activation of "logits" layer of "tagger-features"?

jingcangcang avatar Apr 21 '17 02:04 jingcangcang