jeanflop commited on
Commit
1a4050f
·
verified ·
1 Parent(s): 1802676

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -1
README.md CHANGED
@@ -2,7 +2,60 @@
2
  library_name: transformers
3
  datasets:
4
  - jeanflop/post_ocr_correction-512
 
 
 
 
 
5
  ---
6
 
7
 
8
- This model has been finetune on french OCR dataset. The architecture used is Flan T large. On a sample of 1000. More stong model is under cooks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
  datasets:
4
  - jeanflop/post_ocr_correction-512
5
+ language:
6
+ - fr
7
+ - en
8
+ base_model:
9
+ - google/flan-t5-large
10
  ---
11
 
12
 
13
+ This model lora weight has been finetune on french OCR dataset. The architecture used is Flan T large. On a sample of 1000. More stong model is under cooks.
14
+
15
+ * **Install dependencies**
16
+
17
+ ```bash
18
+ !pip install -q transformers accelerate peft diffusers
19
+ ```
20
+ * **Load and merge adaptaters in 8Bit** (recommanded)
21
+
22
+ ```
23
+ import torch
24
+ from peft import PeftModel, PeftConfig
25
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer,BitsAndBytesConfig
26
+
27
+ # Load peft config for pre-trained checkpoint etc.
28
+ peft_model_id = "jeanflop/ocr_correcteur-v1"
29
+ config = PeftConfig.from_pretrained(peft_model_id)
30
+
31
+ # load base LLM model and tokenizer
32
+ peft_model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map={"":1})
33
+ peft_tokenizer = AutoTokenizer.from_pretrained('google/flan-t5-large')
34
+
35
+ # Load the Lora model
36
+ peft_model = PeftModel.from_pretrained(peft_model, peft_model_id, device_map={"":1})
37
+ # model.eval()
38
+
39
+ print("Peft model loaded")
40
+ ```
41
+ * **Run inference** (recommanded)
42
+
43
+ Add your text
44
+
45
+ ```
46
+ inputs=f"""
47
+ Fix text : {text}"""
48
+ ```
49
+ Run
50
+ ```
51
+ peft_model.config.max_length=512
52
+ peft_tokenizer.model_max_length=512
53
+ inputs = peft_tokenizer(inputs, return_tensors="pt")
54
+ outputs = peft_model.generate(**inputs,max_length=512)
55
+ answer = tokenizer.decode(outputs[0])
56
+ from textwrap import fill
57
+
58
+ print(fill(answer, width=80))
59
+ ```
60
+
61
+