{"id":55760,"date":"2025-02-19T11:50:17","date_gmt":"2025-02-19T03:50:17","guid":{"rendered":"https:\/\/fwq.ai\/blog\/55760\/"},"modified":"2025-02-19T11:50:17","modified_gmt":"2025-02-19T03:50:17","slug":"%e9%80%9a%e8%bf%87%e8%a7%86%e8%a7%89%e6%8f%90%e5%8f%96%e6%96%87%e6%a1%a3%e4%b8%bamarkdown%e6%a0%bc%e5%bc%8f%e6%96%87%e6%a1%a3%e7%9a%84%e7%bb%84%e5%90%88%e6%8f%90%e7%a4%ba%e8%af%8d%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/55760\/","title":{"rendered":"\u901a\u8fc7\u89c6\u89c9\u63d0\u53d6\u6587\u6863\u4e3aMarkdown\u683c\u5f0f\u6587\u6863\u7684\u7ec4\u5408\u63d0\u793a\u8bcd\u6307\u4ee4"},"content":{"rendered":"<p>\u8be5\u6307\u4ee4\u6765\u6e90\u4e8e  \u9879\u76ee\uff0c\u5206\u4e3a\u4e24\u6b65\u63d0\u53d6markdown\u6587\u6863\u3002<\/p>\n<p><strong>\u56fe\u50cf\u5206\u6790\u63d0\u793a\u8bcd (img_analysis.prompt):<\/strong><\/p>\n<pre>Analyze this image and return a detailed JSON description including any text detected, images detected, tables detected, extracted text and confidence score for the extracted text.\r\nConfidence score for the extracted text should be a float value between 0 and 1. If you cannot determine certain details, leave those fields empty.<\/pre>\n<p>&nbsp;<\/p>\n<p> <\/p>\n<p><strong>\u63d0\u793a\u8bcd\u8bd1\u6587<\/strong><\/p>\n<pre>\u5206\u6790\u6b64\u56fe\u50cf\u5e76\u8fd4\u56de\u4e00\u4e2a\u8be6\u7ec6\u7684 JSON \u63cf\u8ff0\uff0c\u5176\u4e2d\u5305\u62ec\u68c0\u6d4b\u5230\u7684\u4efb\u4f55\u6587\u672c\u3001\u68c0\u6d4b\u5230\u7684\u56fe\u50cf\u3001\u68c0\u6d4b\u5230\u7684\u8868\u683c\u3001\u63d0\u53d6\u7684\u6587\u672c\u53ca\u5176\u7f6e\u4fe1\u5ea6\u5206\u6570\u3002 \r\n\u63d0\u53d6\u6587\u672c\u7684\u7f6e\u4fe1\u5ea6\u5206\u6570\u5e94\u4e3a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684\u6d6e\u70b9\u503c\u3002\u5982\u679c\u65e0\u6cd5\u786e\u5b9a\u67d0\u4e9b\u7ec6\u8282\uff0c\u8bf7\u5c06\u8fd9\u4e9b\u5b57\u6bb5\u7559\u7a7a\u3002<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Markdown\u683c\u5f0f\u63d0\u793a\u8bcd\u6a21\u677f (md_prompt.j2):<\/strong><\/p>\n<pre>{% autoescape true %}\r\n\nYour task is to analyze the given image and extract textual content in markdown format.\r\n\n{% if confidence_score_text is defined and confidence_score_text is number %}\r\n{% if confidence_score_text &gt; 0.6 %}\r\n- Verify if the extracted text matches with the content in the image: {{ extracted_text|escape|trim }}.\r\n- Ensure markdown text formatting for {{ extracted_text|escape|trim }} is applied properly by analyzing the image.\r\n- Strictly do not change any content in the original extracted text while applying markdown text formatting.\r\n{% else %}\r\n- Please carefully reanalyze the text in the image as the initial confidence score was low.\r\n- Convert the provided image into markdown format and ensure that all content from the image is included.\r\n{% endif %}\r\n{% endif %}\r\n\n{% if tables_detected is defined and tables_detected|string == \"Yes\" %}\r\n- Preserve the tabular structure in markdown format using | for columns and - for the header row separator.\r\n- Ensure that the cell values are properly aligned within the table columns and the tabular data is not distorted.\r\n- Maintain the original positioning of the table within the scanned document. Do not include any additional explanations or comments.\r\n{% endif %}\r\n\n- Preserve markdown text formatting if present such as bold, italics, underlines, headers, bullet points, links or other elements.\r\n- Strictly, do not omit any textual content from the given image and do not include any additional explanations, notes or comments.\r\n- Ensure that the content does not have unnecessary formatting and at the same time, preserve the original formatting as much as possible.\r\n- Strictly, do not generate code fences or backticks like ``` or ```markdown.\r\n\n{% endautoescape %}<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>\u63d0\u793a\u8bcd\u8bd1\u6587<\/strong><\/p>\n<pre>{% autoescape true %}\r\n\n\u60a8\u7684\u4efb\u52a1\u662f\u5206\u6790\u7ed9\u5b9a\u7684\u56fe\u50cf\uff0c\u5e76\u4ee5 Markdown \u683c\u5f0f\u63d0\u53d6\u6587\u672c\u5185\u5bb9\u3002\r\n\n{% if confidence_score_text is defined and confidence_score_text is number %}\r\n{% if confidence_score_text &gt; 0.6 %}\r\n- \u9a8c\u8bc1\u63d0\u53d6\u7684\u6587\u672c\u662f\u5426\u4e0e\u56fe\u50cf\u5185\u5bb9\u5339\u914d\uff1a{{ extracted_text|escape|trim }}\u3002\r\n- \u901a\u8fc7\u5206\u6790\u56fe\u50cf\uff0c\u786e\u4fdd {{ extracted_text|escape|trim }} \u7684 Markdown \u6587\u672c\u683c\u5f0f\u6b63\u786e\u5e94\u7528\u3002\r\n- \u5728\u5e94\u7528 Markdown \u6587\u672c\u683c\u5f0f\u65f6\uff0c\u4e25\u683c\u4e0d\u8981\u66f4\u6539\u539f\u59cb\u63d0\u53d6\u6587\u672c\u4e2d\u7684\u4efb\u4f55\u5185\u5bb9\u3002\r\n{% else %}\r\n- \u8bf7\u4ed4\u7ec6\u91cd\u65b0\u5206\u6790\u56fe\u50cf\u4e2d\u7684\u6587\u672c\uff0c\u56e0\u4e3a\u521d\u59cb\u7f6e\u4fe1\u8bc4\u5206\u8f83\u4f4e\u3002\r\n- \u5c06\u63d0\u4f9b\u7684\u56fe\u50cf\u8f6c\u6362\u4e3a Markdown \u683c\u5f0f\uff0c\u5e76\u786e\u4fdd\u56fe\u50cf\u4e2d\u7684\u6240\u6709\u5185\u5bb9\u90fd\u88ab\u5305\u542b\u3002\r\n{% endif %}\r\n{% endif %}\r\n\n{% if tables_detected is defined and tables_detected|string == \"Yes\" %}\r\n- \u4f7f\u7528 | \u8868\u793a\u5217\uff0c\u4f7f\u7528 - \u8868\u793a\u8868\u5934\u884c\u5206\u9694\u7b26\uff0c\u4ee5 Markdown \u683c\u5f0f\u4fdd\u7559\u8868\u683c\u7ed3\u6784\u3002\r\n- \u786e\u4fdd\u5355\u5143\u683c\u503c\u5728\u8868\u683c\u5217\u4e2d\u6b63\u786e\u5bf9\u9f50\uff0c\u5e76\u4e14\u8868\u683c\u6570\u636e\u672a\u53d1\u751f\u626d\u66f2\u3002\r\n- \u4fdd\u6301\u8868\u683c\u5728\u626b\u63cf\u6587\u6863\u4e2d\u7684\u539f\u59cb\u4f4d\u7f6e\u3002\u4e0d\u8981\u5305\u62ec\u4efb\u4f55\u989d\u5916\u7684\u8bf4\u660e\u6216\u8bc4\u8bba\u3002\r\n{% endif %}\r\n\n- \u5982\u679c\u5b58\u5728 Markdown \u6587\u672c\u683c\u5f0f\uff0c\u4f8b\u5982\u52a0\u7c97\u3001\u659c\u4f53\u3001\u4e0b\u5212\u7ebf\u3001\u6807\u9898\u3001\u9879\u76ee\u7b26\u53f7\u3001\u94fe\u63a5\u6216\u5176\u4ed6\u5143\u7d20\uff0c\u8bf7\u4e88\u4ee5\u4fdd\u7559\u3002\r\n- \u4e25\u683c\u4e0d\u8981\u9057\u6f0f\u7ed9\u5b9a\u56fe\u50cf\u4e2d\u7684\u4efb\u4f55\u6587\u672c\u5185\u5bb9\uff0c\u4e5f\u4e0d\u8981\u5305\u62ec\u4efb\u4f55\u989d\u5916\u7684\u8bf4\u660e\u3001\u5907\u6ce8\u6216\u8bc4\u8bba\u3002\r\n- \u786e\u4fdd\u5185\u5bb9\u6ca1\u6709\u4e0d\u5fc5\u8981\u7684\u683c\u5f0f\uff0c\u540c\u65f6\u5c3d\u53ef\u80fd\u4fdd\u7559\u539f\u59cb\u683c\u5f0f\u3002\r\n- \u4e25\u683c\u4e0d\u8981\u751f\u6210\u4ee3\u7801\u5757\u6216\u53cd\u5f15\u53f7\uff0c\u4f8b\u5982 ``` \u6216 ```markdown\u3002\r\n\n{% endautoescape %}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u8ba9\u6211\u5206\u6790 md_prompt.j2 \u6a21\u677f\u4e2d\u5f15\u7528\u7684\u6240\u6709\u53d8\u91cf\uff1a<\/p>\n<ol>\n<li><strong>confidence_score_text<\/strong><\/li>\n<\/ol>\n<pre><code>{% if confidence_score_text is defined and confidence_score_text is number %}\r\n{% if confidence_score_text &gt; 0.6 %}\r\n<\/code><\/pre>\n<ul>\n<li>\u7c7b\u578b\uff1a\u6570\u503c\u578b(number)<\/li>\n<li>\u7528\u9014\uff1a\u5b58\u50a8\u6587\u672c\u63d0\u53d6\u7684\u7f6e\u4fe1\u5ea6\u5206\u6570<\/li>\n<li>\u53d6\u503c\u8303\u56f4\uff1a0~1\u4e4b\u95f4\u7684\u6d6e\u70b9\u6570<\/li>\n<li>\u7528\u4e8e\u5224\u65ad\u662f\u5426\u9700\u8981\u91cd\u65b0\u5206\u6790\u6587\u672c<\/li>\n<\/ul>\n<ol>\n<li><strong>extracted_text<\/strong><\/li>\n<\/ol>\n<pre><code>{{ extracted_text|escape|trim }}\r\n<\/code><\/pre>\n<ul>\n<li>\u7c7b\u578b\uff1a\u5b57\u7b26\u4e32(string)<\/li>\n<li>\u7528\u9014\uff1a\u5b58\u50a8\u4ece\u56fe\u50cf\u4e2d\u63d0\u53d6\u7684\u539f\u59cb\u6587\u672c\u5185\u5bb9<\/li>\n<li>\u4f7f\u7528\u4e86\u4e24\u4e2a\u8fc7\u6ee4\u5668\uff1a\n<ul>\n<li>escape: \u8f6c\u4e49\u7279\u6b8a\u5b57\u7b26<\/li>\n<li>trim: \u53bb\u9664\u524d\u540e\u7a7a\u767d\u5b57\u7b26<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol>\n<li><strong>tables_detected<\/strong><\/li>\n<\/ol>\n<pre><code>{% if tables_detected is defined and tables_detected|string == \"Yes\" %}\r\n<\/code><\/pre>\n<ul>\n<li>\u7c7b\u578b\uff1a\u5b57\u7b26\u4e32(string)<\/li>\n<li>\u7528\u9014\uff1a\u6807\u8bc6\u662f\u5426\u68c0\u6d4b\u5230\u8868\u683c<\/li>\n<li>\u53ef\u80fd\u7684\u503c\uff1a&#8221;Yes&#8221; \u6216 &#8220;No&#8221;<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u53d8\u91cf\u6765\u81ea\u4e8e\u4ee3\u7801\u4e2d\u7684 ImageDescription \u6a21\u578b\uff08\u5728 llm.py \u4e2d\u5b9a\u4e49\uff09\uff1a<\/p>\n<pre><code>class ImageDescription(BaseModel):\r\n\"\"\"Model Schema for image description.\"\"\"\r\ntext_detected: Literal[\"Yes\", \"No\"]\r\ntables_detected: Literal[\"Yes\", \"No\"]\r\nextracted_text: str\r\nconfidence_score_text: float\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6a21\u578b\u4e0e img_analysis.prompt \u8fd4\u56de\u7684 JSON \u7ed3\u6784\u76f8\u5bf9\u5e94\uff0c\u786e\u4fdd\u4e86\u6570\u636e\u7684\u7c7b\u578b\u5b89\u5168\u548c\u4e00\u81f4\u6027\u3002\u8fd9\u4e9b\u53d8\u91cf\u662f\u5728\u56fe\u50cf\u5206\u6790\u9636\u6bb5(img_analysis.prompt)\u751f\u6210\u7684\uff0c\u7136\u540e\u4f20\u9012\u7ed9 markdown \u751f\u6210\u6a21\u677f(md_prompt.j2)\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8be5\u6307\u4ee4\u6765\u6e90\u4e8e \u9879\u76ee\uff0c\u5206\u4e3a\u4e24\u6b65\u63d0\u53d6markdown\u6587\u6863\u3002 \u56fe\u50cf\u5206\u6790\u63d0\u793a\u8bcd (img_analysis.prompt): Analyze this image and return a detailed JSON description including any text detected, images detected, tables detected, extracted text and confidence score for the extracted text. Confidence score for the extracted text should be a float value between 0 and 1. If you cannot determine certain details, leave those fields empty. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-55760","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/55760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=55760"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/55760\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=55760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=55760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=55760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}