Kelvinmbewe commited on
Commit
3ba75a6
·
verified ·
1 Parent(s): 832c90b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -16
README.md CHANGED
@@ -109,36 +109,89 @@ This multi‑task setup improves generalization and reduces inference cost.
109
  from transformers import AutoTokenizer
110
  import torch
111
 
112
- tokenizer = AutoTokenizer.from_pretrained("Kelvinmbewe/LusakaLang-MultiTask")
113
- model = torch.load("Kelvinmbewe/LusakaLang-MultiTask/model.pt")
114
- model.eval()
115
- ```
116
-
117
- ```python
118
- predict_language([
 
 
 
 
 
 
 
 
 
 
 
 
119
  "Ndeumfwa bwino lelo",
120
  "Galimoto inachedwa koma driver anali bwino",
121
  "The service was terrible today"
122
  ])
123
- ```
124
-
125
-
126
- ```python
127
- predict_sentiment([
128
  "Driver was rude and unprofessional",
129
  "Ndimvela bwino lelo",
130
  "The ride was okay, nothing special"
131
  ])
132
- ```
133
-
134
- ```python
135
- predict_topic([
136
  "Payment failed but money was deducted",
137
  "Support siyankhapo, waited long",
138
  "Driver was over speeding"
139
  ])
 
 
 
140
  ```
 
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
 
144
  ```python
 
109
  from transformers import AutoTokenizer
110
  import torch
111
 
112
+ class LusakaLangMultiTask:
113
+ def __init__(self, model_path="Kelvinmbewe/LusakaLang-MultiTask"):
114
+ self.tokenizer = AutoTokenizer.from_pretrained(model_path)
115
+ self.model = torch.load(f"{model_path}/model.pt")
116
+ self.model.eval()
117
+ def predict_language(self, texts):
118
+ # Your actual implementation goes here
119
+ pass
120
+ def predict_sentiment(self, texts):
121
+ # Your actual implementation goes here
122
+ pass
123
+ def predict_topic(self, texts):
124
+ # Your actual implementation goes here
125
+ pass
126
+
127
+ # Instantiate model
128
+ llm = LusakaLangMultiTask()
129
+ # Run predictions
130
+ language_results = llm.predict_language([
131
  "Ndeumfwa bwino lelo",
132
  "Galimoto inachedwa koma driver anali bwino",
133
  "The service was terrible today"
134
  ])
135
+ sentiment_results = llm.predict_sentiment([
 
 
 
 
136
  "Driver was rude and unprofessional",
137
  "Ndimvela bwino lelo",
138
  "The ride was okay, nothing special"
139
  ])
140
+ topic_results = llm.predict_topic([
 
 
 
141
  "Payment failed but money was deducted",
142
  "Support siyankhapo, waited long",
143
  "Driver was over speeding"
144
  ])
145
+ print(language_results)
146
+ print(sentiment_results)
147
+ print(topic_results)
148
  ```
149
+ ## Sample Output
150
 
151
+ ```
152
+ # Language Identification
153
+ [
154
+ {"text": "Ndeumfwa bwino lelo",
155
+ "language": "Bemba",
156
+ "confidence": 0.9642},
157
+
158
+ {"text": "Galimoto inachedwa koma driver anali bwino",
159
+ "language": "Nyanja",
160
+ "confidence": 0.9517},
161
+
162
+ {"text": "The service was terrible today",
163
+ "language": "English",
164
+ "confidence": 0.9879}
165
+ ]
166
+ # Sentiment Analysis
167
+ [
168
+ {"text": "Driver was rude and unprofessional",
169
+ "sentiment": "Negative",
170
+ "confidence": 0.9824},
171
+
172
+ {"text": "Ndimvela bwino lelo",
173
+ "sentiment": "Positive",
174
+ "confidence": 0.9451},
175
+
176
+ {"text": "The ride was okay, nothing special",
177
+ "sentiment": "Neutral",
178
+ "confidence": 0.8733}
179
+ ]
180
+ # Topic Classification
181
+ [
182
+ {"text": "Payment failed but money was deducted",
183
+ "topic": "Payment Issue",
184
+ "confidence": 0.9728},
185
+
186
+ {"text": "Support siyankhapo, waited long",
187
+ "topic": "Customer Support",
188
+ "confidence": 0.9486},
189
+
190
+ {"text": "Driver was over speeding",
191
+ "topic": "Driver Behaviour",
192
+ "confidence": 0.9634}
193
+ ]
194
+ ```
195
 
196
 
197
  ```python