Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1 |
---
|
2 |
license: cc-by-sa-3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-sa-3.0
|
3 |
+
task_categories:
|
4 |
+
- question-answering
|
5 |
+
- text-generation
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
size_categories:
|
9 |
+
- 10K<n<100K
|
10 |
---
|
11 |
+
|
12 |
+
[databricks/databricks-dolly-15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) in ChatML format.
|
13 |
+
|
14 |
+
Python code used for conversion:
|
15 |
+
|
16 |
+
```python
|
17 |
+
from datasets import load_dataset
|
18 |
+
import pandas
|
19 |
+
from transformers import AutoTokenizer
|
20 |
+
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
22 |
+
pretrained_model_name_or_path="Felladrin/Llama-160M-Chat-v1"
|
23 |
+
)
|
24 |
+
|
25 |
+
dataset = load_dataset("databricks/databricks-dolly-15k", split="train")
|
26 |
+
|
27 |
+
|
28 |
+
def format(columns):
|
29 |
+
instruction = columns["instruction"].strip()
|
30 |
+
context = columns["context"].strip()
|
31 |
+
response = columns["response"].strip()
|
32 |
+
|
33 |
+
if context:
|
34 |
+
user_message = f"{instruction}\n\nContext:\n{context}"
|
35 |
+
else:
|
36 |
+
user_message = instruction
|
37 |
+
|
38 |
+
messages = [
|
39 |
+
{
|
40 |
+
"role": "user",
|
41 |
+
"content": user_message,
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"role": "assistant",
|
45 |
+
"content": response,
|
46 |
+
},
|
47 |
+
]
|
48 |
+
|
49 |
+
return tokenizer.apply_chat_template(messages, tokenize=False)
|
50 |
+
|
51 |
+
|
52 |
+
pandas.DataFrame({"text": [format(columns) for columns in dataset]}).to_parquet("train.parquet", index=False)
|
53 |
+
```
|