jeremyarancio
commited on
Commit
·
cee2657
1
Parent(s):
f7ede15
update readme
Browse files
README.md
CHANGED
@@ -1,205 +1,83 @@
|
|
1 |
---
|
2 |
-
library_name: peft
|
3 |
base_model: mistralai/Mistral-7B-v0.3
|
4 |
license: agpl-3.0
|
5 |
---
|
6 |
|
7 |
-
#
|
8 |
|
9 |
-
|
10 |
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
## Model Details
|
14 |
|
15 |
### Model Description
|
16 |
|
17 |
-
|
18 |
-
|
19 |
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
- **Shared by [optional]:** [More Information Needed]
|
24 |
-
- **Model type:** [More Information Needed]
|
25 |
-
- **Language(s) (NLP):** [More Information Needed]
|
26 |
-
- **License:** [More Information Needed]
|
27 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
- **Repository:**
|
34 |
-
- **
|
35 |
-
- **Demo [optional]:** [More Information Needed]
|
36 |
|
37 |
## Uses
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
### Direct Use
|
42 |
-
|
43 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
44 |
-
|
45 |
-
[More Information Needed]
|
46 |
-
|
47 |
-
### Downstream Use [optional]
|
48 |
-
|
49 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
50 |
-
|
51 |
-
[More Information Needed]
|
52 |
-
|
53 |
-
### Out-of-Scope Use
|
54 |
|
55 |
-
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
|
|
|
|
|
|
60 |
|
61 |
-
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
Use the code below to get started with the model.
|
74 |
-
|
75 |
-
[More Information Needed]
|
76 |
|
77 |
## Training Details
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
<!-- This should link to a Dataset 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. -->
|
82 |
-
|
83 |
-
[More Information Needed]
|
84 |
-
|
85 |
-
### Training Procedure
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
#### Preprocessing [optional]
|
90 |
-
|
91 |
-
[More Information Needed]
|
92 |
-
|
93 |
-
|
94 |
-
#### Training Hyperparameters
|
95 |
-
|
96 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
97 |
-
|
98 |
-
#### Speeds, Sizes, Times [optional]
|
99 |
-
|
100 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
101 |
-
|
102 |
-
[More Information Needed]
|
103 |
|
104 |
## Evaluation
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
### Testing Data, Factors & Metrics
|
109 |
-
|
110 |
-
#### Testing Data
|
111 |
-
|
112 |
-
<!-- This should link to a Dataset Card if possible. -->
|
113 |
-
|
114 |
-
[More Information Needed]
|
115 |
-
|
116 |
-
#### Factors
|
117 |
-
|
118 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
119 |
-
|
120 |
-
[More Information Needed]
|
121 |
-
|
122 |
-
#### Metrics
|
123 |
-
|
124 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
125 |
-
|
126 |
-
[More Information Needed]
|
127 |
-
|
128 |
-
### Results
|
129 |
-
|
130 |
-
[More Information Needed]
|
131 |
-
|
132 |
-
#### Summary
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
## Model Examination [optional]
|
137 |
-
|
138 |
-
<!-- Relevant interpretability work for the model goes here -->
|
139 |
-
|
140 |
-
[More Information Needed]
|
141 |
-
|
142 |
-
## Environmental Impact
|
143 |
-
|
144 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
145 |
-
|
146 |
-
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).
|
147 |
-
|
148 |
-
- **Hardware Type:** [More Information Needed]
|
149 |
-
- **Hours used:** [More Information Needed]
|
150 |
-
- **Cloud Provider:** [More Information Needed]
|
151 |
-
- **Compute Region:** [More Information Needed]
|
152 |
-
- **Carbon Emitted:** [More Information Needed]
|
153 |
-
|
154 |
-
## Technical Specifications [optional]
|
155 |
-
|
156 |
-
### Model Architecture and Objective
|
157 |
-
|
158 |
-
[More Information Needed]
|
159 |
-
|
160 |
-
### Compute Infrastructure
|
161 |
-
|
162 |
-
[More Information Needed]
|
163 |
-
|
164 |
-
#### Hardware
|
165 |
-
|
166 |
-
[More Information Needed]
|
167 |
-
|
168 |
-
#### Software
|
169 |
-
|
170 |
-
[More Information Needed]
|
171 |
-
|
172 |
-
## Citation [optional]
|
173 |
-
|
174 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
175 |
-
|
176 |
-
**BibTeX:**
|
177 |
-
|
178 |
-
[More Information Needed]
|
179 |
-
|
180 |
-
**APA:**
|
181 |
-
|
182 |
-
[More Information Needed]
|
183 |
-
|
184 |
-
## Glossary [optional]
|
185 |
-
|
186 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
187 |
-
|
188 |
-
[More Information Needed]
|
189 |
-
|
190 |
-
## More Information [optional]
|
191 |
-
|
192 |
-
[More Information Needed]
|
193 |
-
|
194 |
-
## Model Card Authors [optional]
|
195 |
-
|
196 |
-
[More Information Needed]
|
197 |
|
198 |
-
|
199 |
|
200 |
-
[
|
201 |
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
-
|
204 |
|
205 |
-
|
|
|
|
1 |
---
|
|
|
2 |
base_model: mistralai/Mistral-7B-v0.3
|
3 |
license: agpl-3.0
|
4 |
---
|
5 |
|
6 |
+
# Open Food Facts - Ingredients spellcheck model
|
7 |
|
8 |
+
When a product is added to the database, all its details, such as allergens, additives, or nutritional values, are either wrote down by the contributor, or automatically extracted from the product pictures using OCR.
|
9 |
|
10 |
+
However, it often happens the information extracted by OCR contains typos and errors due to bad quality pictures: low-definition, curved product, light reflection, etc...
|
11 |
+
|
12 |
+
To solve this problem, we developed an **Ingredient Spellcheck** 🍊, a model capable of correcting typos in a list of ingredients following a defined guideline. The model, based on [Mistral-7B-v0.3], was fine-tuned on thousand of corrected lists of ingredients extracted from the database.
|
13 |
|
14 |
|
15 |
## Model Details
|
16 |
|
17 |
### Model Description
|
18 |
|
19 |
+
The Open Food Facts Ingredients Spellcheck is a version of [Mistral-7B-v0.3](https://huggingface.co/mistralai/Mistral-7B-v0.3) fine-tuned on thousands of corrected list of ingredients extracted from the OFF database.
|
|
|
20 |
|
21 |
+
The training dataset, with the evaluation benchmark are available in the Open Food Facts HF repository:
|
22 |
|
23 |
+
* **Training dataset:** https://huggingface.co/datasets/openfoodfacts/spellcheck-dataset
|
24 |
+
* **Evaluation benchmark:** https://huggingface.co/datasets/openfoodfacts/spellcheck-benchmark
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
The project is currently in development. You can find it in the Open Food Facts Github repo.
|
27 |
|
28 |
+
A demo of this model is also available in HF Spaces.
|
29 |
|
30 |
+
- **Repository:** https://github.com/openfoodfacts/openfoodfacts-ai/tree/develop/spellcheck
|
31 |
+
- **Demo:** https://huggingface.co/spaces/jeremyarancio/ingredients-spellcheck
|
|
|
32 |
|
33 |
## Uses
|
34 |
|
35 |
+
This model takes a list of ingredients of a product as input and returns the correction.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
It follows a spellcheck guideline, which was used to build the training and evaluation datasets. You can find this guideline in the [Spellcheck project README](https://github.com/openfoodfacts/openfoodfacts-ai/tree/spellcheck/spellcheck).
|
38 |
|
39 |
+
To respect the training process, the input list of ingredients needs to be embedded into the following prompt:
|
40 |
|
41 |
+
```python
|
42 |
+
def prepare_instruction(text: str) -> str:
|
43 |
+
"""Prepare instruction prompt for fine-tuning and inference.
|
44 |
+
Identical to instruction during training.
|
45 |
|
46 |
+
Args:
|
47 |
+
text (str): List of ingredients
|
48 |
|
49 |
+
Returns:
|
50 |
+
str: Instruction.
|
51 |
+
"""
|
52 |
+
instruction = (
|
53 |
+
"###Correct the list of ingredients:\n"
|
54 |
+
+ text
|
55 |
+
+ "\n\n###Correction:\n"
|
56 |
+
)
|
57 |
+
return instruction
|
58 |
+
```
|
|
|
|
|
|
|
59 |
|
60 |
## Training Details
|
61 |
|
62 |
+
The model training informations are available in the [CometML Experiment Tracker](https://www.comet.com/jeremyarancio/spellcheck/e223b404168f4d4c8e633cbd0909b60d?compareXAxis=step&experiment-tab=panels&showOutliers=true&smoothing=0&viewId=vhfLDppdrZXnthxtP5Lnb3tep&xAxis=step), along the other experimentations.
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
The model was trained on AWS Sagemaker using an ml.g5.2xlarge instance for 3 epochs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
## Evaluation
|
67 |
|
68 |
+
The model is evaluated on the [benchmark](https://huggingface.co/datasets/openfoodfacts/spellcheck-benchmark) using a custom evaluation algorithm.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
In short, lists of ingredients are separated into 3 parts: *original*, *reference*, *prediction*. Using a [sequence alignement algorithm](https://en.wikipedia.org/wiki/Sequence_alignment) between respectively *original*-*reference* and *original*-**prediction*, we are able to tell which token were supposed to be corrected, and which one was actually corrected. This leads to a correction Precision and Recall.
|
71 |
|
72 |
+
The complete explanation of the algorithm is available in the [Spellchech README](https://github.com/openfoodfacts/openfoodfacts-ai/tree/spellcheck/spellcheck).
|
73 |
|
74 |
+
### Metrics:
|
75 |
+
* Correction precision: **0.67**
|
76 |
+
* Correction recall: **0.62**
|
77 |
+
* Localisation precision: **0.75**
|
78 |
+
* Localisation recall: **0.69**
|
79 |
|
80 |
+
## Additional links:
|
81 |
|
82 |
+
* Open Food Facts website: https://world.openfoodfacts.org/discover
|
83 |
+
* Open Food Facts Github: https://github.com/openfoodfacts
|