taciturn999 commited on
Commit
16060a8
·
verified ·
1 Parent(s): 074ea11

add fine-tune model

Browse files
README.md CHANGED
@@ -1,3 +1,119 @@
1
- ---
2
- license: unknown
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: mistralai/Mistral-7B-Instruct-v0.1
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Orapi Maintenance Chatbot
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+ The Orapi Maintenance Chatbot is a fine-tuned language model designed to assist users in selecting appropriate maintenance products from the Orapi catalog. It provides recommendations based on user queries about tasks (e.g., cleaning, assembling) and specific conditions (e.g., surface type, constraints like grease type). The model is fine-tuned from Mistral-7B-Instruct-v0.1 using the PEFT library with LoRA for efficient adaptation.
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This model is a fine-tuned version of `mistralai/Mistral-7B-Instruct-v0.1`, a 7-billion-parameter language model developed by Mistral AI. It has been adapted using the Parameter-Efficient Fine-Tuning (PEFT) library with Low-Rank Adaptation (LoRA) to specialize in recommending maintenance products from the Orapi catalog. The fine-tuning dataset consists of approximately 1000 product entries, including product names, codes, functions, and claims in French. The model is designed to answer user queries in a conversational manner, providing detailed product recommendations tailored to specific maintenance tasks and conditions.
19
+
20
+ - **Developed by:** Jeremy Indelicato (tacituzn999 on Hugging Face)
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** Causal Language Model (fine-tuned with LoRA)
24
+ - **Language(s) (NLP):** French (based on the dataset provided, which includes French product descriptions and claims)
25
+ - **License:** [More Information Needed] (Mistral-7B-Instruct-v0.1 has a gated license; you may need to specify your own license for the fine-tuned model)
26
+ - **Finetuned from model [optional]:** mistralai/Mistral-7B-Instruct-v0.1
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed] (e.g., a GitHub repository or Hugging Face model hub link if you upload the model)
33
+ - **Paper [optional]:** Not applicable
34
+ - **Demo [optional]:** [More Information Needed] (e.g., a link to a deployed demo if you host the chatbot online)
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ The Orapi Maintenance Chatbot is intended for direct use by maintenance professionals, technicians, or anyone seeking product recommendations for industrial maintenance tasks. Users can interact with the chatbot through a web interface, asking questions like "Quel produit recommandez-vous pour nettoyer des graisses sur un moteur ?" The model responds with a detailed recommendation, including the product name, code, function, and advantages.
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ The model can be integrated into larger systems, such as a customer support platform for Orapi, to provide automated product recommendations. It could also be further fine-tuned for additional tasks, such as generating product documentation or answering more complex technical queries.
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ The model is not designed for general-purpose conversation or tasks outside the domain of Orapi maintenance products. It should not be used for critical decision-making without human oversight, as it may not account for all safety or regulatory considerations. Misuse could include using the model to provide recommendations for unrelated domains (e.g., medical advice) or attempting to generate harmful content.
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ - **Technical Limitations**:
63
+ - The model was fine-tuned on a relatively small dataset (1000 products), which may limit its ability to generalize to edge cases or products not well-represented in the dataset.
64
+ - The model relies on the quality of the input data (e.g., product descriptions and claims). Inaccurate or incomplete data may lead to suboptimal recommendations.
65
+ - Performance may degrade if the user query is ambiguous or poorly formatted.
66
+ - The model requires significant computational resources (GPU with CUDA support for efficient inference with 4-bit quantization, or substantial RAM for CPU inference).
67
+
68
+ - **Sociotechnical Risks**:
69
+ - The model may inadvertently reflect biases present in the training data, such as over-recommending certain products if they are over-represented in the dataset.
70
+ - Users may overly rely on the model’s recommendations without verifying them, potentially leading to incorrect product usage.
71
+
72
+ ### Recommendations
73
+
74
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
+
76
+ Users (both direct and downstream) should be made aware of the risks, biases, and limitations of the model. Recommendations should be cross-verified with official Orapi documentation or a human expert, especially for critical maintenance tasks. To mitigate biases, the training dataset could be expanded to include a more diverse set of products and use cases. Additionally, users should be encouraged to provide clear and specific queries to improve the quality of recommendations.
77
+
78
+ ## How to Get Started with the Model
79
+
80
+ Use the code below to get started with the model.
81
+
82
+ ```python
83
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
84
+ from peft import PeftModel
85
+ import torch
86
+
87
+ # Configuration pour la quantification 4-bit (nécessite un GPU avec CUDA)
88
+ bnb_config = BitsAndBytesConfig(
89
+ load_in_4bit=True,
90
+ bnb_4bit_quant_type="nf4",
91
+ bnb_4bit_compute_dtype=torch.float16
92
+ )
93
+
94
+ # Votre token Hugging Face (nécessaire pour accéder au modèle de base)
95
+ hf_token = "hf_xxxxxxxxxxxxxxxxxxxxxxxxxx" # Remplacez par votre token
96
+
97
+ # Chemins locaux
98
+ base_model_name = "mistralai/Mistral-7B-Instruct-v0.1"
99
+ model_path = "./fine_tuned_model" # Chemin vers le dossier du modèle fine-tuné
100
+
101
+ # Charger le tokenizer
102
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
103
+
104
+ # Charger le modèle de base et appliquer les adaptateurs LoRA
105
+ base_model = AutoModelForCausalLM.from_pretrained(
106
+ base_model_name,
107
+ quantization_config=bnb_config,
108
+ device_map="auto",
109
+ token=hf_token
110
+ )
111
+ model = PeftModel.from_pretrained(base_model, model_path)
112
+
113
+ # Fonction pour générer une réponse
114
+ def generate_response(question):
115
+ input_text = f"[INST] {question} [/INST]"
116
+ inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
117
+ outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.7)
118
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
119
+ return response.split("[/INST]")[1].strip()
adapter_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "mistralai/Mistral-7B-Instruct-v0.1",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 32,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "q_proj",
27
+ "v_proj"
28
+ ],
29
+ "task_type": "CAUSAL_LM",
30
+ "use_dora": false,
31
+ "use_rslora": false
32
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c365c5818933cbe4b12150bc6557f3d0c96a351352bd7b6db8706dc92c7799f0
3
+ size 27280152
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dadfd56d766715c61d2ef780a525ab43b8e6da4de6865bda3d95fdef5e134055
3
+ size 493443
tokenizer_config.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "additional_special_tokens": [],
32
+ "bos_token": "<s>",
33
+ "chat_template": "{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content'] %}\n {%- set loop_messages = messages[1:] %}\n{%- else %}\n {%- set loop_messages = messages %}\n{%- endif %}\n\n{{- bos_token }}\n{%- for message in loop_messages %}\n {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}\n {{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}\n {%- endif %}\n {%- if message['role'] == 'user' %}\n {%- if loop.first and system_message is defined %}\n {{- ' [INST] ' + system_message + '\\n\\n' + message['content'] + ' [/INST]' }}\n {%- else %}\n {{- ' [INST] ' + message['content'] + ' [/INST]' }}\n {%- endif %}\n {%- elif message['role'] == 'assistant' %}\n {{- ' ' + message['content'] + eos_token}}\n {%- else %}\n {{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}\n {%- endif %}\n{%- endfor %}\n",
34
+ "clean_up_tokenization_spaces": false,
35
+ "eos_token": "</s>",
36
+ "extra_special_tokens": {},
37
+ "legacy": false,
38
+ "model_max_length": 1000000000000000019884624838656,
39
+ "pad_token": "</s>",
40
+ "sp_model_kwargs": {},
41
+ "spaces_between_special_tokens": false,
42
+ "tokenizer_class": "LlamaTokenizer",
43
+ "unk_token": "<unk>",
44
+ "use_default_system_prompt": false
45
+ }