Monketoo commited on
Commit
e1cbc03
·
verified ·
1 Parent(s): b31749c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +193 -0
README.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - text-classification
5
+ - object-detection
6
+ language:
7
+ - en
8
+ size_categories:
9
+ - 10K<n<100K
10
+ ---
11
+
12
+ # Mathematical Documents Dataset
13
+
14
+ This dataset contains 36,661 scientific documents with OCR-extracted text and mathematical content probability scores.
15
+ Documents were filtered from the **CommonCrawl PDF corpus** based on mathematical content probability.
16
+
17
+ ## Quick Start
18
+
19
+ ```python
20
+ from datasets import load_dataset
21
+ import json
22
+
23
+ # Load metadata
24
+ with open("metadata.jsonl") as f:
25
+ for line in f:
26
+ doc = json.loads(line)
27
+ doc_id = doc['doc_id']
28
+
29
+ # Read extracted text for each page
30
+ # texts/{doc_id}/page_1.md, page_2.md, ...
31
+ with open(f"texts/{doc_id}/page_1.md") as page:
32
+ text = page.read()
33
+ print(text)
34
+ break
35
+ ```
36
+
37
+ ## Dataset Structure
38
+
39
+ ```
40
+ math-docs-dataset/
41
+ ├── metadata.jsonl # Document metadata with probability scores
42
+ ├── metadata_updated.jsonl # Updated metadata (if applicable)
43
+ ├── token_counts.jsonl # Token counts per document
44
+ ├── token_stats.json # Aggregate token statistics
45
+ ├── texts/ # OCR-extracted text (2.5GB)
46
+ │ ├── {doc_id}/
47
+ │ │ ├── page_1.md
48
+ │ │ ├── page_2.md
49
+ │ │ └── ...
50
+ └── samples/ # 50 sample documents for preview
51
+ ├── pdfs/
52
+ │ └── {doc_id}.pdf
53
+ ├── texts/
54
+ │ └── {doc_id}/
55
+ └── sample_metadata.jsonl
56
+ ```
57
+
58
+ ## Statistics
59
+
60
+ - **Total documents**: 36,661
61
+ - **Total pages**: 885,333
62
+ - **Average pages per document**: 24.1
63
+ - **Mean probability range**: [0.8007, 1.0000]
64
+
65
+ ### Token Statistics
66
+
67
+ - **Total tokens**: 756,843,504
68
+ - **Average tokens per document**: 20,644
69
+ - **Average tokens per page**: 854
70
+
71
+ Token counts calculated using tiktoken (cl100k_base encoding, GPT-4 tokenizer).
72
+
73
+ ## Accessing Full PDFs
74
+
75
+ Due to size constraints, full PDF files (30+ GB) are hosted on Wasabi S3 storage.
76
+
77
+ ### Download All PDFs
78
+
79
+ ```bash
80
+ # Install AWS CLI if needed
81
+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
82
+ unzip awscliv2.zip
83
+ ./aws/install -i ~/.local/aws-cli -b ~/.local/bin
84
+
85
+ # Download PDFs (no authentication required)
86
+ aws s3 sync s3://igor-bucket/math_docs_dataset/pdfs/ ./pdfs/ \
87
+ --endpoint-url=https://s3.eu-central-1.wasabisys.com \
88
+ --no-sign-request
89
+ ```
90
+
91
+ ### Download Specific PDF
92
+
93
+ ```bash
94
+ # Download single document
95
+ aws s3 cp s3://igor-bucket/math_docs_dataset/pdfs/{doc_id}.pdf ./pdfs/ \
96
+ --endpoint-url=https://s3.eu-central-1.wasabisys.com \
97
+ --no-sign-request
98
+ ```
99
+
100
+ ### Preview Samples
101
+
102
+ 50 sample PDFs are included in the `samples/` directory for preview without downloading the full dataset.
103
+
104
+ ## Metadata Fields
105
+
106
+ Each entry in `metadata.jsonl` contains:
107
+
108
+ - `doc_id`: Unique document identifier
109
+ - `pdf_path`: Relative path to PDF file
110
+ - `num_pages`: Number of pages in the document
111
+ - `mean_proba`: Mean probability that document contains mathematical content
112
+
113
+ ## Data Collection
114
+
115
+ 1. **Source**: CommonCrawl PDF corpus
116
+ 2. **Filtering**: Documents classified by mathematical content probability
117
+ 3. **Text Extraction**: [doct.ocr](https://github.com/parse-data/doct.ocr)
118
+
119
+ ## Usage Examples
120
+
121
+ ### Load and Process Documents
122
+
123
+ ```python
124
+ import json
125
+ from pathlib import Path
126
+
127
+ # Load metadata
128
+ docs = []
129
+ with open("metadata.jsonl") as f:
130
+ for line in f:
131
+ docs.append(json.loads(line))
132
+
133
+ # Filter high-quality math documents
134
+ high_quality = [d for d in docs if d['mean_proba'] > 0.95]
135
+ print(f"Found {len(high_quality)} high-quality documents")
136
+
137
+ # Read document text
138
+ def read_document(doc_id):
139
+ text_dir = Path(f"texts/{doc_id}")
140
+ full_text = []
141
+
142
+ for page_file in sorted(text_dir.glob("page_*.md")):
143
+ with open(page_file) as f:
144
+ full_text.append(f.read())
145
+
146
+ return "\n\n".join(full_text)
147
+
148
+ # Example usage
149
+ doc = high_quality[0]
150
+ text = read_document(doc['doc_id'])
151
+ print(f"Document {doc['doc_id']}: {len(text)} characters")
152
+ ```
153
+
154
+ ### Token Analysis
155
+
156
+ ```python
157
+ import json
158
+
159
+ # Load token statistics
160
+ with open("token_stats.json") as f:
161
+ stats = json.load(f)
162
+ print(f"Total tokens: {stats['total_tokens']:,}")
163
+ print(f"Avg tokens/doc: {stats['avg_tokens_per_doc']:.0f}")
164
+
165
+ # Load per-document token counts
166
+ with open("token_counts.jsonl") as f:
167
+ for line in f:
168
+ doc_tokens = json.loads(line)
169
+ # Process individual document token counts
170
+ break
171
+ ```
172
+
173
+ ## Citation
174
+
175
+ If you use this dataset, please cite:
176
+
177
+ ```bibtex
178
+ @dataset{math_docs_dataset,
179
+ title={Mathematical Documents Dataset},
180
+ author={Your Name},
181
+ year={2025},
182
+ publisher={HuggingFace},
183
+ url={https://huggingface.co/datasets/your-username/math-docs-dataset}
184
+ }
185
+ ```
186
+
187
+ ## License
188
+
189
+ MIT License
190
+
191
+ ## Contact
192
+
193
+ For questions or issues, please open an issue on the dataset repository.