Mario12355 commited on
Commit
feca0b6
·
verified ·
1 Parent(s): 8efa428

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +158 -3
README.md CHANGED
@@ -1,7 +1,45 @@
1
  ---
 
 
2
  license: mit
3
- pipeline_tag: translation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
 
5
  # Swabian-German Translation Model (DPO-Enhanced)
6
 
7
  This model fine-tunes LLAMA 3.1 8B for bidirectional translation between Standard German and Swabian dialect, enhanced through Direct Preference Optimization (DPO).
@@ -19,7 +57,124 @@ This model fine-tunes LLAMA 3.1 8B for bidirectional translation between Standar
19
 
20
  ## Usage
21
 
 
 
22
  ```python
 
 
 
 
 
 
 
 
23
  # Example translation from Swabian to Standard German
24
- prompt = "Übersetze ins Hochdeutsche: Du hosch ja a blaus Mol am Arm!"
25
- Expected output format: "Du hast ja einen Bluterguss am Arm!""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - de
4
  license: mit
5
+ library_name: transformers
6
+ pipeline_tag: text2text-generation
7
+ tags:
8
+ - llama
9
+ - translation
10
+ - german
11
+ - dialect
12
+ - swabian
13
+ - qlora
14
+ - dpo
15
+ datasets:
16
+ - custom
17
+ model-index:
18
+ - name: swabian-german-translator
19
+ results:
20
+ - task:
21
+ type: translation
22
+ name: German-Swabian Translation
23
+ metrics:
24
+ - type: accuracy
25
+ value: 0.8
26
+ name: Training Loss
27
+ - type: bleu
28
+ value: N/A
29
+ name: BLEU Score
30
+ metadata:
31
+ author: [Your Name]
32
+ framework: pytorch
33
+ fine_tuning_type:
34
+ - dpo
35
+ - qlora
36
+ base_model: llama-3.1-8b
37
+ training_data: Custom dataset based on Schwäbisch-Schwätza wordbook
38
+ training_processes:
39
+ - sft
40
+ - dpo
41
  ---
42
+
43
  # Swabian-German Translation Model (DPO-Enhanced)
44
 
45
  This model fine-tunes LLAMA 3.1 8B for bidirectional translation between Standard German and Swabian dialect, enhanced through Direct Preference Optimization (DPO).
 
57
 
58
  ## Usage
59
 
60
+ ### Basic Translation
61
+
62
  ```python
63
+ from transformers import AutoModelForCausalLM, AutoTokenizer
64
+ import torch
65
+
66
+ # Load model and tokenizer
67
+ model_name = "your-username/swabian-translator-dpo"
68
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
69
+ model = AutoModelForCausalLM.from_pretrained(model_name)
70
+
71
  # Example translation from Swabian to Standard German
72
+ def translate(text, direction="to_german"):
73
+ if direction == "to_german":
74
+ prompt = f"Übersetze ins Hochdeutsche: {text}"
75
+ else:
76
+ prompt = f"Übersetze ins Schwäbische: {text}"
77
+
78
+ inputs = tokenizer(prompt, return_tensors="pt")
79
+ outputs = model.generate(**inputs, max_length=100)
80
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
81
+
82
+ # Example usage
83
+ swabian_text = "Du hosch ja a blaus Mol am Arm!"
84
+ german_translation = translate(swabian_text, "to_german")
85
+ print(german_translation) # Expected: "Du hast ja einen Bluterguss am Arm!"
86
+ ```
87
+
88
+ ### Translation Examples
89
+
90
+ Swabian to German:
91
+ ```
92
+ Input: "I han koi Zeit"
93
+ Output: "Ich habe keine Zeit"
94
+
95
+ Input: "Des goht et"
96
+ Output: "Das geht nicht"
97
+
98
+ Input: "Wo bisch du her komma?"
99
+ Output: "Woher kommst du?"
100
+ ```
101
+
102
+ German to Swabian:
103
+ ```
104
+ Input: "Ich verstehe das nicht"
105
+ Output: "I versteh des et"
106
+
107
+ Input: "Das schmeckt sehr gut"
108
+ Output: "Des schmeckt arg guat"
109
+ ```
110
+
111
+ ## Model Architecture & Training
112
+
113
+ ### Training Process
114
+ 1. **Initial Dataset Preparation**
115
+ - Base dataset: 12,000+ word pairs from Schwäbisch-Schwätza wordbook
116
+ - Context enhancement using LLM-generated sentences
117
+ - Manual verification and cleanup
118
+
119
+ 2. **SFT (Supervised Fine-Tuning)**
120
+ - QLoRA implementation for efficient training
121
+ - 2 epochs on the complete dataset
122
+ - Loss convergence at ~0.8
123
+
124
+ 3. **DPO (Direct Preference Optimization)**
125
+ - 300 carefully curated preference pairs
126
+ - 3 epochs of preference learning
127
+ - Focus on natural and accurate translations
128
+
129
+ ### Technical Implementation
130
+ - Quantized training using QLoRA
131
+ - 4-bit precision for efficient resource usage
132
+ - Training framework: UnslothAI
133
+ - Single GPU training (~16GB VRAM required)
134
+
135
+ ## Limitations and Considerations
136
+
137
+ 1. **Dialect Variations**
138
+ - Swabian varies significantly by region
139
+ - Model focuses on common/standard Swabian expressions
140
+ - May not capture all local variations
141
+
142
+ 2. **Translation Quality**
143
+ - Best performance on common phrases and expressions
144
+ - May struggle with very colloquial or context-dependent translations
145
+ - Not recommended for official or legal translations
146
+
147
+ 3. **Technical Limitations**
148
+ - Input length limited to 512 tokens
149
+ - Generation speed affected by quantization
150
+ - Memory requirements: ~8GB RAM minimum
151
+
152
+ ## Community and Contributions
153
+
154
+ We welcome community contributions to improve the model:
155
+ - Additional training data
156
+ - Regional variant documentation
157
+ - Bug reports and fixes
158
+ - Performance improvements
159
+
160
+ Please submit issues or pull requests through the Hugging Face repository.
161
+
162
+ ## Citation and Attribution
163
+
164
+ ```bibtex
165
+ @misc{swabian-german-translator,
166
+ author = {[Your Name]},
167
+ title = {Swabian-German Translation Model},
168
+ year = {2024},
169
+ publisher = {Hugging Face},
170
+ journal = {Hugging Face Model Hub}
171
+ }
172
+ ```
173
+
174
+ ## License
175
+ This project is licensed under the MIT License - see the LICENSE file for details.
176
+
177
+ ## Acknowledgments
178
+ - Original dictionary data: [schwäbisch-schwätza.de](http://xn--schwbisch-schwtza-tqbk.de/)
179
+ - UnslothAI for the training framework
180
+ - LLAMA 3.1 8B base model