Text Generation
Transformers
Safetensors
DIVEdoc
docvqa
distillation
VLM
document-understanding
OCR-free
custom_code
Instructions to use JayRay5/DIVE-Doc-FRD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JayRay5/DIVE-Doc-FRD with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JayRay5/DIVE-Doc-FRD", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("JayRay5/DIVE-Doc-FRD", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use JayRay5/DIVE-Doc-FRD with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JayRay5/DIVE-Doc-FRD" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JayRay5/DIVE-Doc-FRD", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/JayRay5/DIVE-Doc-FRD
- SGLang
How to use JayRay5/DIVE-Doc-FRD with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "JayRay5/DIVE-Doc-FRD" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JayRay5/DIVE-Doc-FRD", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "JayRay5/DIVE-Doc-FRD" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JayRay5/DIVE-Doc-FRD", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use JayRay5/DIVE-Doc-FRD with Docker Model Runner:
docker model run hf.co/JayRay5/DIVE-Doc-FRD
Update README.md
Browse files
README.md
CHANGED
|
@@ -6,6 +6,12 @@ datasets:
|
|
| 6 |
- pixparse/docvqa-single-page-questions
|
| 7 |
spaces:
|
| 8 |
- JayRay5/DIVE-Doc-docvqa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
## 1 Introduction
|
|
@@ -37,9 +43,30 @@ Trained on the [DocVQA dataset](https://openaccess.thecvf.com/content/WACV2021/h
|
|
| 37 |
|
| 38 |
#### From the Transformers library
|
| 39 |
```bash
|
| 40 |
-
from transformers import AutoModelForCausalLM
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
```
|
| 44 |
|
| 45 |
#### From the GitHub repository
|
|
|
|
| 6 |
- pixparse/docvqa-single-page-questions
|
| 7 |
spaces:
|
| 8 |
- JayRay5/DIVE-Doc-docvqa
|
| 9 |
+
tags:
|
| 10 |
+
- docvqa
|
| 11 |
+
- distillation
|
| 12 |
+
- VLM
|
| 13 |
+
- document-understanding
|
| 14 |
+
- OCR-free
|
| 15 |
---
|
| 16 |
|
| 17 |
## 1 Introduction
|
|
|
|
| 43 |
|
| 44 |
#### From the Transformers library
|
| 45 |
```bash
|
| 46 |
+
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 47 |
+
from PIL import Image
|
| 48 |
+
import torch
|
| 49 |
|
| 50 |
+
processor = AutoProcessor.from_pretrained("JayRay5/DIVE-Doc-FRD", trust_remote_code=True)
|
| 51 |
+
model = AutoModelForCausalLM.from_pretrained("JayRay5/DIVE-Doc-FRD", trust_remote_code=True)
|
| 52 |
+
|
| 53 |
+
image = Image.open("your_image_document_path/image_document.png").convert("RGB")
|
| 54 |
+
question_example = "What the the name of the author"
|
| 55 |
+
|
| 56 |
+
inputs = (
|
| 57 |
+
processor(text=question_example, images=image, return_tensors="pt", padding=True)
|
| 58 |
+
.to(model.device)
|
| 59 |
+
.to(model.dtype)
|
| 60 |
+
)
|
| 61 |
+
input_length = inputs["input_ids"].shape[-1]
|
| 62 |
+
|
| 63 |
+
with torch.inference_mode():
|
| 64 |
+
output_ids = model.generate(**inputs, max_new_tokens=100, do_sample=False)
|
| 65 |
+
|
| 66 |
+
generated_ids = output_ids[0][input_length:]
|
| 67 |
+
answer = processor.decode(generated_ids, skip_special_tokens=True)
|
| 68 |
+
|
| 69 |
+
print(answer)
|
| 70 |
```
|
| 71 |
|
| 72 |
#### From the GitHub repository
|