A method is given that \inverts" a logic grammar and displays it from the point of view of the logical form, rather than from that of the word string. LR-compiling techniques are used to allow a recursivedescent generation algorithm to perform \functor merging" much in the same way as an LR parser performs pre x merging. This is an improvement on the semantic-head-driven generator that results in a much smaller search space. The amount of semantic lookahead can be varied, and appropriate tradeo points between table size and resulting nondeterminism can be found automatically. This can be done by removing all spurious nondeterminism for input su ciently close to the examples of a training corpus, and large portions of it for other input, while preserving completeness. 1 1 I wish to thank greatly Gregor Erbach, Jussi Karlgren, Manny Rayner, Hans Uszkoreit, Mats Wir en and the anonymous reviewers of ACL, EACL, IJCAI and RANLP for valuable feedback on previous versions of this article. Special credit is due to Kristina Striegnitz, who assisted with the implementation.Parts of this article have previously appeared as (Samuelsson 1995). The presented work was funded by the N3 \Bidirektionale Linguistische Deduktion (BiLD)" project in the Sonderforschungsbereich 314 K unstliche Intelligenz | Wissensbasierte Systeme.