Text Generation
Transformers
Safetensors
English
qwen2
multi-document
long-context
Long Context
conversational
text-generation-inference
Instructions to use yale-nlp/MDCure-Qwen2-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yale-nlp/MDCure-Qwen2-7B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yale-nlp/MDCure-Qwen2-7B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yale-nlp/MDCure-Qwen2-7B-Instruct") model = AutoModelForCausalLM.from_pretrained("yale-nlp/MDCure-Qwen2-7B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Local Apps Settings
- vLLM
How to use yale-nlp/MDCure-Qwen2-7B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yale-nlp/MDCure-Qwen2-7B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yale-nlp/MDCure-Qwen2-7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yale-nlp/MDCure-Qwen2-7B-Instruct
- SGLang
How to use yale-nlp/MDCure-Qwen2-7B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "yale-nlp/MDCure-Qwen2-7B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yale-nlp/MDCure-Qwen2-7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "yale-nlp/MDCure-Qwen2-7B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yale-nlp/MDCure-Qwen2-7B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yale-nlp/MDCure-Qwen2-7B-Instruct with Docker Model Runner:
docker model run hf.co/yale-nlp/MDCure-Qwen2-7B-Instruct
Add library_name and pipeline_tag
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
| 3 |
datasets:
|
| 4 |
- yale-nlp/MDCure-72k
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
-
|
| 8 |
-
- Qwen/Qwen2-7B-Instruct
|
| 9 |
tags:
|
| 10 |
- multi-document
|
| 11 |
- long-context
|
| 12 |
- Long Context
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
# MDCure-Qwen2-7B-Instruct
|
| 16 |
|
| 17 |
-
|
| 18 |
[π 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)
|
| 19 |
|
| 20 |
-
|
| 21 |
## Introduction
|
| 22 |
|
| 23 |
**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%.
|
|
@@ -41,7 +41,9 @@ We recommend using the latest version of HF Transformers, or any `transformers>=
|
|
| 41 |
|
| 42 |
## Quickstart
|
| 43 |
|
| 44 |
-
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 `
|
|
|
|
|
|
|
| 45 |
|
| 46 |
```python
|
| 47 |
model = AutoModelForCausalLM.from_pretrained("yale-nlp/MDCure-Qwen2-7B-Instruct", device_map='auto',torch_dtype="auto")
|
|
@@ -50,7 +52,13 @@ tokenizer = AutoTokenizer.from_pretrained("yale-nlp/MDCure-Qwen2-7B-Instruct")
|
|
| 50 |
source_text_1 = ...
|
| 51 |
source_text_2 = ...
|
| 52 |
source_text_3 = ...
|
| 53 |
-
prompt = f"{source_text_1}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
messages = [
|
| 56 |
{"role": "system", "content": "You are an assistant with strong multi-document processing skills."},
|
|
@@ -78,7 +86,7 @@ We open-source our custom multi-document instruction scoring model, MDCureRM, as
|
|
| 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-
|
| 82 |
|
| 83 |
## Citation
|
| 84 |
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model:
|
| 3 |
+
- Qwen/Qwen2-7B-Instruct
|
| 4 |
datasets:
|
| 5 |
- yale-nlp/MDCure-72k
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
+
license: apache-2.0
|
|
|
|
| 9 |
tags:
|
| 10 |
- multi-document
|
| 11 |
- long-context
|
| 12 |
- Long Context
|
| 13 |
+
library_name: transformers
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
---
|
| 16 |
|
| 17 |
# MDCure-Qwen2-7B-Instruct
|
| 18 |
|
|
|
|
| 19 |
[π 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)
|
| 20 |
|
|
|
|
| 21 |
## Introduction
|
| 22 |
|
| 23 |
**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%.
|
|
|
|
| 41 |
|
| 42 |
## Quickstart
|
| 43 |
|
| 44 |
+
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 `
|
| 45 |
+
|
| 46 |
+
` or `<doc-sep>` to maintain consistency with the format of the data used during training.
|
| 47 |
|
| 48 |
```python
|
| 49 |
model = AutoModelForCausalLM.from_pretrained("yale-nlp/MDCure-Qwen2-7B-Instruct", device_map='auto',torch_dtype="auto")
|
|
|
|
| 52 |
source_text_1 = ...
|
| 53 |
source_text_2 = ...
|
| 54 |
source_text_3 = ...
|
| 55 |
+
prompt = f"{source_text_1}
|
| 56 |
+
|
| 57 |
+
{source_text_2}
|
| 58 |
+
|
| 59 |
+
{source_text_3}
|
| 60 |
+
|
| 61 |
+
What happened in CHAMPAIGN regarding Lovie Smith and the 2019 defense improvements? Respond with 1-2 sentences."
|
| 62 |
|
| 63 |
messages = [
|
| 64 |
{"role": "system", "content": "You are an assistant with strong multi-document processing skills."},
|
|
|
|
| 86 |
| **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 |
|
| 87 |
| **MDCure-Qwen2-7B-Instruct** | [π€ HF Repo](https://huggingface.co/yale-nlp/MDCure-Qwen2-7B-Instruct) | **Qwen2-7B-Instruct** fine-tuned with MDCure-72k |
|
| 88 |
| **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 |
|
| 89 |
+
| **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-72k |
|
| 90 |
|
| 91 |
## Citation
|
| 92 |
|