Role-RL: Online Long-Context Processing with Role Reinforcement Learning for Distinct LLMs in Their Optimal Roles

Lewei He, Tianyu Shi, Pengran Huang, Bingzhi Chen, Qianglong Chen, Jiahui PanarXiv 2024 · DOI

Abstract

Processing massive, real-time streaming transcripts (e.g., live e-commerce) presents a significant challenge for Large Language Models (LLMs) due to context window limitations, high costs, and varying model strengths. We present Role-RL, a framework that decomposes long-context processing into specialized roles and uses reinforcement learning to dynamically assign the optimal LLM to each sub-task. By matching model "personalities" to specific requirements, Role-RL achieves a 93.2% average recall while reducing operational costs by approximately 80% compared to monolithic high-tier model deployments.

Introduction

The rise of 24/7 streaming content—from live shopping to automated news—creates a bottleneck for real-time information extraction. Standard LLMs often suffer from the "lost in the middle" phenomenon in long documents and are frequently too slow or expensive for continuous processing. Furthermore, the rapid proliferation of models (GPT-4, Claude, Llama, etc.) makes manual pipeline optimization a moving target, as each model possesses unique strengths in reasoning, formatting, or efficiency.

Methods

Role-RL addresses these challenges through a two-pronged approach: an Online Long-context Processing (OLP) pipeline and a Reinforcement Learning-based Role Manager.

The Role-RL architecture integrates an LLM pool with a specialized OLP pipeline, managed by an RL agent and an Advisory Board.

The OLP pipeline splits the input stream into semantic chunks and processes them through six specialized roles:

  1. Topic Finder & Locator: Identifies and timestamps specific subjects.
  2. Topic Locator: Finds the exact indices for identified topics.
  3. Relationship Checker: Manages redundancy by merging or deleting topics.
  4. Content Organizer: Summarizes content into structured aspects (e.g., Price, Description).
  5. Format Checker & Chunk Splitter: Ensures clean output and manages transitions between chunks to prevent context loss.

The Role Manager is a Q-learning agent that selects the best LLM for each role from a pool. It is guided by an Advisory Board of high-performing models that evaluate "worker" outputs. The agent optimizes a reward function $R = \text{accuracy} - (\text{cost} \times k_1) - (\text{latency} \times k_2)$, ensuring the system finds the most cost-effective model that maintains high accuracy.

Datasets and Task Description

The system was evaluated on OLP-MINI, a new benchmark of 600 live e-commerce transcripts from TikTok and Alibaba. The task involves extracting structured product details from raw transcripts.

Example of the OLP task: converting raw transcript chunks into structured product descriptions with specific categories like Price and Order Urging.

Additional testing on the LongBench dataset (MultiNews and LSHT) demonstrated the framework's generalizability across different languages and domains.

Key Results and Insights

  • Efficiency and Accuracy: Role-RL achieved a 93.2% recall on OLP-MINI while slashing costs by 79.4%. On LongBench, the OLP pipeline improved recall by 53.6 percentage points over standard techniques.
  • Model Specialization: The RL agent successfully identified "sweet spots"—for instance, delegating Relationship Checking to smaller models like Llama-3-8b, which performed comparably to GPT-4o at a fraction of the cost.
  • Rapid Adaptation: The system effectively "promotes" models like Claude-3-Opus to complex tasks while delegating simpler formatting tasks to more efficient models within a few hundred rounds of learning.

Conclusion

While Role-RL significantly optimizes long-context processing, the use of an Advisory Board for evaluation still incurs some overhead. Future work will explore periodic board consultation and expanding roles to handle multimodal inputs like direct video and audio streams.

Summary updated

Abstract

Large language models (LLMs) with long-context processing are still challenging because of their implementation complexity, training efficiency and data sparsity. To address this issue, a new paradigm named Online Long-context Processing (OLP) is proposed when we process a document of unlimited length, which typically occurs in the information reception and organization of diverse streaming media such as automated news reporting, live e-commerce, and viral short videos. Moreover, a dilemma was often encountered when we tried to select the most suitable LLM from a large number of LLMs amidst explosive growth aiming for outstanding performance, affordable prices, and short response delays. In view of this, we also develop Role Reinforcement Learning (Role-RL) to automatically deploy different LLMs in their respective roles within the OLP pipeline according to their actual performance. Extensive experiments are conducted on our OLP-MINI dataset and it is found that OLP with Role-RL framework achieves OLP benchmark with an average recall rate of 93.2% and the LLM cost saved by 79.4%. The code and dataset are publicly available at: https://anonymous.4open.science/r/Role-RL.
BibTeX
@misc{he2024role,
  author = {Lewei He and Tianyu Shi and Pengran Huang and Bingzhi Chen and Qianglong Chen and Jiahui Pan},
  title = {{Role-RL: Online Long-Context Processing with Role Reinforcement Learning for Distinct LLMs in Their Optimal Roles}},
  year = {2024},
  eprint = {2409.18014},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.18014},
}
Figure