Update README.md
Browse files
README.md
CHANGED
@@ -10,6 +10,159 @@ license: apache-2.0
|
|
10 |
language:
|
11 |
- en
|
12 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Uploaded model
|
15 |
|
|
|
10 |
language:
|
11 |
- en
|
12 |
---
|
13 |
+
# Fine-Tuned Mistral Model
|
14 |
+
|
15 |
+
This repository contains a fine-tuned version of the Mistral language model. The fine-tuning was performed using a dataset derived from a CSV file, enabling the model to specialize in tasks related to the specific context of the dataset.
|
16 |
+
|
17 |
+
## Model Details
|
18 |
+
|
19 |
+
- **Base Model**: Mistral (base version)
|
20 |
+
- **Fine-Tuning Framework**: [Unsloth](https://github.com/UnslothAI) and [Hugging Face Transformers](https://huggingface.co/docs/transformers/index)
|
21 |
+
- **Dataset**: 141 rows of input-output pairs derived from a CSV file
|
22 |
+
- **Objective**: Enhance the model's capability to generate accurate and contextually appropriate responses for tasks specific to the provided dataset.
|
23 |
+
|
24 |
+
## Dataset
|
25 |
+
|
26 |
+
The dataset used for fine-tuning contains conversational data structured as follows:
|
27 |
+
|
28 |
+
- **Input**: User queries or prompts
|
29 |
+
- **Output**: Model-generated responses or target answers
|
30 |
+
|
31 |
+
### Example Entry
|
32 |
+
|
33 |
+
```json
|
34 |
+
{
|
35 |
+
"conversations": [
|
36 |
+
{ "from": "human", "value": "<input-text>" },
|
37 |
+
{ "from": "gpt", "value": "<output-text>" }
|
38 |
+
]
|
39 |
+
}
|
40 |
+
```
|
41 |
+
|
42 |
+
## Fine-Tuning Process
|
43 |
+
|
44 |
+
1. **Preprocessing**:
|
45 |
+
- Converted the CSV file into a JSON format compatible with the Mistral model using the ShareGPT template.
|
46 |
+
- Applied tokenization and ensured compatibility with the Mistral chat template.
|
47 |
+
|
48 |
+
2. **Training Configuration**:
|
49 |
+
- **Epochs**: 30
|
50 |
+
- **Batch Size**: 2 (per device)
|
51 |
+
- **Gradient Accumulation**: 4 steps
|
52 |
+
- **Optimizer**: AdamW with 8-bit precision
|
53 |
+
- **Learning Rate**: 2e-4
|
54 |
+
|
55 |
+
3. **Hardware**:
|
56 |
+
- Training was conducted on a single GPU.
|
57 |
+
|
58 |
+
4. **Frameworks**:
|
59 |
+
- [Unsloth](https://github.com/UnslothAI) for chat template handling and training
|
60 |
+
- [Hugging Face Transformers](https://huggingface.co/docs/transformers) for model fine-tuning
|
61 |
+
|
62 |
+
## Installation and Setup
|
63 |
+
|
64 |
+
### Prerequisites
|
65 |
+
|
66 |
+
- Python 3.8+
|
67 |
+
- Install dependencies:
|
68 |
+
```bash
|
69 |
+
pip install torch transformers datasets unsloth
|
70 |
+
```
|
71 |
+
|
72 |
+
### Usage
|
73 |
+
|
74 |
+
To use the fine-tuned model, load it with the Hugging Face Transformers library:
|
75 |
+
|
76 |
+
```python
|
77 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
78 |
+
|
79 |
+
# Load model and tokenizer
|
80 |
+
model = AutoModelForCausalLM.from_pretrained("path_to_your_finetuned_model")
|
81 |
+
tokenizer = AutoTokenizer.from_pretrained("path_to_your_finetuned_model")
|
82 |
+
|
83 |
+
# Generate a response
|
84 |
+
input_text = "<your input>"
|
85 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
86 |
+
outputs = model.generate(**inputs, max_new_tokens=50)
|
87 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
88 |
+
print(response)
|
89 |
+
```
|
90 |
+
|
91 |
+
### Inference Example
|
92 |
+
|
93 |
+
```python
|
94 |
+
input_text = "What is the weather like today?"
|
95 |
+
response = get_response(input_text)
|
96 |
+
print(response)
|
97 |
+
```
|
98 |
+
|
99 |
+
## Results
|
100 |
+
|
101 |
+
The fine-tuned model achieved:
|
102 |
+
|
103 |
+
- **Improved Response Quality**: The model generates responses closely aligned with the target dataset.
|
104 |
+
- **Faster Convergence**: Optimized for a small dataset with minimal overfitting.
|
105 |
+
|
106 |
+
## Limitations
|
107 |
+
|
108 |
+
- **Dataset Size**: The model was fine-tuned on a small dataset (141 rows), which may limit generalization to other tasks.
|
109 |
+
- **Domain-Specific**: Performance is optimal for the domain represented by the dataset.
|
110 |
+
|
111 |
+
## Acknowledgments
|
112 |
+
|
113 |
+
Special thanks to the open-source AI community for providing tools like Unsloth and Hugging Face Transformers. Their contributions make fine-tuning large language models accessible to all.
|
114 |
+
|
115 |
+
# Fine-Tuned Mistral Model
|
116 |
+
|
117 |
+
## Example Chat Conversation
|
118 |
+
|
119 |
+
Below is an example conversation showcasing the capabilities of the fine-tuned Mistral model. The model is optimized for customer service in the FMCG industry and supports use cases like recommending healthy snacks.
|
120 |
+
|
121 |
+
### Input Data Example
|
122 |
+
| Field | Value |
|
123 |
+
|---------------------------------|---------------------------------------------|
|
124 |
+
| **doc_id** | cs001 |
|
125 |
+
| **last_update** | 2024-12-06 |
|
126 |
+
| **use_case** | customer service |
|
127 |
+
| **topic** | FMCG |
|
128 |
+
| **stage** | awareness |
|
129 |
+
| **input** | Halo, aku cari camilan sehat nih. |
|
130 |
+
| **language** | bahasa |
|
131 |
+
| **intent** | menyapa dan memulai pencarian produk |
|
132 |
+
| **input_emotion** | penasaran |
|
133 |
+
| **instruction** | Sapa pelanggan dengan hangat, tawarkan beberapa rekomendasi camilan sehat, dan ajak mereka untuk memilih kategori tertentu. |
|
134 |
+
| **output** | Hai Kak! Aku [ai_agent_name] 😊. Lagi cari camilan sehat ya? Kita punya banyak pilihan nih, mulai dari granola bar, kacang panggang, sampai keripik sayur. Kakak lagi butuh yang praktis buat dibawa atau buat ngemil di rumah? 🛍️���� |
|
135 |
+
| **output_tone** | ramah, santai |
|
136 |
+
| **metadata/product_category/0** | snacks |
|
137 |
+
| **metadata/dynamic_placeholders/0** | [ai_agent_name] |
|
138 |
+
|
139 |
+
---
|
140 |
+
|
141 |
+
### Example Conversation
|
142 |
+
|
143 |
+
#### **Human**:
|
144 |
+
> Halo, aku cari camilan sehat nih.
|
145 |
+
|
146 |
+
#### **Assistant**:
|
147 |
+
> Hai Kak! Aku **SnackBot** 😊. Lagi cari camilan sehat ya? Kita punya banyak pilihan nih, mulai dari granola bar, kacang panggang, sampai keripik sayur. Kakak lagi butuh yang praktis buat dibawa atau buat ngemil di rumah? 🛍️🍴
|
148 |
+
|
149 |
+
---
|
150 |
+
|
151 |
+
This demonstrates the model's ability to:
|
152 |
+
1. **Understand intent**: Identify the user's need for healthy snacks.
|
153 |
+
2. **Generate relevant responses**: Provide a list of options in a friendly tone.
|
154 |
+
3. **Utilize placeholders dynamically**: Replace `[ai_agent_name]` with a suitable agent name, e.g., **SnackBot**.
|
155 |
+
|
156 |
+
For more usage examples, refer to the instructions in the dataset or try interacting with the model directly!
|
157 |
+
|
158 |
+
## License
|
159 |
+
|
160 |
+
This project is licensed under the [MIT License](LICENSE).
|
161 |
+
|
162 |
+
---
|
163 |
+
|
164 |
+
Feel free to raise any issues or contribute improvements to this repository!
|
165 |
+
|
166 |
|
167 |
# Uploaded model
|
168 |
|