mirror of
https://github.com/allenai/olmocr.git
synced 2025-10-13 17:22:13 +00:00
Gathering some new data
This commit is contained in:
parent
c1061146e5
commit
f789fc3a72
@ -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")
|
||||
|
||||
|
@ -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 "
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user