You could have a feedback loop, feeding back compilation errors to the model untill it converges to no errors.
Potentially you could do the same for fact-related questions, by fact checking the result against the (properly indexed) training set and feeding the results back.
I wonder if it would work.