layoutlmv2 base uncased finetuned docvqa
简介
核心亮点
- 多模态理解:同步处理文本、布局与图像信息
- 专注文档问答:精准提取结构化文档中的关键信息
- 工业级场景:适用于发票、合同等复杂表单解析
- 开源生态:基于主流 LayoutLMv2,易于部署集成
使用方法
# 安装 Hugging Face transformers
pip install transformers torch
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa")
tokenizer = AutoTokenizer.from_pretrained("tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa")
Hugging Face 下载
我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。
操作指引:在下载前,请先通过如下命令安装 huggingface_hub:
pip install -U huggingface_hub
命令行下载
下载完整模型库
huggingface-cli download tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa
下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa config.json --local-dir ./dir
SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa')
Git 下载
请确保 lfs 已经被正确安装
git lfs install
git clone https://huggingface.co/tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa
如果您希望跳过 lfs 大文件下载,可以使用如下命令
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa
模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。
PyTorch / Transformers 使用
安装 Transformers
pip install -U transformers torch
模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa')
tokenizer = AutoTokenizer.from_pretrained('tiennvcs/layoutlmv2-base-uncased-finetuned-docvqa')
完整文档
---
license: cc-by-sa-4.0
tags:
- generated_from_trainer
model-index:
- name: layoutlmv2-base-uncased-finetuned-docvqa
results: []
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
layoutlmv2-base-uncased-finetuned-docvqa
This model is a fine-tuned version of microsoft/layoutlmv2-base-uncased on an unknown dataset.
It achieves the following results on the evaluation set:
- Loss: 1.1940
Model description
More information needed
Intended uses & limitations
More information needed
Training and evaluation data
More information needed
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 250500
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 2
Training results
| Training Loss | Epoch | Step | Validation Loss |
|:-------------:|:-----:|:----:|:---------------:|
| 1.463 | 0.27 | 1000 | 1.6272 |
| 0.9447 | 0.53 | 2000 | 1.3646 |
| 0.7725 | 0.8 | 3000 | 1.2560 |
| 0.5762 | 1.06 | 4000 | 1.3582 |
| 0.4382 | 1.33 | 5000 | 1.2490 |
| 0.4515 | 1.59 | 6000 | 1.1860 |
| 0.383 | 1.86 | 7000 | 1.1940 |
Framework versions
- Transformers 4.12.2
- Pytorch 1.8.0+cu101
- Datasets 1.14.0
- Tokenizers 0.10.3