CoolFace
Modelpublic

bryanha/Declaration-Form-Audit

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes
README.md235 linesDownload Raw Back to root
1---2license: apache-2.03language:4- zh5- en6base_model:7- Qwen/Qwen3-VL-8B-Instruct8pipeline_tag: image-text-to-text9tags:10- Declaration-Form11- Audit12- vision13- multimodal14- customs15- document-understanding16---17 18 19     20 21<h1> Customs Declaration-Form-Audit VLM </h1>22 23 24<h5 align="center"> 25 26<p align="center">27  28</p>29 30 31</h5>32</div>33 34 35 36     专为报关单证智能审核优化的多模态视觉语言模型。37 38 39     ## 🎯 模型功能40 41     本模型专注于进出口报关单证的智能审核任务,具备以下核心能力:42 43     ### 单证信息提取44     - **证书类型识别**:卫生证书、原产地证书、检验报告、合同、发票等45     - **关键字段提取**:证书编号、集装箱号、件数、净重、毛重46     - **商品明细解析**:逐行提取表格数据(商品名称、数量、金额等)47     - **日期信息提取**:签发日期、有效期、生产日期48 49     ### 表格数据处理50     - 支持复杂多列表格的逐行扫描51     - 准确识别数字、日期、文本混合内容52     - 自动处理表格合并单元格和分栏结构53 54     ### 多语言OCR55     - 中文、英文、西班牙语、日文、俄文等多语言混合识别56     - 支持手写体和印刷体混合文档57     - 模糊字符智能识别优化58 59     ### 单证比对审核60     - 比对报关单与随附证书的一致性61     - 识别数据异常和潜在风险点62     - 生成结构化审核结果63 64     ## 🔧 模型训练65 66     ### 训练方法67     本模型采用初期审单领域知识注入(CPT)+多阶段监督微调(SFT)+ 2阶段强化学习(RL)**的训练策略:68 69     1. **视觉-语言对齐阶段**:增强模型对单证图像的理解能力70     2. **领域数据适配阶段**:学习海关报关单证的专业术语和格式71     3. **任务专项优化阶段**:针对表格提取、字段识别等具体任务强化训练72     4. **多任务融合阶段**:综合提升各项审核能力73 74     ### 训练数据规模75     - 监督学习阶段:约70万条高质量标注样本76     - 强化学习阶段:约15万条审核任务数据77     - 覆盖20+国家/地区的单证格式78 79     ## 📄 疑难PDF处理能力80 81     ### 低质量图像优化82     本模型在训练中特别针对实际业务中的疑难PDF进行了优化:83     84     1. 特殊类型的证书编号:85 86![wechat_2026-02-10_153652_180](https://cdn-uploads.huggingface.co/production/uploads/679f3301b6a9cac2b8154fac/eK4r6TuVmGsJ63AO3IX1z.png)87 88     2. 负责表格数据提取及汇总:89 90![wechat_2026-02-10_154616_288](https://cdn-uploads.huggingface.co/production/uploads/679f3301b6a9cac2b8154fac/Zx0iN8w210JnheF_eR-CK.png)91 92     93     3. 不规范表格的提取:94![wechat_2026-02-10_154730_980](https://cdn-uploads.huggingface.co/production/uploads/679f3301b6a9cac2b8154fac/btTW8h00LWyNKDwOXUAda.png)95 96 97     4. 跨页单据的提取累加:98 99![wechat_2026-02-10_154844_598](https://cdn-uploads.huggingface.co/production/uploads/679f3301b6a9cac2b8154fac/s-HKZLXpZPU_hErJpVWhi.png)100 101     102 103     ### 实测效果104 105     | 测试场景 | 准确率 | 106     |---------|-------|107     | 证书编号识别 | 99%+ | 108     | 集装箱号提取 | 98%+ |109     | 表格数据提取 | 99%+ | 110     | 件数重量识别 | 99%+ |111 112     ## 🚀 快速开始113 114     ### 安装依赖115 116     ```bash117     pip install transformers torch pillow118     ```119 120     ### Python推理121 122     ```python123     from transformers import Qwen2VLForConditionalGeneration, AutoProcessor124     from PIL import Image125     import torch126 127     # 加载模型128     model = Qwen2VLForConditionalGeneration.from_pretrained(129         "shihao1989/Declaration-Form-Audit",130         torch_dtype=torch.bfloat16,131         device_map="auto"132     )133     processor = AutoProcessor.from_pretrained("shihao1989/Declaration-Form-Audit")134 135     # 准备输入136     image = Image.open("certificate.jpg")137     messages = [138         {139             "role": "user",140             "content": [141                 {"type": "image"},142     {143       "type": "text",144       "text": "请提取这份证书的证书编号、集装箱号、件数和净重。"145     }146             ]147         }148     ]149 150     # 推理151     text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)152     inputs = processor(text=[text], images=[image], return_tensors="pt").to("cuda")153 154     output = model.generate(**inputs, max_new_tokens=512, temperature=0.1)155     result = processor.batch_decode(output, skip_special_tokens=True)[0]156     print(result)157     ```158 159     ### vLLM部署(生产推荐)160 161     ```bash162     docker run -d \163       --name declaration-audit \164       --runtime=nvidia \165       -e NVIDIA_VISIBLE_DEVICES=0 \166       --ipc=host \167       -p 8000:8000 \168       vllm/vllm-openai:latest \169       --model shihao1989/Declaration-Form-Audit \170       --trust-remote-code \171       --max-model-len 32000 \172       --gpu-memory-utilization 0.9173     ```174 175     ### API调用176 177     ```python178     import requests179     import base64180 181     with open("certificate.jpg", "rb") as f:182         image_b64 = base64.b64encode(f.read()).decode()183 184     response = requests.post("http://localhost:8000/v1/chat/completions", json={185         "model": "shihao1989/Declaration-Form-Audit",186         "messages": [187             {188                 "role": "user",189                 "content": [190                     {"type": "text", "text": "提取证书编号和净重"},191                     {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_b64}"}}192                 ]193             }194         ],195         "max_tokens": 512,196         "temperature": 0.1197     })198 199     print(response.json()["choices"][0]["message"]["content"])200     ```201 202     ## 💡 最佳实践203 204     ### Prompt设计建议205 206     **推荐格式(结构化输出):**207     ```208     请从这份原产地证书中提取以下字段,返回JSON格式:209     {210       "cert_code": "证书编号",211       "containers": ["集装箱号列表"],212       "packages": 件数(整数),213       "net_weight_kg": 净重(数字)214     }215     只输出JSON,不要有额外文字。216     ```217 218     **关键原则:**219     - 明确指定提取字段和格式220     - 提供字段的可能名称(如"证书编号/Certificate No.")221     - 使用JSON等结构化格式便于后处理222 223     ## 📜 许可证224 225     本模型遵循 Apache 2.0 许可证。226 227     ## 🙏 致谢228 229     - Qwen团队提供的优秀基座模型230     - 海关业务专家提供的领域知识指导231 232     ## 📮 联系方式233 234     如有问题或建议,欢迎通过Hugging Face Discussions交流。235     邮箱:199416378@qq.com