This repo contains a proxy-centric alignment framework (C-3PO) that bridges the gap between retrievers and LLMs. Instead of modifying existing components in RAG, C-3PO introduces multi-agent system within a lightweight proxy model to simulate humen-like behaviors that optimizes the entire RAG pipeline while maintaining plug-and-play compatibility.

For C-3PO (also works for LLM server)
conda create -n c3po python=3.11
conda activate c3po
pip install -r requirements.txt
For Retrieval (dense model)
conda create -n faiss python=3.11
conda activate faiss
pip install -r retrieval_requirements.txt
Please download the following models from huggingface:
Qwen2-0.5B
Qwen2-1.5B
Qwen2-72B-Instruct
contriever-msmarco
Download preprocessed passage data of the wikipedia 2018 dump.
cd ./C-3PO/deploy_servers/retrieve_server/wiki18
wget https://dl.fbaipublicfiles.com/dpr/wikipedia_split/psgs_w100.tsv.gz
Then, download the embedded passages. We use Contriever-MSMARCO.
cd ./C-3PO/deploy_servers/retrieve_server/wikipedia_embeddings
wget https://dl.fbaipublicfiles.com/contriever/embeddings/contriever-msmarco/wikipedia_embeddings.tar
cd ./deploy_servers/llm_server
bash qwen_72b_serve.sh
cd ./C-3PO/deploy_servers/retrieve_server/retrieve_code/wiki18
bash start_wiki18.sh
You can download our ckpt of C-3PO-1.5B or C-3PO-0.5B on the ModelScope.
Our implementation supports two high-performance inference engines: SGLang and vLLM, allowing users to optimize for different deployment scenarios and hardware configurations.
cd ./C-3PO/inference
bash single_model.sh
We collect seed data through tree-structured rollout using Qwen-2-72B-Instruct.
cd ./C-3PO/instruct_sampling_scripts
bash run_72b.sh
We use Llama-Factory as our training framework for sft.
git clone (from llama-Factory)
# we release our training hyper-parameters for easy reproduction.
cd ./C-3PO/train/sft_scripts
bash run_base_packing.sh
This work is built upon several excellent open-source projects. We sincerely thank:
We express our gratitude to all these projects for their outstanding contributions to the open-source community.
If you find our work useful in your research, please consider citing our paper:
@article{chen2025c,
title={C-3PO: Compact Plug-and-Play Proxy Optimization to Achieve Human-like Retrieval-Augmented Generation},
author={Chen, Guoxin and Liao, Minpeng and Yu, Peiying and Wang, Dingmin and Qiao, Zile and Yang, Chao and Zhao, Xin and Fan, Kai},
journal={arXiv preprint arXiv:2502.06205},
year={2025}
}
Your support by starring ⭐ this repository would be greatly appreciated!
$ claude mcp add C-3PO \
-- python -m otcore.mcp_server <graph>