pybeebee commited on
Commit
931a078
Β·
verified Β·
1 Parent(s): 3c2307d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -3
README.md CHANGED
@@ -1,3 +1,95 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model:
6
+ - sfairXC/FsfairX-LLaMA3-RM-v0.1
7
+ tags:
8
+ - reward model
9
+ - fine-grained
10
+ ---
11
+
12
+ # MDCureRM
13
+
14
+
15
+ [πŸ“„ Paper](https://arxiv.org/pdf/2410.23463) | [πŸ€— HF Collection](https://huggingface.co/collections/yale-nlp/mdcure-6724914875e87f41e5445395) | [βš™οΈ GitHub Repo](https://github.com/yale-nlp/MDCure)
16
+
17
+
18
+ ## Introduction
19
+
20
+ **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](https://github.com/google-research/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%.
21
+
22
+ 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](https://huggingface.co/collections/yale-nlp/mdcure-6724914875e87f41e5445395). For further details regarding dataset construction, please see our [paper](https://arxiv.org/pdf/2410.23463) and [Github repo](https://github.com/yale-nlp/MDCure). For additional details regarding how to use **yale-nlp/MDCure-Qwen2-7B-Instruct**, please see below.
23
+
24
+ <p align="center">
25
+ <img src="fig1.png" width="90%">
26
+ </p>
27
+ <p align="center" style="margin-top: 0; padding-top: 0;">
28
+ <em>The MDCure pipeline generates diverse multi-document instructions, filters them via fine-grained scoring by MDCureRM, and tunes a base LLM to enhance its multi-document capabilities.</em>
29
+ </p>
30
+
31
+ ## Model Details
32
+
33
+ **yale-nlp/MDCureRM** is initialized from [sfairXC/FsfairX-LLaMA3-RM-v0.1](https://huggingface.co/sfairXC/FsfairX-LLaMA3-RM-v0.1) and trained via a multi-objective reward modeling framework to obtain a MD-specific reward model that evaluates candidate instructions based on six different criteria. These criteria capture both the overall quality of the instruction-response pairs and their effectiveness in handling multi-document content. Using MDCureRM via a fine-grained RM-as-a-Judge mechanism enables us to yield high-quality training data.
34
+
35
+ ## Requirements
36
+
37
+ We recommend using the latest version of HF Transformers, or any `transformers>=4.45.0`, to avoid any potential errors when using this model.
38
+
39
+ ## Quickstart
40
+
41
+ Below we provide a code snippet demonstrating how to load the tokenizer and model and score a candidate instruction. We strongly recommend to format the instruction input as shown to maintain consistency with the format of the data used during training of MDCureRM. As the model outputs values normalized to the 0-1 range, we scale outputted scores up to the 1-5 range for more interpretable results. Relative weighting of fine-grained rewards may be configured as desired to obtain the final score; we reproduce the weights used in our implementation in `reward_weights` below.
42
+
43
+ ```python
44
+ model = AutoModel.from_pretrained("yale-nlp/MDCureRM").to(torch.device("cuda"))
45
+ tokenizer = AutoTokenizer.from_pretrained("yale-nlp/MDCureRM", use_fast=True)
46
+ tokenizer.pad_token = tokenizer.eos_token
47
+
48
+ reward_weights = torch.tensor([1/9, 1/9, 2/9, 2/9, 2/9, 2/9], device="cuda")
49
+
50
+ source_text_1 = ...
51
+ source_text_2 = ...
52
+ source_text_3 = ...
53
+ context = f"{source_text_1}\n\n{source_text_2}\n\n{source_text_3}"
54
+ instruction = "What happened in CHAMPAIGN regarding Lovie Smith and the 2019 defense improvements? Respond with 1-2 sentences."
55
+
56
+ input_text = f"Instruction: {instruction}\n\n{context}"
57
+ tokenized_input = tokenizer(
58
+ input_text,
59
+ return_tensors='pt',
60
+ truncation=True,
61
+ padding=True,
62
+ ).to(torch.device("cuda"))
63
+
64
+ all_six_scores = model(tokenized_input["input_ids"]).squeeze(0) # flatten for dot product
65
+ all_six_scores = all_six_scores*4. + 1. # scale up to 1->5 range
66
+
67
+ final_score = torch.dot(all_six_scores, reward_weights).cpu().item()
68
+ print(score)
69
+ ```
70
+
71
+ ## All MDCure Models
72
+ Beyond MDCureRM, we open-source our best MDCure'd models at the following links:
73
+
74
+ | Model | Huggingface Repo | Description |
75
+ |---------------------------|---------------------|------------------------------|
76
+ | **MDCure-FlanT5-Base** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-FlanT5-Base) | **FlanT5-Base** fine-tuned with MDCure-72k |
77
+ | **MDCure-FlanT5-Large** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-FlanT5-Large) | **FlanT5-Large** fine-tuned with MDCure-72k |
78
+ | **MDCure-Qwen2-1.5B-Instruct** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-Qwen2-1.5B-Instruct) | **Qwen2-1.5B-Instruct** fine-tuned with MDCure-72k |
79
+ | **MDCure-Qwen2-7B-Instruct** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-Qwen2-7B-Instruct) | **Qwen2-7B-Instruct** fine-tuned with MDCure-72k |
80
+ | **MDCure-LLAMA3.1-8B-Instruct** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-LLAMA3.1-8B-Instruct) | **LLAMA3.1-8B-Instruct** fine-tuned with MDCure-72k |
81
+ | **MDCure-LLAMA3.1-70B-Instruct** | [πŸ€— HF Repo](https://huggingface.co/yale-nlp/MDCure-LLAMA3.1-70B-Instruct) | **LLAMA3.1-70B-Instruct** fine-tuned with MDCure-72 |
82
+
83
+ ## Citation
84
+
85
+ If you find our work useful, please cite our paper as:
86
+
87
+ ```bibtex
88
+ @article{liu2023mdcure,
89
+ title={MDCure: A Scalable Pipeline for Multi-Document Instruction-Following},
90
+ author={Gabrielle Kaili-May Liu and Bowen Shi and Avi Caciularu and Idan Szpektor and Arman Cohan},
91
+ journal={arXiv preprint arXiv:2410.23463},
92
+ year={2024},
93
+ url={https://arxiv.org/abs/2410.23463}
94
+ }
95
+ ```