MDCure is an effective and scalable procedure for generating high-quality multi-document (MD) instruction tuning data to improve MD capabilities of LLMs. Using MDCure, we construct a suite of MD instruction datasets complementary to collections such as
FLAN and fine-tune a variety of already instruction-tuned LLMs from the FlanT5, Qwen2, and LLAMA3.1 model families, up to 70B parameters in size. We additionally introduce
MDCureRM, an evaluator model specifically designed for the MD setting to filter and select high-quality MD instruction data in a cost-effective, RM-as-a-judge fashion. Extensive evaluations on a wide range of MD and long-context benchmarks spanning various tasks show MDCure consistently improves performance over pre-trained baselines and over corresponding base models by up to 75.5%.
We release MDCure datasets of size 12k, 36k, and 72k. We also release MDCureRM and the best MDCure'd model for each architecture/size combination. To access all our models and datasets, please visit our
HF Collection. For further details regarding dataset construction, please see our
paper and
Github repo. For additional details regarding how to use
yale-nlp/MDCure-Qwen2-1.5B-Instruct, please see below.
Below we provide a code snippet demonstrating how to load the tokenizer and model and generate content in response to an input context concerning multiple source documents and a related question or instruction. We strongly recommend to separate the texts and/or instruction using `
1model = AutoModelForCausalLM.from_pretrained("yale-nlp/MDCure-Qwen2-1.5B-Instruct", device_map='auto',torch_dtype="auto")
2tokenizer = AutoTokenizer.from_pretrained("yale-nlp/MDCure-Qwen2-1.5B-Instruct")
3
4source_text_1 = ...
5source_text_2 = ...
6source_text_3 = ...
7prompt = f"{source_text_1}
8
9{source_text_2}
10
11{source_text_3}
12
13What happened in CHAMPAIGN regarding Lovie Smith and the 2019 defense improvements? Respond with 1-2 sentences."
14
15messages = [
16 {"role": "system", "content": "You are an assistant with strong multi-document processing skills."},
17 {"role": "user", "content": prompt},
18 ]
19
20text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
22
23generated_ids = model.generate(**model_inputs, max_new_tokens=512)
24generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)]
25
26response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
27print(response)
We open-source our custom multi-document instruction scoring model, MDCureRM, as well as our best MDCure'd models at the following links:
1@article{liu2024mdcure,
2 title={MDCure: A Scalable Pipeline for Multi-Document Instruction-Following},
3 author={Gabrielle Kaili-May Liu and Bowen Shi and Avi Caciularu and Idan Szpektor and Arman Cohan},
4 journal={arXiv preprint arXiv:2410.23463},
5 year={2024},
6 url={https://arxiv.org/abs/2410.23463}
7}