giayphuyen commited on
Commit
660e429
·
verified ·
1 Parent(s): 94285db

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: deepseek-ai/DeepSeek-OCR
3
+ library_name: peft
4
+ tags:
5
+ - lora
6
+ - ocr
7
+ - deepseek
8
+ - unsloth
9
+ pipeline_tag: image-text-to-text
10
+ license: mit
11
+ ---
12
+
13
+ # LoRA Adapter for DeepSeek-OCR (Vietnamese Bills)
14
+
15
+ This repository contains LoRA fine-tuned weights for the model
16
+ **deepseek-ai/DeepSeek-OCR**, specialized for OCR tasks.
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ from transformers import AutoModel, AutoTokenizer
22
+ from peft import PeftModel
23
+ import torch
24
+
25
+ base = "deepseek-ai/DeepSeek-OCR"
26
+ lora = "giayphuyen/lora_model"
27
+
28
+ tokenizer = AutoTokenizer.from_pretrained(base, trust_remote_code=True)
29
+ model = AutoModel.from_pretrained(base, trust_remote_code=True).cuda()
30
+
31
+ model = PeftModel.from_pretrained(model, lora)
32
+ model = model.eval().to(torch.bfloat16)
33
+
34
+ prompt = "<image>\nExtract the text."
35
+ image = "your_image.jpg"
36
+
37
+ res = model.infer(
38
+ tokenizer,
39
+ prompt=prompt,
40
+ image_file=image,
41
+ output_path=".",
42
+ )
43
+ print(res)
adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "DeepseekOCRForCausalLM",
7
+ "parent_library": "transformers_modules.deepseek_ocr.modeling_deepseekocr",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "./deepseek_ocr",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.0",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "o_proj",
37
+ "up_proj",
38
+ "k_proj",
39
+ "v_proj",
40
+ "down_proj",
41
+ "gate_proj",
42
+ "q_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:433c792704bc2ec04011e6c221d06f6a8976d6b57e2b726ed7859ec74dfa2a08
3
+ size 310662536
special_tokens_map.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|User|>",
4
+ "<|Assistant|>"
5
+ ],
6
+ "bos_token": {
7
+ "content": "<|begin▁of▁sentence|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "eos_token": {
14
+ "content": "<|end▁of▁sentence|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "pad_token": {
21
+ "content": "<|▁pad▁|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ }
27
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff