File size: 7,620 Bytes
1ee5227
 
c9f89e0
 
 
 
 
 
 
 
 
 
 
1ee5227
 
 
 
2924b27
1ee5227
 
 
 
 
 
 
c9f89e0
1ee5227
c9f89e0
1ee5227
c9f89e0
 
 
 
 
 
 
 
1ee5227
 
 
 
 
c9f89e0
 
 
1ee5227
 
 
 
 
c9f89e0
1ee5227
 
 
c9f89e0
 
1ee5227
 
 
 
 
c9f89e0
1ee5227
 
 
 
 
 
c9f89e0
 
 
 
 
1ee5227
 
 
 
c9f89e0
 
 
1ee5227
 
 
 
 
c9f89e0
 
1ee5227
 
 
 
 
adc4f71
c9f89e0
 
 
ecda2a0
 
c9f89e0
 
ecda2a0
 
c9f89e0
1ee5227
 
 
 
 
 
c9f89e0
1ee5227
 
 
 
 
 
 
c9f89e0
1ee5227
 
 
 
ecda2a0
 
 
 
 
1ee5227
 
 
 
 
 
 
c9f89e0
 
1ee5227
 
 
c9f89e0
 
1ee5227
 
 
c9f89e0
1ee5227
 
 
 
 
 
 
c9f89e0
 
 
 
 
1ee5227
 
 
 
 
ecda2a0
 
1ee5227
 
 
ecda2a0
 
1ee5227
 
 
 
 
 
 
 
adc4f71
c9f89e0
 
 
 
 
 
1ee5227
 
c9f89e0
1ee5227
c9f89e0
1ee5227
 
 
 
 
c9f89e0
1ee5227
 
 
ecda2a0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
library_name: transformers
tags:
- low-resource-languages
- NLP
- Hausa
license: mit
datasets:
- HausaNLP/NaijaSenti-Twitter
language:
- ha
metrics:
- accuracy
---

# Model Card for Model ID

This model is a fine-tuned version of the Google Gemma 7B large language model, specifically optimized for Hausa language sentiment analysis. It classifies text into positive, neutral, and negative sentiments and can be used for tasks like social media monitoring, customer feedback analysis, and any sentiment-related task involving Hausa text.



## Model Details

### Model Description

The fine-tuned Gemma 7B model is designed for sentiment analysis in the Hausa language, which is widely spoken across West Africa. It was fine-tuned using Hausa text data with labeled sentiments to accurately classify text as positive, neutral, or negative. The fine-tuning process employed Low-Rank Adaptation (LoRA) to efficiently update the model’s parameters without requiring large amounts of computational resources.

This model is ideal for analyzing Hausa-language social media posts, reviews, and other text data to gain insights into public sentiment. It offers significant improvements over the base model, particularly for sentiment classification tasks in a low-resource language like Hausa. The model is part of an ongoing effort to create more robust natural language processing tools for underrepresented languages.


- **Developed by:** Mubarak Daha Isa
- **Funded by [optional]:** None
- **Shared by [optional]:** None
- **Model type:** Large Language Model (LLM) fine-tuned for sentiment analysis
- **Language(s) (NLP):** Hausa
- **License:** MIT
- **Finetuned from model [optional]:** Google Gemma 7B

### Model Sources [optional]

<!-- Provide the basic links for the model. -->

- **Repository:** https://huggingface.co/bagwai/fine-tuned-gemma-7b-Hausa
- **Paper [optional]:** Comming Soon..
- **Demo [optional]:** None

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->


### Direct Use

<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
This model can be used for sentiment analysis of text written in the Hausa language, specifically categorizing text into positive, neutral, or negative sentiments. It is ideal for applications in social media analysis, customer feedback, or any Hausa text-based sentiment classification tasks.



### Downstream Use [optional]

<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
Adaptation to other NLP tasks such as emotion detection, text classification, and content moderation in Hausa language contexts.


### Out-of-Scope Use

<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->

This model is not suitable for:

Sentiment analysis in languages other than Hausa without further fine-tuning.
Use in environments where bias in sentiment classification may have critical implications (e.g., legal or medical contexts).


## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->
**Bias:** The model may reflect inherent biases in the training data, especially in its treatment of neutral and negative sentiment.
**Risks:** Misclassification of sentiment in sensitive use cases could lead to misinterpretations of Hausa language texts.
**Limitations:** This model was trained on a limited dataset. Performance might degrade when applied to Hausa texts outside of its training domain.

### Recommendations

<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->

Users (both direct and downstream) should be made aware of the risks, biases, and limitations of the model. The model’s outputs should be carefully reviewed in sensitive contexts.


## How to Get Started with the Model

Use the code below to get started with the model.


from transformers import AutoModelForSequenceClassification, AutoTokenizer

### Load the model and tokenizer
- **model** = AutoModelForSequenceClassification.from_pretrained("bagwai/fine-tuned-gemma-7b-hausa")
- **tokenizer** = AutoTokenizer.from_pretrained("bagwai/fine-tuned-gemma-7b-hausa")

### Example usage
- **inputs** = tokenizer("Ina son wannan littafin", return_tensors="pt")
- **outputs** = model(**inputs)


## Training Details

### Training Data

<!-- 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. -->
The model was fine-tuned on a Hausa sentiment analysis dataset consisting of 300 samples from NaijaSenti > Hausa Dataset.

### Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

#### Preprocessing [optional]

Preprocessing: Hausa stopwords were removed using a custom stopword list (hau_stop.csv).

#### Training Hyperparameters

- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
- **Epochs:** 5
- **Learning Rate:** 2e-4
- **Batch Size:** 8
- **Optimizer:** AdamW
- **LoRA Rank:** 64

## Evaluation

<!-- This section describes the evaluation protocols and provides the results. -->

### Testing Data, Factors & Metrics

**Testing Data:** Evaluation was performed on a hold-out test set comprising 300 Hausa text samples.
**Metrics:** Accuracy, Precision, Recall, F1-Score.

### Results

**Before Fine-Tuning:** Accuracy = 37.7%, F1-Score = 31.0%
**After Fine-Tuning:** Accuracy = 66.0%, F1-Score = 66.0%

#### Summary

![image/png](https://cdn-uploads.huggingface.co/production/uploads/667a06609715dee1c93d7a96/LMXaiRwOFV8e5-WkQLQ30.png)

## Environmental Impact

<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

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).

- **Hardware Type:** GPU P100
- **Hours used:** 5hrs
- **Cloud Provider:** Kaggle
- **Compute Region:** India
- **Carbon Emitted:** Zero

## Technical Specifications [optional]

### Model Architecture and Objective

- **Model Type:** Gemma 7B (LLM)
- **Objective:** Fine-tuned for sentiment analysis in the Hausa language.

### Compute Infrastructure

- **Hardware:** Kaggle NVIDIA P100 GPUs
- **Software:** PyTorch, Hugging Face Transformers, LoRA (Low-Rank Adaptation)


## Citation [optional]

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

**BibTeX:**

@misc{mubarak2024fine,
  author = {Mubarak Daha Isa},
  title = {Fine-tuned Gemma 7B for Hausa Sentiment Analysis},
  year = {2024},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/your-username/fine-tuned-gemma-7b-hausa}},
}


**APA:**

Mubarak Daha Isa (2024). Fine-tuned Gemma 7B for Hausa Sentiment Analysis. Hugging Face. https://huggingface.co/bagwai/fine-tuned-gemma-7b-hausa



## Model Card Authors [optional]

Mubarak Daha Isa

## Model Card Contact

- **mubarakdaha8@gmail.com**
- **2023000675.mubarak@pg.sharda.ac.in**