Administrator
发布于 2026-04-09 / 2 阅读
0
0

AI 试卷识别的解决方案技术实现

curl --location 'https://ark.cn-beijing.volces.com/api/v3/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ' \
--data '{
      "model": "doubao-seed-1-8",
    "messages": [
        {
            "content": "你是一个试题录入工具人 你识别试题的流程 1、先识别题干(1. (1) 一、 (一))类似的分割作为题的拆分",
            "role": "system"
        },
        {
            "content": [
                {
                    "image_url": "https://xthk-knowledge-center.oss-cn-shenzhen.aliyuncs.com/topic/3d06dfee-f0e8-4b98-aa2b-a0d714cb84b9_merged_1766461906167535000.png",
                    "type": "image_url"
                }
            ],
            "role": "user"
        }
    ],
  
    "response_format": {
        "json_schema": {
            "name": "universal_topic_schema",
            "schema": {
                "additionalProperties": false,
                "properties": {
                    "answer": {
                        "description": "题目答案集合,不同题型格式不同",
                        "items": {
                            "additionalProperties": false,
                            "properties": {
                                "id": {
                                    "description": "答案项唯一ID",
                                    "type": "integer"
                                },
                                "topic_answer": {
                                    "description": "答案内容:单选=[选项ID数组],填空=[[答案文本数组]],简答=\u003cp\u003e答案文本\u003c/p\u003e,组合=混合格式",
                                    "type": [
                                        "array",
                                        "string"
                                    ]
                                },
                                "topic_type": {
                                    "description": "对应题型(原题型/子题型)的类型标识",
                                    "type": "integer"
                                }
                            },
                            "required": [
                                "id",
                                "topic_type",
                                "topic_answer"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "children": {
                        "description": "子题目列表,仅组合题填充有效子题,其他题型传空数组",
                        "items": {
                            "additionalProperties": false,
                            "properties": {
                                "id": {
                                    "description": "子题目唯一标识ID",
                                    "type": "integer"
                                },
                                "topic_analysis": {
                                    "description": "子题目解析,通常包含HTML标签\u003cp\u003e包裹文本",
                                    "type": "string"
                                },
                                "topic_answer": {
                                    "description": "子题目答案,格式与对应子题型一致",
                                    "type": [
                                        "array",
                                        "string"
                                    ]
                                },
                                "topic_body": {
                                    "description": "子题干内容,通常包含HTML标签\u003cp\u003e包裹文本",
                                    "type": "string"
                                },
                                "topic_option": {
                                    "description": "子题目选项列表,子单选题填充有效选项,其他子题型传空数组",
                                    "items": {
                                        "additionalProperties": false,
                                        "properties": {
                                            "id": {
                                                "description": "子选项唯一ID",
                                                "type": "integer"
                                            },
                                            "is_answer": {
                                                "description": "子选项是否为正确答案:0=否,1=是",
                                                "type": "integer"
                                            },
                                            "option_title": {
                                                "description": "子选项内容,如“选项A:xxx”",
                                                "type": "string"
                                            }
                                        },
                                        "required": [
                                            "id",
                                            "option_title",
                                            "is_answer"
                                        ],
                                        "type": "object"
                                    },
                                    "type": "array"
                                },
                                "topic_type": {
                                    "description": "子题型类型(支持1/4/5等基础题型)",
                                    "type": "integer"
                                }
                            },
                            "required": [
                                "id",
                                "topic_type",
                                "topic_body",
                                "topic_analysis",
                                "topic_answer"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "topic_body": {
                        "description": "题干内容,通常包含HTML标签\u003cp\u003e包裹文本",
                        "type": "string"
                    },
                    "topic_option": {
                        "description": "选项列表,单选题填充有效选项,填空/简答/组合题传空数组",
                        "items": {
                            "additionalProperties": false,
                            "properties": {
                                "id": {
                                    "description": "选项唯一ID",
                                    "type": "integer"
                                },
                                "is_answer": {
                                    "description": "是否为正确答案:0=否,1=是",
                                    "type": "integer"
                                },
                                "option_title": {
                                    "description": "选项内容,如“选项A:xxx”",
                                    "type": "string"
                                }
                            },
                            "required": [
                                "id",
                                "option_title",
                                "is_answer"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "topic_type": {
                        "description": "题型类型:1=单选题,4=填空题,5=简答题,6=组合题",
                        "type": "integer"
                    }
                },
                "required": [
                    "topic_type",
                    "topic_body",
                    "topic_option",
                    "answer",
                    "children"
                ],
                "strict": true,
                "type": "object"
            }
        },
        "type": "json_schema"
    },
    "thinking": {
        "type": "disabled"
    }
}'

核心解决思路就是一点利用 大模型的VL 图片理解能力,以及输出json的能力将 图片内容转化为满足业务系统标准的JSON 格式数据

火山的标准

结构化输出(beta)

https://www.volcengine.com/docs/82379/1798161?lang=zh#20fd65fa


评论