Instructions to use Kimang18/deepseek_ocr_Khmer_finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Kimang18/deepseek_ocr_Khmer_finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Kimang18/deepseek_ocr_Khmer_finetuned", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Kimang18/deepseek_ocr_Khmer_finetuned", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use Kimang18/deepseek_ocr_Khmer_finetuned with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kimang18/deepseek_ocr_Khmer_finetuned to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Kimang18/deepseek_ocr_Khmer_finetuned to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Kimang18/deepseek_ocr_Khmer_finetuned to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Kimang18/deepseek_ocr_Khmer_finetuned", max_seq_length=2048, )
Objective
Fine-tune deepseek-ai/DeepSeek-OCR on WildKhmerST.
The setting for image processing is the following
base_size=512
image_size=512
crop_mode=False
The setting for LoRA is the following
model = FastVisionModel.get_peft_model(
model,
target_modules = [
"q_proj",
"k_proj",
"v_proj",
"o_proj",
"gate_proj",
"up_proj",
"down_proj",
],
r = 16, # The larger, the higher the accuracy, but might overfit
lora_alpha = 16, # Recommended alpha == r at least
lora_dropout = 0,
bias = "none",
random_state = 3407,
use_rslora = False, # We support rank stabilized LoRA
loftq_config = None, # And LoftQ
# target_modules = "all-linear", # Optional now! Can specify a list if needed
)
For future benchmarking in Khmer OCR task, WildKhmerST is processed to contains pairs of 'text region image' and 'text'.
The processed dataset is uploaded to huggingface platform here.
There are 3 splits. train split is used to fine-tune unsloth/DeepSeek-OCR.
test split is used to evaluate the fine-tuned model.
The fine-tuned model performs better on Khmer text, yet it still completely misses some images in the test split.
Concretely, its cer on the whole test split is 237% (result file can be found here)
This is because when the fine-tuned completely misses decoding some images, it hallucinates and then repeats the same text token until the number of maximum tokens is met.
Removing hallucinating cases, cer drops to 67.66% (result file can be found here).
Uploaded finetuned model
- Developed by: Kimang18
- License: apache-2.0
- Finetuned from model : deepseek-ai/DeepSeek-OCR
This deepseek_vl_v2 model was trained 2x faster with Unsloth and Huggingface's TRL library.
Usage
TBA
- Downloads last month
- 146
Model tree for Kimang18/deepseek_ocr_Khmer_finetuned
Base model
deepseek-ai/DeepSeek-OCR