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7 |
+
|
8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
|
10 |
+
This a finetune codellama model finetuned to convert OCR scan result (eg. PaddleOCR) text array to structure json object. the input include ocr text array and ground truth boxes.
|
11 |
+
|
12 |
+
## Model Details
|
13 |
+
|
14 |
+
training dataset: [ mychen76/cord-ocr-text-v2 ]
|
15 |
+
enhanced version of original: naver-clova-ix/cord-v2
|
16 |
+
|
17 |
+
Usage-1 Input OCR text array and context boxes:
|
18 |
+
|
19 |
+
eval_prompt = """### Instruction:
|
20 |
+
Use the Input below and Context details to create an strucuture receipt data. The output must be a well-formed JSON object: ```json
|
21 |
+
### Input:
|
22 |
+
["BAKS", "Nasgor Jawa", "32.727", "Jeruk Panas", "19.091", "1Air Mineral", "9.091", "Net Total", "60.909", "P.Resto 10", "6.091", "3 Total", "67.000", "CASH", "67.000"]
|
23 |
+
|
24 |
+
### Context:
|
25 |
+
[[[[131.0, 210.0], [327.0, 210.0], [327.0, 251.0], [131.0, 251.0]], ["BAKS", 0.9765313863754272]], [[[120.0, 378.0], [273.0, 380.0], [273.0, 400.0], [120.0, 398.0]], ["Nasgor Jawa", 0.9626438021659851]], [[[340.0, 381.0], [419.0, 381.0], [419.0, 399.0], [340.0, 399.0]], ["32.727", 0.9828599095344543]], [[[106.0, 398.0], [271.0, 400.0], [271.0, 418.0], [106.0, 416.0]], ["Jeruk Panas", 0.9557318091392517]], [[[340.0, 401.0], [417.0, 401.0], [417.0, 419.0], [340.0, 419.0]], ["19.091", 0.995367705821991]], [[[98.0, 417.0], [269.0, 419.0], [269.0, 436.0], [98.0, 434.0]], ["1Air Mineral", 0.9278557300567627]], [[[348.0, 416.0], [418.0, 418.0], [418.0, 439.0], [348.0, 437.0]], ["9.091", 0.9945915937423706]], [[[97.0, 455.0], [217.0, 455.0], [217.0, 475.0], [97.0, 475.0]], ["Net Total", 0.9419357776641846]], [[[336.0, 455.0], [419.0, 457.0], [419.0, 478.0], [336.0, 476.0]], ["60.909", 0.9923689961433411]], [[[97.0, 475.0], [243.0, 474.0], [243.0, 494.0], [97.0, 495.0]], ["P.Resto 10", 0.8946446180343628]], [[[350.0, 477.0], [415.0, 477.0], [415.0, 495.0], [350.0, 495.0]], ["6.091", 0.9968243837356567]], [[[94.0, 495.0], [193.0, 497.0], [192.0, 533.0], [93.0, 531.0]], ["3 Total", 0.9634256362915039]], [[[334.0, 495.0], [420.0, 495.0], [420.0, 535.0], [334.0, 535.0]], ["67.000", 0.9943265914916992]], [[[91.0, 552.0], [154.0, 552.0], [154.0, 596.0], [91.0, 596.0]], ["CASH", 0.9981260895729065]], [[[335.0, 553.0], [419.0, 553.0], [419.0, 594.0], [335.0, 594.0]], ["67.000", 0.9952940344810486]]]
|
26 |
+
|
27 |
+
### Response:
|
28 |
+
"""
|
29 |
+
## expect output
|
30 |
+
## {"menu": [{"nm": "Nasgor Jawa", "cnt": "1", "price": "32.727"}, {"nm": "Jeruk Panas", "cnt": "1", "price": "19.091"}, {"nm": "Air Mineral", "cnt": "1", "price": "9.091"}], "sub_total": {"subtotal_price": "60.909", "tax_price": "6.091"}, "total": {"total_price": "67.000", "cashprice": "67.000", "menutype_cnt": "3"}}
|
31 |
+
|
32 |
+
input_ids = tokenizer(eval_prompt, return_tensors="pt", truncation=True).input_ids.cuda()
|
33 |
+
outputs = model.generate(input_ids=input_ids, max_new_tokens=100, do_sample=True, top_p=0.9,temperature=0.9)
|
34 |
+
print(f"Generated instruction:\n{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(eval_prompt):]}")
|
35 |
+
|
36 |
+
***Generated instruction:***
|
37 |
+
|
38 |
+
{"menu": [{"nm": "BAKS"}, {"nm": "apple"}, {"nm": "banada"}, {"nm": "Mineral Water"}], "sub_total": {"subtotal_price": "60.909"}, "total": {"total_price": "67.000", "cashprice": "67.000", "changeprice": "0"}}
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
### Model Description
|
43 |
+
|
44 |
+
<!-- Provide a longer summary of what this model is. -->
|
45 |
+
|
46 |
+
- **Developed by: mychen776** [More Information Needed]
|
47 |
+
- **Shared by [optional]:** [More Information Needed]
|
48 |
+
- **Model type:** [More Information Needed]
|
49 |
+
- **Language(s) (NLP):** [More Information Needed]
|
50 |
+
- **License:** [More Information Needed]
|
51 |
+
- **Finetuned from model [codellama/CodeLlama-34b-Instruct-hf]:** [More Information Needed]
|
52 |
+
|
53 |
+
### Model Sources [optional]
|
54 |
+
|
55 |
+
<!-- Provide the basic links for the model. -->
|
56 |
+
|
57 |
+
- **Repository:** [More Information Needed]
|
58 |
+
- **Paper [optional]:** [More Information Needed]
|
59 |
+
- **Demo [optional]:** [More Information Needed]
|
60 |
+
|
61 |
+
## Uses
|
62 |
+
|
63 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
64 |
+
|
65 |
+
### Direct Use
|
66 |
+
|
67 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
68 |
+
|
69 |
+
[More Information Needed]
|
70 |
+
|
71 |
+
### Downstream Use [optional]
|
72 |
+
|
73 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
74 |
+
|
75 |
+
[More Information Needed]
|
76 |
+
|
77 |
+
### Out-of-Scope Use
|
78 |
+
|
79 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
80 |
+
|
81 |
+
[More Information Needed]
|
82 |
+
|
83 |
+
## Bias, Risks, and Limitations
|
84 |
+
|
85 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
86 |
+
|
87 |
+
[More Information Needed]
|
88 |
+
|
89 |
+
### Recommendations
|
90 |
+
|
91 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
92 |
+
|
93 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
94 |
+
|
95 |
+
## How to Get Started with the Model
|
96 |
+
|
97 |
+
Use the code below to get started with the model.
|
98 |
+
|
99 |
+
[More Information Needed]
|
100 |
+
|
101 |
+
## Training Details
|
102 |
+
|
103 |
+
### Training Data
|
104 |
+
|
105 |
+
<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
106 |
+
|
107 |
+
[More Information Needed]
|
108 |
+
|
109 |
+
### Training Procedure
|
110 |
+
|
111 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
112 |
+
|
113 |
+
#### Preprocessing [optional]
|
114 |
+
|
115 |
+
[More Information Needed]
|
116 |
+
|
117 |
+
|
118 |
+
#### Training Hyperparameters
|
119 |
+
|
120 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
121 |
+
|
122 |
+
#### Speeds, Sizes, Times [optional]
|
123 |
+
|
124 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
125 |
+
|
126 |
+
[More Information Needed]
|
127 |
+
|
128 |
+
## Evaluation
|
129 |
+
|
130 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
131 |
+
|
132 |
+
### Testing Data, Factors & Metrics
|
133 |
+
|
134 |
+
#### Testing Data
|
135 |
+
|
136 |
+
<!-- This should link to a Data Card if possible. -->
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
#### Factors
|
141 |
+
|
142 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
143 |
+
|
144 |
+
[More Information Needed]
|
145 |
+
|
146 |
+
#### Metrics
|
147 |
+
|
148 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
149 |
+
|
150 |
+
[More Information Needed]
|
151 |
+
|
152 |
+
### Results
|
153 |
+
|
154 |
+
[More Information Needed]
|
155 |
+
|
156 |
+
#### Summary
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
## Model Examination [optional]
|
161 |
+
|
162 |
+
<!-- Relevant interpretability work for the model goes here -->
|
163 |
+
|
164 |
+
[More Information Needed]
|
165 |
+
|
166 |
+
## Environmental Impact
|
167 |
+
|
168 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
169 |
+
|
170 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
171 |
+
|
172 |
+
- **Hardware Type:** [More Information Needed]
|
173 |
+
- **Hours used:** [More Information Needed]
|
174 |
+
- **Cloud Provider:** [More Information Needed]
|
175 |
+
- **Compute Region:** [More Information Needed]
|
176 |
+
- **Carbon Emitted:** [More Information Needed]
|
177 |
+
|
178 |
+
## Technical Specifications [optional]
|
179 |
+
|
180 |
+
### Model Architecture and Objective
|
181 |
+
|
182 |
+
[More Information Needed]
|
183 |
+
|
184 |
+
### Compute Infrastructure
|
185 |
+
|
186 |
+
[More Information Needed]
|
187 |
+
|
188 |
+
#### Hardware
|
189 |
+
|
190 |
+
[More Information Needed]
|
191 |
+
|
192 |
+
#### Software
|
193 |
+
|
194 |
+
[More Information Needed]
|
195 |
+
|
196 |
+
## Citation [optional]
|
197 |
+
|
198 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
199 |
+
|
200 |
+
**BibTeX:**
|
201 |
+
|
202 |
+
[More Information Needed]
|
203 |
+
|
204 |
+
**APA:**
|
205 |
+
|
206 |
+
[More Information Needed]
|
207 |
+
|
208 |
+
## Glossary [optional]
|
209 |
+
|
210 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
211 |
+
|
212 |
+
[More Information Needed]
|
213 |
+
|
214 |
+
## More Information [optional]
|
215 |
+
|
216 |
+
[More Information Needed]
|
217 |
+
|
218 |
+
## Model Card Authors [optional]
|
219 |
+
|
220 |
+
[More Information Needed]
|
221 |
+
|
222 |
+
## Model Card Contact
|
223 |
+
|
224 |
+
[More Information Needed]
|
225 |
+
|
226 |
+
|