Run this model with HF Jobs

Run TusharGoel/LiLT-Document-QA on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/TusharGoel/LiLT-Document-QA. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/TusharGoel/LiLT-Document-QA on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

LiLT Model Read Here. This model being fine-tuned on English DocVQA

from transformers import AutoTokenizer, AutoModelForQuestionAnswering
from datasets import load_dataset

model_checkpoint = "TusharGoel/LiLT-Document-QA"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, add_prefix_space=True)
model_predict = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)

model_predict.eval()
dataset = load_dataset("nielsr/funsd", split="train")
example = dataset[0]
print(example)

question = "What is the Licensee Number?"
print(question)

words = example["words"]
boxes = example["bboxes"]

encoding = tokenizer(question, words, boxes = boxes, return_token_type_ids=True, return_tensors="pt")

word_ids = encoding.word_ids(0)
outputs = model_predict(**encoding)

loss = outputs.loss
start_scores = outputs.start_logits
end_scores = outputs.end_logits

start, end = word_ids[start_scores.argmax(-1).item()], word_ids[end_scores.argmax(-1).item()]
# print(start, end)
print(" ".join(words[start : end + 1]))
Downloads last month
87
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Spaces using TusharGoel/LiLT-Document-QA 2

Paper for TusharGoel/LiLT-Document-QA