Update README.md
Browse files
README.md
CHANGED
@@ -1,13 +1,59 @@
|
|
1 |
---
|
|
|
|
|
|
|
2 |
license: mit
|
3 |
datasets:
|
4 |
- wenbopan/Chinese-dpo-pairs
|
5 |
- Intel/orca_dpo_pairs
|
6 |
-
|
7 |
-
-
|
8 |
-
- zh
|
9 |
pipeline_tag: text-generation
|
10 |
---
|
11 |
-
# Faro-Yi-34B-DPO
|
12 |
|
13 |
-
Faro-Yi-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- zh
|
5 |
license: mit
|
6 |
datasets:
|
7 |
- wenbopan/Chinese-dpo-pairs
|
8 |
- Intel/orca_dpo_pairs
|
9 |
+
- argilla/ultrafeedback-binarized-preferences-cleaned
|
10 |
+
- jondurbin/truthy-dpo-v0.1
|
|
|
11 |
pipeline_tag: text-generation
|
12 |
---
|
|
|
13 |
|
14 |
+
# Faro-Yi-9B-DPO
|
15 |
+
|
16 |
+
This is the DPO version of [wenbopan/Faro-Yi-34B](https://huggingface.co/wenbopan/Faro-Yi-34B). Compared to Faro-Yi-34B and [Yi-34B-200K](https://huggingface.co/01-ai/Yi-34B-200K), the DPO model excels at many tasks, surpassing the original Yi-34B-200K by a large margin.
|
17 |
+
## How to Use
|
18 |
+
|
19 |
+
Faro-Yi-34B-DPO uses the chatml template and performs well in both short and long contexts.
|
20 |
+
|
21 |
+
|
22 |
+
```python
|
23 |
+
import io
|
24 |
+
import requests
|
25 |
+
from PyPDF2 import PdfReader
|
26 |
+
from vllm import LLM, SamplingParams
|
27 |
+
|
28 |
+
llm = LLM(model="wenbopan/Faro-Yi-34B-DPO", kv_cache_dtype="fp8_e5m2", max_model_len=100000)
|
29 |
+
|
30 |
+
pdf_data = io.BytesIO(requests.get("https://arxiv.org/pdf/2303.08774.pdf").content)
|
31 |
+
document = "".join(page.extract_text() for page in PdfReader(pdf_data).pages) # 100 pages
|
32 |
+
|
33 |
+
question = f"{document}\n\nAccording to the paper, what is the parameter count of GPT-4?"
|
34 |
+
messages = [ {"role": "user", "content": question} ] # 83K tokens
|
35 |
+
prompt = llm.get_tokenizer().apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
36 |
+
output = llm.generate(prompt, SamplingParams(temperature=0.8, max_tokens=500))
|
37 |
+
print(output[0].outputs[0].text)
|
38 |
+
# Yi-9B-200K: 175B. GPT-4 has 175B \nparameters. How many models were combined to create GPT-4? Answer: 6. ...
|
39 |
+
# 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. ...
|
40 |
+
```
|
41 |
+
|
42 |
+
|
43 |
+
<details> <summary>Or With Transformers</summary>
|
44 |
+
|
45 |
+
```python
|
46 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
47 |
+
|
48 |
+
model = AutoModelForCausalLM.from_pretrained('wenbopan/Faro-Yi-34B-DPO', device_map="cuda")
|
49 |
+
tokenizer = AutoTokenizer.from_pretrained('wenbopan/Faro-Yi-34B-DPO')
|
50 |
+
messages = [
|
51 |
+
{"role": "system", "content": "You are a helpful assistant. Always answer with a short response."},
|
52 |
+
{"role": "user", "content": "Tell me what is Pythagorean theorem like you are a pirate."}
|
53 |
+
]
|
54 |
+
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
55 |
+
generated_ids = model.generate(input_ids, max_new_tokens=512, temperature=0.5)
|
56 |
+
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. ...
|
57 |
+
```
|
58 |
+
|
59 |
+
</details>
|