Gathering some new data

This commit is contained in:
Jake Poznanski 2025-08-04 15:33:14 +00:00
parent c1061146e5
commit f789fc3a72
2 changed files with 19 additions and 1 deletions

View File

@ -15,6 +15,7 @@ from olmocr.prompts.prompts import (
build_finetuning_prompt,
build_openai_silver_data_prompt,
openai_response_format_schema,
build_openai_silver_data_prompt_v2
)
@ -24,7 +25,7 @@ def run_chatgpt(
model: str = "gpt-4o-2024-08-06",
temperature: float = 0.1,
target_longest_image_dim: int = 2048,
prompt_template: Literal["full", "full_no_document_anchoring", "basic", "finetune"] = "finetune",
prompt_template: Literal["full", "full_no_document_anchoring", "basic", "finetune", "fullv2"] = "finetune",
response_template: Literal["plain", "json"] = "json",
) -> str:
"""
@ -55,6 +56,8 @@ def run_chatgpt(
prompt = build_finetuning_prompt(anchor_text)
elif prompt_template == "basic":
prompt = build_basic_prompt()
elif prompt_template == "fullv2":
prompt = build_openai_silver_data_prompt_v2(anchor_text)
else:
raise ValueError("Unknown prompt template")

View File

@ -16,6 +16,21 @@ def build_openai_silver_data_prompt(base_text: str) -> str:
f"RAW_TEXT_START\n{base_text}\nRAW_TEXT_END"
)
def build_openai_silver_data_prompt_v2(base_text: str) -> str:
return (
f"Below is the image of one page of a PDF document, as well as some raw textual content that was previously extracted for it that includes position information for each image and block of text (The origin [0x0] of the coordinates is in the lower left corner of the image). "
f"Just return the plain text representation of this document as if you were reading it naturally.\n"
f"Turn equations into a LaTeX representation, make sure to use \\( and \\) as a delimiter for inline math, and \\[ and \\] for block math.\n"
f"Convert tables into HTML format. Remove the headers and footers, but keep references and footnotes.\n"
f"Read any natural handwriting.\n"
f"If there are any figures or charts, label them with the following markdown syntax ![Alt text describing the contents of the figure](page_startx_starty_width_height.png)"
f"This is likely one page out of several in the document, so be sure to preserve any sentences that come from the previous page, or continue onto the next page, exactly as they are.\n"
f"If there is no text at all that you think you should read, you can output null.\n"
f"Do not hallucinate.\n"
f"RAW_TEXT_START\n{base_text}\nRAW_TEXT_END"
)
@dataclass(frozen=True)
class PageResponse: