Skip to main content
QUICK REVIEW

[Paper Review] An Exploration of Approaches to Integrating Neural Reranking Models in Multi-Stage Ranking Architectures

Zhucheng Tu, Matt Crane|arXiv (Cornell University)|Jul 26, 2017
Advanced Database Systems and QueriesComputer Science13 references7 citations
TL;DR

This paper evaluates three approaches to integrating a convolutional neural network (CNN) reranker into a Lucene-based multi-stage ranking system: exposing the PyTorch model via Apache Thrift, importing the trained model into Java using Deeplearning4J, and compiling the CNN into a standalone C++ program with a Thrift interface. The key finding is that wrapping the PyTorch model in a Thrift service offers the best balance of performance and integration simplicity, with minimal overhead and no need for complex model porting or compilation.

ABSTRACT

We explore different approaches to integrating a simple convolutional neural network (CNN) with the Lucene search engine in a multi-stage ranking architecture. Our models are trained using the PyTorch deep learning toolkit, which is implemented in C/C++ with a Python frontend. One obvious integration strategy is to expose the neural network directly as a service. For this, we use Apache Thrift, a software framework for building scalable cross-language services. In exploring alternative architectures, we observe that once trained, the feedforward evaluation of neural networks is quite straightforward. Therefore, we can extract the parameters of a trained CNN from PyTorch and import the model into Java, taking advantage of the Java Deeplearning4J library for feedforward evaluation. This has the advantage that the entire end-to-end system can be implemented in Java. As a third approach, we can extract the neural network from PyTorch and "compile" it into a C++ program that exposes a Thrift service. We evaluate these alternatives in terms of performance (latency and throughput) as well as ease of integration. Experiments show that feedforward evaluation of the convolutional neural network is significantly slower in Java, while the performance of the compiled C++ network does not consistently beat the PyTorch implementation.

Motivation & Objective

  • To address the growing need to integrate deep learning models into production search systems, particularly Lucene-based architectures used in industry.
  • To explore viable, high-performance integration strategies between PyTorch-trained neural networks and the Java-based Lucene search engine.
  • To compare alternative deployment architectures—service-based, in-Java inference, and compiled C++—in terms of latency, throughput, and development complexity.
  • To assess whether model porting to Java (via Deeplearning4J) or compilation to C++ can outperform direct PyTorch service exposure.

Proposed method

  • Training a simple CNN for answer selection using PyTorch, a deep learning toolkit with a Python frontend and C/C++ backend.
  • Exposing the trained CNN as a cross-language service using Apache Thrift, enabling communication between Python (PyTorch) and Java (Lucene).
  • Extracting the trained CNN’s parameters from PyTorch and importing them into a Java-based inference engine using Deeplearning4J for end-to-end Java deployment.
  • Compiling the trained CNN into a standalone C++ program that exposes a Thrift service, enabling high-performance inference without Python dependencies.
  • Evaluating all three approaches using latency and throughput metrics on desktop and laptop machines, with and without Thrift service wrappers.
  • Using a single-threaded Thrift server (TSimpleServer) and a Python client to measure end-to-end performance, including serialization overhead.

Experimental results

Research questions

  • RQ1Which integration approach—PyTorch service, Java-based inference with Deeplearning4J, or compiled C++—delivers the best performance (latency and throughput) for a neural reranker in a Lucene pipeline?
  • RQ2How does the performance of the Deeplearning4J Java implementation compare to native PyTorch and compiled C++ inference for feedforward evaluation?
  • RQ3What is the performance overhead introduced by using Apache Thrift to expose the neural model as a service, and how does it vary across different backends?
  • RQ4Can a compiled C++ version of the CNN consistently outperform the PyTorch implementation, or does the Python frontend’s C-backend minimize performance differences?

Key findings

  • The PyTorch model wrapped in a Thrift service achieved the highest throughput (1226.49 QPS) on the desktop machine, outperforming both the Deeplearning4J and C++ compiled versions.
  • The Deeplearning4J Java implementation was significantly slower than PyTorch, with only 530.4 QPS on the desktop, indicating that the library is less optimized for inference in its default configuration.
  • The C++-compiled model showed comparable performance to PyTorch (1235.50 QPS on desktop), but did not consistently outperform it, suggesting minimal overhead from PyTorch’s Python frontend.
  • Thrift service integration introduced about 6–7% overhead when wrapping PyTorch, and 10–24% overhead when wrapping the C++ version, with the Python Thrift client proving more efficient than the C++ one.
  • The performance gap between PyTorch and Deeplearning4J suggests that Deeplearning4J is not yet as mature or optimized as other deep learning toolkits for inference workloads.
  • The results indicate that direct PyTorch service exposure via Thrift is currently the most practical and performant option, balancing simplicity, performance, and language interoperability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.