LastDance: a Diagnostic-Driven Autoresearch Framework for Retrieval-Augmented Generation with Compact Language Models
Preprint
- 25 July 2026
- preprint
- Published by Elsevier in SSRN Electronic Journal
Abstract
We present LastDance, an autoresearch framework that autonomously discovers optimized Retrieval-Augmented Generation pipelines for compact language models under token budget constraints. The framework guides a coding agent (Claude Code paired with Qwen3-Coder-Next as the underlying coder model) through a proposed project structure comprising three instruction files, a modifiable pipeline file, a fixed evaluation script with diagnostic report generation, and a curated research knowledge base. After each experiment, a diagnostic module classifies every evaluation sample into four failure categories and recommends which pipeline stage to modify next. This helps the agent make research decisions based on diagnostic evidence. The methodology discovered by LastDance, KnapsackRAG, formulates passage selection as a 0/1 integer linear program with cardinality, coverage, and pairwise redundancy constraints. On the NQ Open and TriviaQA validation sets, KnapsackRAG achieves 36.9% and 36.2% relative F1 improvements over the strongest top-k baseline with Qwen2.5-1.5B-Instruct as the generator. The discovered configuration transfers to Llama-3.2-3B-Instruct without modification, yielding 99.3% and 17.3% relative F1 gains on the same two datasets.Keywords
This publication has 11 references indexed in Scilit:
- Shifting from Ranking to Set Selection for Retrieval Augmented Generation2025
- Lost in the Middle: How Language Models Use Long ContextsTransactions of the Association for Computational Linguistics, 2024
- SEER : A Knapsack approach to Exemplar Selection for In-Context HybridQA2023
- Automatic Prompt Optimization with “Gradient Descent” and Beam Search2023
- Integer Programming2020
- Dense Passage Retrieval for Open-Domain Question Answering2020
- Natural Questions: A Benchmark for Question Answering ResearchTransactions of the Association for Computational Linguistics, 2019
- Billion-Scale Similarity Search with GPUsIEEE Transactions on Big Data, 2019
- TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehension2017
- SQuAD: 100,000+ Questions for Machine Comprehension of Text2016