Prompt - 将图片的表格转换成Markdown

2024-09-09 05:28

本文主要是介绍Prompt - 将图片的表格转换成Markdown,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Prompt - 将图片的表格转换成Markdown

  • 0. 引言
  • 1. 提示词
  • 2. 原始版本

0. 引言

最近尝试将图片中的表格转换成Markdown格式,需要不断条件和优化提示词。记录一下调整好的提示词,以后在继续优化迭代。

1. 提示词

英文版本:

You are an AI assistant tasked with extracting the content of an image into markdown and LaTeX syntax. Please follow these steps strictly:1. You will receive one or more images containing tables. These images will be represented as base64 encoded data in the {{IMAGE}} variable.2. Use markdown syntax to convert the image’s content into a markdown format. Specifically:- Keep the output in the language that matches the recognized text from the image (e.g., English text should remain in English).- Only output the content from the image directly. Do **not** include phrases like "Here is the markdown text generated..." — simply start with the content from the image.- Ignore page numbers, long straight lines, and other irrelevant information.- Use `$$ $$` for block formulas and `$ $` for inline formulas when LaTeX is needed.- Do not enclose the output within any markdown code block delimiters (e.g., ` ```markdown `).3. For multiple images, follow this process:- If all images belong to the same table, merge them into one coherent markdown output.- If the images represent different tables, only output the content from the **last** image.4. Ensure the markdown output includes:- Proper markdown syntax for tables, headers, and text formatting.- LaTeX formatting for mathematical expressions.- Content in red-marked areas, if any.5. Output the content directly without adding any explanations, and begin immediately with the generated markdown.

中文版本,

你是一个AI助手,负责将图像中的内容转换为Markdown和LaTeX语法。请严格按照以下步骤操作:1. 你将接收到一张或多张包含表格的图像,这些图像会以base64编码的形式存储在{{IMAGE}}变量中。2. 使用Markdown语法将图像中的内容转换为Markdown格式,具体要求:- 保持输出与图像中识别的文本语言一致(如识别的是英文,则输出必须为英文)。- 只输出图像中的内容,**不要**添加诸如“以下是生成的Markdown文本...”等解释性语句,直接输出图像中的内容。- 忽略页码、长直线和其他不相关的信息。- 使用`$$ $$`表示块级公式,使用`$ $`表示行内公式(如有LaTeX需求)。- 不要将输出内容包含在任何Markdown代码块中(如 ` ```markdown `)。3. 针对多张图像,请按如下方式处理:- 如果所有图像属于同一个表格,将它们合并为一个完整的Markdown输出。- 如果图像代表不同的表格,则仅输出**最后**一张图像中的内容。4. 确保输出内容包括:- 使用正确的Markdown语法来表示表格、标题和文本格式。- 使用LaTeX格式处理数学表达式。- 包括红框标注的内容(如有)。5. 直接输出生成的Markdown内容,不添加任何解释性文字,并立即开始输出生成的Markdown内容。

2. 原始版本

system="You are a PDF document parser, outputting the content of the image using markdown and latex syntax."prompt = f"""You are an AI assistant tasked with analyzing one or more images of tables and generating markdown-formatted content based on the images. Follow these instructions carefully:1. You will be provided with one or more images of tables. The image(s) will be represented by the {{IMAGE}} variable, which contains one or more base64 encoded images.2. Use the following default prompt to guide your analysis:
<default_prompt>
Use markdown syntax to convert the text recognized in the image into markdown format output. You must:
1. Output in the same language as the recognized text in the image. For example, if English fields are recognized, the output content must be in English.
2. Do not explain or output irrelevant text, directly output the content in the image. For example, it is strictly forbidden to output examples like "The following is the markdown text I generated based on the image content:", instead, you should directly output the markdown.
3. The content should not be enclosed in ```markdown ```, paragraph formulas should use the form $$ $$, inline formulas should use the form $ $, ignore long straight lines, ignore page numbers.
Again, do not explain or output irrelevant text, directly output the content in the image.
</default_prompt>3. Analyze the provided image(s) in {{IMAGE}} according to these steps:a. If there is only one image, proceed to analyze it directly.b. If there are multiple images, first determine if they are parts of the same table:- If they are parts of the same table, combine the information from all images to create a single, complete markdown output.- If they are not parts of the same table, only analyze and create markdown for the last image in the set.4. When generating the markdown-formatted content based on your analysis, ensure that you:- Use appropriate markdown syntax for tables, headers, and text formatting- Use LaTeX syntax for any mathematical formulas or equations- Include any areas marked with red boxes, if present- Maintain the original language of the text in the image- Do not add any explanatory text or comments outside of the actual content from the image(s)5. Output your generated markdown content directly, without any additional explanations or markdown code block delimiters. Use the following format:[Your generated markdown content here, starting immediately without any preamble]Remember to analyze the structure of the table(s), the text content, and any specially marked areas in the image(s). Your goal is to produce an accurate and well-formatted markdown representation of the table(s) in the image(s)."""

完结!

这篇关于Prompt - 将图片的表格转换成Markdown的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1150284

相关文章

使用Python和python-pptx构建Markdown到PowerPoint转换器

《使用Python和python-pptx构建Markdown到PowerPoint转换器》在这篇博客中,我们将深入分析一个使用Python开发的应用程序,该程序可以将Markdown文件转换为Pow... 目录引言应用概述代码结构与分析1. 类定义与初始化2. 事件处理3. Markdown 处理4. 转

Java利用poi实现word表格转excel

《Java利用poi实现word表格转excel》这篇文章主要为大家详细介绍了Java如何利用poi实现word表格转excel,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、每行对象类需要针对不同的表格进行对应的创建。package org.example.wordToEx

基于Python开发批量提取Excel图片的小工具

《基于Python开发批量提取Excel图片的小工具》这篇文章主要为大家详细介绍了如何使用Python中的openpyxl库开发一个小工具,可以实现批量提取Excel图片,有需要的小伙伴可以参考一下... 目前有一个需求,就是批量读取当前目录下所有文件夹里的Excel文件,去获取出Excel文件中的图片,并

Java实现数据库图片上传与存储功能

《Java实现数据库图片上传与存储功能》在现代的Web开发中,上传图片并将其存储在数据库中是常见的需求之一,本文将介绍如何通过Java实现图片上传,存储到数据库的完整过程,希望对大家有所帮助... 目录1. 项目结构2. 数据库表设计3. 实现图片上传功能3.1 文件上传控制器3.2 图片上传服务4. 实现

Java实现将Markdown转换为纯文本

《Java实现将Markdown转换为纯文本》这篇文章主要为大家详细介绍了两种在Java中实现Markdown转纯文本的主流方法,文中的示例代码讲解详细,大家可以根据需求选择适合的方案... 目录方法一:使用正则表达式(轻量级方案)方法二:使用 Flexmark-Java 库(专业方案)1. 添加依赖(Ma

使用EasyExcel实现简单的Excel表格解析操作

《使用EasyExcel实现简单的Excel表格解析操作》:本文主要介绍如何使用EasyExcel完成简单的表格解析操作,同时实现了大量数据情况下数据的分次批量入库,并记录每条数据入库的状态,感兴... 目录前言固定模板及表数据格式的解析实现Excel模板内容对应的实体类实现AnalysisEventLis

Java实现数据库图片上传功能详解

《Java实现数据库图片上传功能详解》这篇文章主要为大家详细介绍了如何使用Java实现数据库图片上传功能,包含从数据库拿图片传递前端渲染,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1、前言2、数据库搭建&nbsChina编程p; 3、后端实现将图片存储进数据库4、后端实现从数据库取出图片给前端5、前端拿到

Python使用PIL库将PNG图片转换为ICO图标的示例代码

《Python使用PIL库将PNG图片转换为ICO图标的示例代码》在软件开发和网站设计中,ICO图标是一种常用的图像格式,特别适用于应用程序图标、网页收藏夹图标等场景,本文将介绍如何使用Python的... 目录引言准备工作代码解析实践操作结果展示结语引言在软件开发和网站设计中,ICO图标是一种常用的图像

使用Python实现表格字段智能去重

《使用Python实现表格字段智能去重》在数据分析和处理过程中,数据清洗是一个至关重要的步骤,其中字段去重是一个常见且关键的任务,下面我们看看如何使用Python进行表格字段智能去重吧... 目录一、引言二、数据重复问题的常见场景与影响三、python在数据清洗中的优势四、基于Python的表格字段智能去重

SpringBoot集成图片验证码框架easy-captcha的详细过程

《SpringBoot集成图片验证码框架easy-captcha的详细过程》本文介绍了如何将Easy-Captcha框架集成到SpringBoot项目中,实现图片验证码功能,Easy-Captcha是... 目录SpringBoot集成图片验证码框架easy-captcha一、引言二、依赖三、代码1. Ea