ntgiaky commited on
Commit
1c8072b
·
verified ·
1 Parent(s): 9888d64

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -39
README.md CHANGED
@@ -178,30 +178,25 @@ print(result)
178
  For a complete NLU pipeline:
179
 
180
  ```python
181
- from transformers import pipeline
182
 
183
- # Load both models
184
- intent_classifier = pipeline("text-classification", model="ntgiaky/phobert-intent-classifier-smart-home")
185
- ner = pipeline("token-classification", model="ntgiaky/phobert-ner-smart-home", aggregation_strategy="simple")
 
 
 
186
 
187
- def process_command(text):
188
- # Get intent
189
- intent_result = intent_classifier(text)
190
- intent = intent_result[0]['label']
191
-
192
- # Get entities
193
- entities = ner(text)
194
-
195
- # Combine results
196
- return {
197
- 'text': text,
198
- 'intent': intent,
199
- 'entities': entities
200
- }
201
-
202
- # Example
203
- command = "điều chỉnh nhiệt độ điều hòa 25 độ"
204
- result = process_command(command)
205
  print(result)
206
  ```
207
 
@@ -209,23 +204,8 @@ print(result)
209
 
210
  ```python
211
  # Input: "bật đèn phòng khách"
212
- # Entities: [
213
- # {'type': 'device', 'text': 'đèn'},
214
- # {'type': 'living_space', 'text': 'phòng khách'}
215
- # ]
216
-
217
- # Input: "tắt quạt phòng ngủ lúc 10 giờ tối"
218
- # Entities: [
219
- # {'type': 'device', 'text': 'quạt'},
220
- # {'type': 'living_space', 'text': 'phòng ngủ'},
221
- # {'type': 'time_at', 'text': '10 giờ tối'}
222
- # ]
223
-
224
- # Input: "điều chỉnh nhiệt độ điều hòa 25 độ"
225
- # Entities: [
226
- # {'type': 'device', 'text': 'điều hòa'},
227
- # {'type': 'target_number', 'text': '25 độ'}
228
- # ]
229
  ```
230
 
231
  ## Citation
 
178
  For a complete NLU pipeline:
179
 
180
  ```python
181
+ from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
182
 
183
+ # Load with PhoBERT tokenizer explicitly
184
+ tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
185
+ model = AutoModelForTokenClassification.from_pretrained(
186
+ "ntgiaky/phobert-ner-smart-home",
187
+ ignore_mismatched_sizes=True # Add this if needed
188
+ )
189
 
190
+ # Create pipeline with explicit tokenizer
191
+ ner = pipeline(
192
+ "token-classification",
193
+ model=model,
194
+ tokenizer=tokenizer,
195
+ aggregation_strategy="simple"
196
+ )
197
+
198
+ # Test
199
+ result = ner("bật đèn phòng khách")
 
 
 
 
 
 
 
 
200
  print(result)
201
  ```
202
 
 
204
 
205
  ```python
206
  # Input: "bật đèn phòng khách"
207
+ # [{'entity_group': 'living_space', 'score': np.float32(0.97212785), 'word': 'đèn', 'start': None, 'end': None},
208
+ # {'entity_group': 'duration', 'score': np.float32(0.9332844), 'word': 'phòng khách', 'start': None, 'end': None}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  ```
210
 
211
  ## Citation