Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,26 +1,121 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LyTOC Benchmark
|
| 2 |
+
|
| 3 |
+
This repository contains a benchmark dataset extracted from homework PDFs using SimpleTex OCR API.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
|
| 7 |
+
- Automated PDF content extraction using SimpleTex OCR API
|
| 8 |
+
- Structured benchmark dataset creation
|
| 9 |
+
- Multiple export formats (JSON, JSONL, HuggingFace Dataset)
|
| 10 |
+
- Easy upload to HuggingFace Hub
|
| 11 |
+
- Interactive pipeline runner
|
| 12 |
+
|
| 13 |
+
## Quick Start
|
| 14 |
+
|
| 15 |
+
### 1. Install Dependencies
|
| 16 |
+
|
| 17 |
+
```bash
|
| 18 |
+
pip install -r requirements.txt
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
### 2. Set Up API Keys
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
cp .env.example .env
|
| 25 |
+
# Edit .env and add your API keys:
|
| 26 |
+
# - OCR_UAT: Get from https://simpletex.cn
|
| 27 |
+
# - HF_TOKEN: Get from https://huggingface.co/settings/tokens
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### 3. Run the Pipeline
|
| 31 |
+
|
| 32 |
+
**Option A: Interactive Pipeline** (Recommended)
|
| 33 |
+
```bash
|
| 34 |
+
python run_pipeline.py
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
**Option B: Manual Steps**
|
| 38 |
+
```bash
|
| 39 |
+
# Extract PDFs
|
| 40 |
+
python extract_pdfs.py
|
| 41 |
+
|
| 42 |
+
# Create benchmark dataset
|
| 43 |
+
python create_benchmark.py
|
| 44 |
+
|
| 45 |
+
# Upload to HuggingFace
|
| 46 |
+
python upload_to_hf.py <username/repo-name> [--private]
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
## Project Structure
|
| 50 |
+
|
| 51 |
+
```
|
| 52 |
+
lytoc/
|
| 53 |
+
βββ raw/ # Source PDF files
|
| 54 |
+
βββ parsed_data/ # Extracted markdown content
|
| 55 |
+
β βββ hw*.md # Individual parsed files
|
| 56 |
+
β βββ extraction_metadata.json # Extraction status
|
| 57 |
+
βββ benchmark_dataset/ # Final benchmark dataset
|
| 58 |
+
β βββ dataset.json # JSON format
|
| 59 |
+
β βββ dataset.jsonl # JSONL format
|
| 60 |
+
β βββ huggingface_dataset/ # HuggingFace format
|
| 61 |
+
βββ extract_pdfs.py # PDF extraction script
|
| 62 |
+
βββ create_benchmark.py # Benchmark creation script
|
| 63 |
+
βββ upload_to_hf.py # HuggingFace upload script
|
| 64 |
+
βββ run_pipeline.py # Interactive pipeline runner
|
| 65 |
+
βββ DATASET_CARD.md # Dataset documentation
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Dataset Structure
|
| 69 |
+
|
| 70 |
+
Each problem in the dataset contains:
|
| 71 |
+
- `homework`: Homework identifier (e.g., "hw1", "hw2")
|
| 72 |
+
- `problem_number`: Problem number within the homework
|
| 73 |
+
- `content`: Full problem text and description
|
| 74 |
+
- `full_id`: Unique identifier (e.g., "hw1_problem1")
|
| 75 |
+
|
| 76 |
+
Example:
|
| 77 |
+
```json
|
| 78 |
+
{
|
| 79 |
+
"homework": "hw1",
|
| 80 |
+
"problem_number": "1",
|
| 81 |
+
"content": "Problem statement...",
|
| 82 |
+
"full_id": "hw1_problem1"
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## Scripts
|
| 87 |
+
|
| 88 |
+
### extract_pdfs.py
|
| 89 |
+
Extracts content from PDF files in the `raw/` directory using SimpleTex OCR API.
|
| 90 |
+
- Converts PDFs to markdown format via OCR
|
| 91 |
+
- Saves parsed content to `parsed_data/`
|
| 92 |
+
- Creates extraction metadata
|
| 93 |
+
|
| 94 |
+
### create_benchmark.py
|
| 95 |
+
Processes parsed content into a structured benchmark dataset.
|
| 96 |
+
- Parses markdown content to extract individual problems
|
| 97 |
+
- Creates dataset in multiple formats
|
| 98 |
+
- Generates statistics and sample output
|
| 99 |
+
|
| 100 |
+
### upload_to_hf.py
|
| 101 |
+
Uploads the benchmark dataset to HuggingFace Hub.
|
| 102 |
+
```bash
|
| 103 |
+
python upload_to_hf.py username/repo-name [--private]
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
### run_pipeline.py
|
| 107 |
+
Interactive script that runs the complete pipeline with user prompts.
|
| 108 |
+
|
| 109 |
+
## Requirements
|
| 110 |
+
|
| 111 |
+
- Python 3.8+
|
| 112 |
+
- SimpleTex API token (OCR_UAT)
|
| 113 |
+
- HuggingFace account and token (for upload)
|
| 114 |
+
|
| 115 |
+
## License
|
| 116 |
+
|
| 117 |
+
MIT License - See LICENSE file for details
|
| 118 |
+
|
| 119 |
+
## Contributing
|
| 120 |
+
|
| 121 |
+
Contributions are welcome! Please feel free to submit a Pull Request.
|