Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,100 @@
|
|
1 |
-
|
2 |
-
library_name: transformers
|
3 |
-
tags: []
|
4 |
-
---
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
-
|
9 |
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
##
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
|
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
|
|
45 |
|
46 |
-
###
|
47 |
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
-
|
59 |
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
63 |
|
64 |
-
|
|
|
65 |
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
## How to Get Started with the Model
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- 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. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
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).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
+
# Creating a README.md file with the Hugging Face style content as per the user's request.
|
|
|
|
|
|
|
2 |
|
3 |
+
readme_content = """
|
4 |
+
# Kurdish-English Machine Translation with Hugging Face Transformers
|
5 |
|
6 |
+
This repository focuses on fine-tuning a Kurdish-English machine translation model using Hugging Face's `transformers` library with MarianMT. The model is trained on a custom parallel corpus with a detailed pipeline that includes data preprocessing, bidirectional training, evaluation, and inference.
|
7 |
|
8 |
+
## Table of Contents
|
9 |
|
10 |
+
- [Introduction](#introduction)
|
11 |
+
- [Requirements](#requirements)
|
12 |
+
- [Setup](#setup)
|
13 |
+
- [Pipeline Overview](#pipeline-overview)
|
14 |
+
- [Data Preparation](#data-preparation)
|
15 |
+
- [Training SentencePiece Tokenizer](#training-sentencepiece-tokenizer)
|
16 |
+
- [Model and Tokenizer Setup](#model-and-tokenizer-setup)
|
17 |
+
- [Tokenization and Dataset Preparation](#tokenization-and-dataset-preparation)
|
18 |
+
- [Training Configuration](#training-configuration)
|
19 |
+
- [Evaluation and Metrics](#evaluation-and-metrics)
|
20 |
+
- [Inference](#inference)
|
21 |
+
- [Results](#results)
|
22 |
+
- [License](#license)
|
23 |
|
24 |
+
## Introduction
|
25 |
|
26 |
+
This project fine-tunes a MarianMT model for Kurdish-English translation on a custom parallel corpus. Training is configured for bidirectional translation, enabling model use in both language directions.
|
27 |
|
28 |
+
## Requirements
|
29 |
|
30 |
+
- Python 3.8+
|
31 |
+
- Hugging Face Transformers
|
32 |
+
- Datasets library
|
33 |
+
- SentencePiece
|
34 |
+
- PyTorch 1.9+
|
35 |
+
- CUDA (for GPU support)
|
36 |
|
37 |
+
## Setup
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
1. Clone the repository and install dependencies.
|
40 |
+
2. Ensure GPU availability.
|
41 |
+
3. Prepare your Kurdish-English corpus in CSV format.
|
42 |
|
43 |
+
## Pipeline Overview
|
44 |
|
45 |
+
### Data Preparation
|
|
|
|
|
46 |
|
47 |
+
1. **Corpus**: A Kurdish-English parallel corpus in CSV format with columns `Source` (Kurdish) and `Target` (English).
|
48 |
+
2. **Path Definition**: Specify the corpus path in the configuration.
|
49 |
|
50 |
+
### Training SentencePiece Tokenizer
|
51 |
|
52 |
+
- **Vocabulary Size**: 32,000
|
53 |
+
- **Source Data**: The tokenizer is trained on both the primary Kurdish corpus and the English dataset to create shared subword tokens.
|
54 |
|
55 |
+
### Model and Tokenizer Setup
|
56 |
|
57 |
+
- **Model**: `Helsinki-NLP/opus-mt-en-mul` pre-trained MarianMT model.
|
58 |
+
- **Tokenizer**: MarianMT tokenizer aligned with the model, with source and target languages set dynamically.
|
59 |
|
60 |
+
### Tokenization and Dataset Preparation
|
61 |
|
62 |
+
- **Train-Validation Split**: 90% train, 10% validation split.
|
63 |
+
- **Maximum Sequence Length**: 128 tokens for both source and target sequences.
|
64 |
+
- **Bidirectional Tokenization**: Prepare tokenized sequences for both Kurdish-English and English-Kurdish translation.
|
65 |
|
66 |
+
### Training Configuration
|
67 |
|
68 |
+
- **Learning Rate**: 2e-5
|
69 |
+
- **Batch Size**: 4 (per device, for both training and evaluation)
|
70 |
+
- **Weight Decay**: 0.01
|
71 |
+
- **Evaluation Strategy**: Per epoch
|
72 |
+
- **Epochs**: 3
|
73 |
+
- **Logging**: Logs saved every 100 steps, with TensorBoard logging enabled
|
74 |
+
- **Output Directory**: `./results`
|
75 |
+
- **Device**: GPU 1 explicitly set
|
76 |
|
77 |
+
### Evaluation and Metrics
|
78 |
|
79 |
+
The following metrics are computed on the validation dataset:
|
80 |
+
- **BLEU**: Measures translation quality based on precision and recall of n-grams.
|
81 |
+
- **METEOR**: Considers synonymy and stem matches.
|
82 |
+
- **BERTScore**: Evaluates semantic similarity with BERT embeddings.
|
83 |
|
84 |
+
### Inference
|
85 |
|
86 |
+
Inference includes bidirectional translation capabilities:
|
87 |
+
- **Source to Target**: English to Kurdish translation.
|
88 |
+
- **Target to Source**: Kurdish to English translation.
|
89 |
|
90 |
+
## Results
|
91 |
|
92 |
+
The fine-tuned model and tokenizer are saved to `./fine-tuned-marianmt`, including evaluation metrics across BLEU, METEOR, and BERTScore.
|
93 |
+
"""
|
94 |
|
95 |
+
# Write the content to README.md
|
96 |
+
file_path = "/mnt/data/README.md"
|
97 |
+
with open(file_path, "w") as readme_file:
|
98 |
+
readme_file.write(readme_content)
|
99 |
|
100 |
+
file_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|