Add implementation for new document inference.