Spaces:
Running on Zero
Running on Zero
layout: trained label names; split: every-page rule
Browse files67 unmodified lines6869707172737 unmodified lines81828384858625 unmodified lines1121131141151161171186 unmodified lines12512612712812913013113213367 unmodified lines"her new address is Kungsgatan 8, 111 43 Stockholm.\n\nThanks,\nMaja")ATTACH_RULE = ("Pages that are delivery notes are attachments: they stay with the document before them and never start ""a new document. Every other page starts a new document. Does {p} start a new document?")DEFAULT_SPLIT = "Does {p} start a new, separate document (rather than continuing the document {q} belongs to)?"7 unmodified linesqs[f"attachments rule: page {k} starts a new document"] = {"type": "noul", "instructions": ATTACH_RULE.format(p=p),"criteria": {"true": f"{p} is the first page of a new document", "false": f"{p} continues the same document as {q}"}}return qs25 unmodified lines"pii": {"type": "spans", "instructions": "Mark the personal data in `email`.", "target": "email","criteria": {"person": "a person's name", "email_address": "an e-mail address", "phone": "a phone number","iban": "a bank account number", "address": "a postal address"}}}),"Page stream: split it, with and without an instruction": (["invoice_ardent.png", "packing_slip.png", "invoice_blueharbor.png", "w9_page1.png"],{"pages": [{"image": f"page_{i + 1}", "text": t[:900]} for i, t in enumerate([INVOICE_OCR, SLIP_OCR, BH_OCR, W9_OCR])]},split_questions(4)),6 unmodified lines"Layout: box and label every heading, paragraph, table and figure": (["report_page.png"], {"page": "page_1"},{"layout": {"type": "boxes", "asset": "page_1", "min_boxes": 0, "max_boxes": 50,"instructions": "Draw every element on page_1 and label it as one of: heading, paragraph, table, figure and caption.","criteria": {"heading": "a section heading", "paragraph": "a block of body text", "table": "a table","figure": "a chart or picture", "caption": "a table or figure caption"}}}),}# ------------------------------------------------------------------------------------------------ rendering67 unmodified lines68697071727374757 unmodified lines83848586878889909125 unmodified lines1171181191201211221236 unmodified lines13013113213313413513613713813914014114214367 unmodified lines"her new address is Kungsgatan 8, 111 43 Stockholm.\n\nThanks,\nMaja")ATTACH_RULE = ("Pages that are delivery notes are attachments: they stay with the document before them and never start ""a new document. Every other page starts a new document. Does {p} start a new document?")EVERY_RULE = ("For this task every single page is its own document: mark a boundary before every page, also when it ""continues the previous page's document. Does {p} start a new document under this rule?")DEFAULT_SPLIT = "Does {p} start a new, separate document (rather than continuing the document {q} belongs to)?"7 unmodified linesqs[f"attachments rule: page {k} starts a new document"] = {"type": "noul", "instructions": ATTACH_RULE.format(p=p),"criteria": {"true": f"{p} is the first page of a new document", "false": f"{p} continues the same document as {q}"}}qs[f"every-page rule: page {k} starts a new document"] = {"type": "noul", "instructions": EVERY_RULE.format(p=p),"criteria": {"true": f"{p} starts a new document under the every-page rule", "false": f"{p} does not"}}return qs25 unmodified lines"pii": {"type": "spans", "instructions": "Mark the personal data in `email`.", "target": "email","criteria": {"person": "a person's name", "email_address": "an e-mail address", "phone": "a phone number","iban": "a bank account number", "address": "a postal address"}}}),"Page stream: split it, by default and under two instructions": (["invoice_ardent.png", "packing_slip.png", "invoice_blueharbor.png", "w9_page1.png"],{"pages": [{"image": f"page_{i + 1}", "text": t[:900]} for i, t in enumerate([INVOICE_OCR, SLIP_OCR, BH_OCR, W9_OCR])]},split_questions(4)),6 unmodified lines"Layout: box and label every heading, paragraph, table and figure": (["report_page.png"], {"page": "page_1"},{"layout": {"type": "boxes", "asset": "page_1", "min_boxes": 0, "max_boxes": 50,"instructions": "Draw every element on page_1 and label it as one of: section header, paragraph, table, ""figure, caption, page header and page footer.","criteria": {"section header": "a heading that opens a section or subsection","paragraph": "a block of ordinary body text", "table": "data laid out in rows and columns","figure": "a picture, chart, diagram or other graphic","caption": "text that describes or names a figure or table","page header": "running text in the top margin, such as a chapter or document name","page footer": "running text in the bottom margin, such as a page number or document name"}}}),}# ------------------------------------------------------------------------------------------------ rendering
app.py+14-4