Update README.md
Browse files
README.md
CHANGED
@@ -11,4 +11,62 @@ language:
|
|
11 |
pipeline_tag: text-generation
|
12 |
---
|
13 |
|
14 |
-
Dataset Card for Faro-Yi-9B-DPO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
pipeline_tag: text-generation
|
12 |
---
|
13 |
|
14 |
+
# Dataset Card for Faro-Yi-9B-DPO
|
15 |
+
|
16 |
+
This is the DPO version of [wenbopan/Faro-Yi-9B](https://huggingface.co/wenbopan/Faro-Yi-9B). Compared to Faro-Yi-9B and [Yi-9B-200K](https://huggingface.co/01-ai/Yi-9B-200K), the DPO model excel at many tasks, surpass the original Yi-9B-200K by a large margin.
|
17 |
+
|
18 |
+
| **Metric** | **MMLU** | GSM8K | **hellaswag** | **truthfulqa** | **ai2_arc** | **winogrande** | **CMMLU** |
|
19 |
+
| --------------- | --------- | --------- | ------------- | -------------- | ----------- | -------------- | --------- |
|
20 |
+
| **Yi-9B-200K** | 65.73 | 50.49 | 56.72 | 33.80 | 69.25 | 71.67 | 71.97 |
|
21 |
+
| **Faro-9B** | **68.80** | **63.08** | 57.28 | 40.86 | 72.58 | 71.11 | **73.28** |
|
22 |
+
| **Faro-9B-DPO** | 66.96 | 57.92 | **61.14** | **51.63** | **75.25** | **75.53** | 71.02 |
|
23 |
+
|
24 |
+
|
25 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/62cd3a3691d27e60db0698b0/Oa9QSbXgaYVekrYfgfaiC.png)
|
26 |
+
|
27 |
+
## How to Use
|
28 |
+
|
29 |
+
|
30 |
+
## How to Use
|
31 |
+
|
32 |
+
Faro-Yi-9B-DPO uses the chatml template and performs well in both short and long contexts. For longer inputs under **24GB of VRAM**, I recommend to use vLLM to have a max prompt of 32K. Setting `kv_cache_dtype="fp8_e5m2"` allows for 48K input length. 4bit-AWQ quantization on top of that can boost input length to 160K, albeit with some performance impact. Adjust `max_model_len` arg in vLLM or `config.json` to avoid OOM.
|
33 |
+
|
34 |
+
|
35 |
+
```python
|
36 |
+
import io
|
37 |
+
import requests
|
38 |
+
from PyPDF2 import PdfReader
|
39 |
+
from vllm import LLM, SamplingParams
|
40 |
+
|
41 |
+
llm = LLM(model="wenbopan/Faro-Yi-9B-DPO", kv_cache_dtype="fp8_e5m2", max_model_len=100000)
|
42 |
+
|
43 |
+
pdf_data = io.BytesIO(requests.get("https://arxiv.org/pdf/2303.08774.pdf").content)
|
44 |
+
document = "".join(page.extract_text() for page in PdfReader(pdf_data).pages) # 100 pages
|
45 |
+
|
46 |
+
question = f"{document}\n\nAccording to the paper, what is the parameter count of GPT-4?"
|
47 |
+
messages = [ {"role": "user", "content": question} ] # 83K tokens
|
48 |
+
prompt = llm.get_tokenizer().apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
49 |
+
output = llm.generate(prompt, SamplingParams(temperature=0.8, max_tokens=500))
|
50 |
+
print(output[0].outputs[0].text)
|
51 |
+
# Yi-9B-200K: 175B. GPT-4 has 175B \nparameters. How many models were combined to create GPT-4? Answer: 6. ...
|
52 |
+
# Faro-Yi-9B: GPT-4 does not have a publicly disclosed parameter count due to the competitive landscape and safety implications of large-scale models like GPT-4. ...
|
53 |
+
```
|
54 |
+
|
55 |
+
|
56 |
+
<details> <summary>Or With Transformers</summary>
|
57 |
+
|
58 |
+
```python
|
59 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
60 |
+
|
61 |
+
model = AutoModelForCausalLM.from_pretrained('wenbopan/Faro-Yi-9B-DPO', device_map="cuda")
|
62 |
+
tokenizer = AutoTokenizer.from_pretrained('wenbopan/Faro-Yi-9B-DPO')
|
63 |
+
messages = [
|
64 |
+
{"role": "system", "content": "You are a helpful assistant. Always answer with a short response."},
|
65 |
+
{"role": "user", "content": "Tell me what is Pythagorean theorem like you are a pirate."}
|
66 |
+
]
|
67 |
+
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
68 |
+
generated_ids = model.generate(input_ids, max_new_tokens=512, temperature=0.5)
|
69 |
+
response = tokenizer.decode(generated_ids[0], skip_special_tokens=True) # Aye, matey! The Pythagorean theorem is a nautical rule that helps us find the length of the third side of a triangle. ...
|
70 |
+
```
|
71 |
+
|
72 |
+
</details>
|