tkon3 commited on
Commit
3d71fdf
·
1 Parent(s): 2ac48e8

first commit

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. README.md +41 -0
  3. arxiv-classification.py +103 -0
  4. test_data.txt +3 -0
  5. train_data.txt +3 -0
  6. val_data.txt +3 -0
.gitattributes CHANGED
@@ -25,3 +25,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.txt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ languages: en
3
+ task_categories: text-classification
4
+ tags:
5
+ - long context
6
+ task_ids:
7
+ - multi-class-classification
8
+ - topic-classification
9
+ size_categories: 10K<n<100K
10
+ ---
11
+
12
+ **Arxiv Classification: a classification of Arxiv Papers (11 classes).**
13
+
14
+ This dataset is intended for long context classification (documents have all > 4k tokens). \
15
+ Copied from "Long Document Classification From Local Word Glimpses via Recurrent Attention Learning" by JUN HE LIQUN WANG LIU LIU, JIAO FENG AND HAO WU
16
+ * See: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8675939
17
+ * See: https://github.com/LiqunW/Long-document-dataset
18
+
19
+ It contains 11 slightly unbalanced classes, 33k Arxiv Papers divided into 3 splits: train (23k), val (5k) and test (5k).
20
+
21
+ **Removed all "\n", each document is a single line document**
22
+ **I also removed references to the class inside the document (eg: [cs.LG] -> [])**
23
+
24
+ Compatible with [run_glue.py](https://github.com/huggingface/transformers/tree/master/examples/pytorch/text-classification) script:
25
+ ```
26
+ export MODEL_NAME=roberta-base
27
+ export MAX_SEQ_LENGTH=512
28
+
29
+ python run_glue.py \
30
+ --model_name_or_path $MODEL_NAME \
31
+ --dataset_name ccdv/arxiv-classification \
32
+ --do_train \
33
+ --do_eval \
34
+ --max_seq_length $MAX_SEQ_LENGTH \
35
+ --per_device_train_batch_size 8 \
36
+ --gradient_accumulation_steps 4 \
37
+ --learning_rate 2e-5 \
38
+ --num_train_epochs 1 \
39
+ --max_eval_samples 500 \
40
+ --output_dir tmp/QR-AN
41
+ ```
arxiv-classification.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ import datasets
5
+ from datasets.tasks import TextClassification
6
+
7
+ _CITATION = None
8
+
9
+
10
+ _DESCRIPTION = """
11
+ Arxiv Classification Dataset: a classification of Arxiv Papers (11 classes).
12
+ It contains 11 slightly unbalanced classes, 33k Arxiv Papers divided into 3 splits: train (23k), val (5k) and test (5k).
13
+ Copied from "Long Document Classification From Local Word Glimpses via Recurrent Attention Learning" by JUN HE LIQUN WANG LIU LIU, JIAO FENG AND HAO WU
14
+ See: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8675939
15
+ See: https://github.com/LiqunW/Long-document-dataset
16
+ """
17
+
18
+ _LABELS = [
19
+ "math.AC",
20
+ "cs.cv",
21
+ "cs.AI",
22
+ "cs.SY",
23
+ "math.GR",
24
+ "cs.CE",
25
+ "cs.PL",
26
+ "cs.IT",
27
+ "cs.DS",
28
+ "cs.NE",
29
+ "math.ST"
30
+ ]
31
+
32
+
33
+ class ArxivClassificationConfig(datasets.BuilderConfig):
34
+ """BuilderConfig for ArxivClassification."""
35
+
36
+ def __init__(self, **kwargs):
37
+ """BuilderConfig for ArxivClassification.
38
+ Args:
39
+ **kwargs: keyword arguments forwarded to super.
40
+ """
41
+ super(ArxivClassificationConfig, self).__init__(**kwargs)
42
+
43
+
44
+ class ArxivClassificationDataset(datasets.GeneratorBasedBuilder):
45
+ """ArxivClassification Dataset: classification of Arxiv Papers (11 classes)."""
46
+
47
+ _DOWNLOAD_URL = "https://huggingface.co/datasets/ccdv/arxiv-classification/resolve/main/"
48
+ _TRAIN_FILE = "train_data.txt"
49
+ _VAL_FILE = "val_data.txt"
50
+ _TEST_FILE = "test_data.txt"
51
+ _LABELS_DICT = {label: i for i, label in enumerate(_LABELS)}
52
+
53
+ BUILDER_CONFIGS = [
54
+
55
+ ArxivClassificationConfig(
56
+ name="arxiv",
57
+ version=datasets.Version("1.0.0"),
58
+ description="Arxiv Classification Dataset: A classification task of Arxiv Papers (11 classes)",
59
+ ),
60
+ ]
61
+
62
+ DEFAULT_CONFIG_NAME = "arxiv"
63
+
64
+ def _info(self):
65
+ return datasets.DatasetInfo(
66
+ description=_DESCRIPTION,
67
+ features=datasets.Features(
68
+ {
69
+ "text": datasets.Value("string"),
70
+ "label": datasets.features.ClassLabel(names=_LABELS),
71
+ }
72
+ ),
73
+ supervised_keys=None,
74
+ citation=_CITATION,
75
+ task_templates=[TextClassification(
76
+ text_column="text", label_column="label")],
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ train_path = dl_manager.download_and_extract(self._DOWNLOAD_URL + self._TRAIN_FILE)
81
+ val_path = dl_manager.download_and_extract(self._DOWNLOAD_URL + self._VAL_FILE)
82
+ test_path = dl_manager.download_and_extract(self._DOWNLOAD_URL + self._TEST_FILE)
83
+
84
+ return [
85
+ datasets.SplitGenerator(
86
+ name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}
87
+ ),
88
+ datasets.SplitGenerator(
89
+ name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path}
90
+ ),
91
+ datasets.SplitGenerator(
92
+ name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}
93
+ ),
94
+ ]
95
+
96
+ def _generate_examples(self, filepath):
97
+ """Generate ArxivClassification examples."""
98
+ with open(filepath, encoding="utf-8") as f:
99
+ for id_, row in enumerate(f):
100
+ data = json.loads(row)
101
+ label = self._LABELS_DICT[data["label"]]
102
+ text = data["text"]
103
+ yield id_, {"text": text, "label": label}
test_data.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2fcfc6c86a3e5b973e4004e3ab1dd287df1ce200a185c9a5c18ad5992160336
3
+ size 285232323
train_data.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:591f4056f0dc4270a546028a08571c0c474f470b5e7ba14b6b52872a22243710
3
+ size 1358051316
val_data.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:005426cc445a98d39cffd5e364df0bcfe01f8d45065f7ef565585c4f1be509ae
3
+ size 292050818