Update README.md
Browse files
README.md
CHANGED
@@ -25,4 +25,55 @@ configs:
|
|
25 |
---
|
26 |
# Dataset Card for "no_robots_test400"
|
27 |
|
28 |
-
[More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
---
|
26 |
# Dataset Card for "no_robots_test400"
|
27 |
|
28 |
+
[More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
|
29 |
+
|
30 |
+
This is a subset of "no_robots", selecting 400 questions from the test set.
|
31 |
+
|
32 |
+
Code:
|
33 |
+
|
34 |
+
```python
|
35 |
+
import pandas as pd
|
36 |
+
import numpy as np
|
37 |
+
import numpy.random
|
38 |
+
from datasets import load_dataset, Dataset
|
39 |
+
from copy import deepcopy
|
40 |
+
|
41 |
+
def get_norobot_dataset():
|
42 |
+
ds = load_dataset('HuggingFaceH4/no_robots')
|
43 |
+
all_test_data = []
|
44 |
+
for sample in ds['test_sft']:
|
45 |
+
sample: dict
|
46 |
+
for i, message in enumerate(sample['messages']):
|
47 |
+
if message['role'] == 'user':
|
48 |
+
item = dict(
|
49 |
+
messages=deepcopy(sample['messages'][:i + 1]),
|
50 |
+
category=sample['category'],
|
51 |
+
prompt_id=sample['prompt_id'],
|
52 |
+
)
|
53 |
+
all_test_data.append(item)
|
54 |
+
return Dataset.from_list(all_test_data)
|
55 |
+
|
56 |
+
|
57 |
+
dataset = get_norobot_dataset().to_pandas()
|
58 |
+
dataset.groupby('category').count()
|
59 |
+
dataset['_sort_key'] = dataset['messages'].map(str)
|
60 |
+
dataset = dataset.sort_values(['_sort_key'])
|
61 |
+
|
62 |
+
subset = []
|
63 |
+
for category, group_df in sorted(dataset.groupby('category')):
|
64 |
+
n = int(len(group_df) * 0.603)
|
65 |
+
if n <= 20:
|
66 |
+
n = len(group_df)
|
67 |
+
indices = np.random.default_rng(seed=42).choice(len(group_df), size=n, replace=False)
|
68 |
+
subset.append(group_df.iloc[indices])
|
69 |
+
|
70 |
+
df = pd.concat(subset)
|
71 |
+
df = df.drop(columns=['_sort_key'])
|
72 |
+
df = df.reset_index(drop=True)
|
73 |
+
print(len(df))
|
74 |
+
print(df.groupby('category').count().to_string())
|
75 |
+
Dataset.from_pandas(df).push_to_hub('yujiepan/no_robots_test400')
|
76 |
+
```
|
77 |
+
|
78 |
+
|
79 |
+
|