Update README.md
Browse files
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
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
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 |
-
#
|
213 |
-
#
|
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
|