Commit
·
ee028d2
1
Parent(s):
ed67b34
Namespace metadata column by output column name
Browse files- Changes metadata column from fixed 'olmocr_metadata' to '{output_column}_metadata'
- Allows multiple OCR runs on same dataset with different column names
- Handles existing columns by removing and overwriting with warning
- Enables workflow: process same dataset with different models/settings
Example:
--output-column markdown → markdown_metadata
--output-column olmocr2 → olmocr2_metadata
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- olmocr2-vllm.py +11 -2
olmocr2-vllm.py
CHANGED
|
@@ -323,9 +323,10 @@ def main(
|
|
| 323 |
logger.info(f"Processing {len(ds)} samples")
|
| 324 |
logger.info(f"Output will be written to column: {output_column}")
|
| 325 |
|
| 326 |
-
# Set column names
|
| 327 |
-
metadata_column_name = "
|
| 328 |
inference_info_column = "inference_info"
|
|
|
|
| 329 |
|
| 330 |
# Initialize LLM
|
| 331 |
logger.info(f"Initializing vLLM with model: {model}")
|
|
@@ -365,7 +366,15 @@ def main(
|
|
| 365 |
all_metadata.append(json.dumps(metadata))
|
| 366 |
|
| 367 |
# Add results to dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
ds = ds.add_column(output_column, all_outputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
ds = ds.add_column(metadata_column_name, all_metadata)
|
| 370 |
|
| 371 |
# Add inference information
|
|
|
|
| 323 |
logger.info(f"Processing {len(ds)} samples")
|
| 324 |
logger.info(f"Output will be written to column: {output_column}")
|
| 325 |
|
| 326 |
+
# Set column names - namespace metadata by output column to avoid conflicts
|
| 327 |
+
metadata_column_name = f"{output_column}_metadata"
|
| 328 |
inference_info_column = "inference_info"
|
| 329 |
+
logger.info(f"Metadata will be written to column: {metadata_column_name}")
|
| 330 |
|
| 331 |
# Initialize LLM
|
| 332 |
logger.info(f"Initializing vLLM with model: {model}")
|
|
|
|
| 366 |
all_metadata.append(json.dumps(metadata))
|
| 367 |
|
| 368 |
# Add results to dataset
|
| 369 |
+
# Check if columns already exist and handle appropriately
|
| 370 |
+
if output_column in ds.column_names:
|
| 371 |
+
logger.warning(f"Column '{output_column}' already exists, it will be overwritten")
|
| 372 |
+
ds = ds.remove_columns([output_column])
|
| 373 |
ds = ds.add_column(output_column, all_outputs)
|
| 374 |
+
|
| 375 |
+
if metadata_column_name in ds.column_names:
|
| 376 |
+
logger.warning(f"Column '{metadata_column_name}' already exists, it will be overwritten")
|
| 377 |
+
ds = ds.remove_columns([metadata_column_name])
|
| 378 |
ds = ds.add_column(metadata_column_name, all_metadata)
|
| 379 |
|
| 380 |
# Add inference information
|