[论文解读] An Exploration of Approaches to Integrating Neural Reranking Models in Multi-Stage Ranking Architectures
本文评估了三种将卷积神经网络(CNN)重排序器集成到基于Lucene的多阶段排序系统中的方法:通过Apache Thrift暴露PyTorch模型、使用Deeplearning4J将训练好的模型导入Java,以及将CNN编译为带有Thrift接口的独立C++程序。主要发现是,将PyTorch模型封装在Thrift服务中在性能与集成简便性之间实现了最佳平衡,具有极低的开销,且无需复杂的模型迁移或编译过程。
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.
研究动机与目标
- 为应对工业界广泛使用的基于Lucene的架构中日益增长的深度学习模型集成需求,特别是针对生产环境中的搜索系统。
- 探索可行的、高性能的策略,实现基于PyTorch训练的神经网络与基于Java的Lucene搜索引擎之间的集成。
- 从延迟、吞吐量和开发复杂度的角度,比较基于服务的架构、Java内推理和编译为C++的替代部署方案。
- 评估是否可以通过Deeplearning4J将模型移植到Java,或编译为C++,来超越直接暴露PyTorch服务的性能。
提出的方法
- 使用PyTorch(具有Python前端和C/C++后端的深度学习工具包)训练一个用于答案选择的简单CNN。
- 通过Apache Thrift将训练好的CNN暴露为跨语言服务,实现Python(PyTorch)与Java(Lucene)之间的通信。
- 从PyTorch中提取训练好的CNN参数,并使用Deeplearning4J将它们导入基于Java的推理引擎,实现端到端的Java部署。
- 将训练好的CNN编译为一个独立的C++程序,该程序暴露一个Thrift服务,从而在无需Python依赖的情况下实现高性能推理。
- 在台式机和笔记本电脑上,使用延迟和吞吐量指标评估所有三种方法,包括是否使用Thrift服务包装。
- 使用单线程Thrift服务器(TSimpleServer)和Python客户端测量端到端性能,包括序列化开销。
实验结果
研究问题
- RQ1在Lucene流水线中,哪种集成方式——PyTorch服务、基于Java的Deeplearning4J推理,还是编译为C++——能为神经重排序器提供最佳性能(延迟和吞吐量)?
- RQ2Deeplearning4J的Java实现与原生PyTorch及编译为C++的推理在前向传播评估中的性能相比如何?
- RQ3使用Apache Thrift将神经模型暴露为服务所引入的性能开销是多少?该开销在不同后端之间如何变化?
- RQ4CNN的编译C++版本是否能持续优于PyTorch实现?还是PyTorch的Python前端的C后端已将性能差异最小化?
主要发现
- 在台式机上,封装在Thrift服务中的PyTorch模型实现了最高的吞吐量(1226.49 QPS),优于Deeplearning4J和C++编译版本。
- Deeplearning4J的Java实现显著慢于PyTorch,在台式机上仅达到530.4 QPS,表明该库在其默认配置下对推理任务的优化程度较低。
- C++编译模型在台式机上的性能与PyTorch相当(1235.50 QPS),但并未持续优于后者,表明PyTorch的Python前端带来的开销极小。
- 使用Thrift服务包装PyTorch时引入了约6–7%的开销,而包装C++版本时开销为10–24%,且Python的Thrift客户端比C++客户端更高效。
- PyTorch与Deeplearning4J之间的性能差距表明,Deeplearning4J在当前阶段尚未像其他深度学习工具包那样成熟或针对推理工作负载进行充分优化。
- 结果表明,通过Thrift直接暴露PyTorch服务是目前最实用且性能最优的方案,兼顾了开发简便性、性能表现和语言互操作性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。