how to build an inference engine