Views
No views yet
CS221DoAn/Do_an_group_BiLSTM_CRF is a deep learning model based on the Bidirectional LSTM + Conditional Random Field (BiLSTM-CRF) architecture. It is specifically trained for Named Entity Recognition (NER) on domain-specific Vietnamese unstructured text: Online Food Delivery Orders and Messages.| Tag | Entity Class | Description | Examples |
|---|---|---|---|
B-FOOD, I-FOOD | FOOD | Names of dishes, drinks, toppings | cơm sườn, trà sữa, trân châu |
B-QUANTITY, I-QUANTITY | QUANTITY | Portions, servings, item counts | 1p, 2 ly, một hộp, 3 suất |
B-NOTE, I-NOTE | NOTE | Special requests, flavor modifications | không, ít ngọt, nhiều |
B-PLACE, I-PLACE | PLACE | Delivery location, addresses | Ký túc xá khu A, tòa D6, rào b4 |
B-PHONE, I-PHONE | PHONE | Receiver's contact number | 0794987xxx, 0903123xxx |
B-TIME, I-TIME | TIME | Expected/requested delivery time | lúc 11h30, trưa nay, 18h |
B-PRICE, I-PRICE | PRICE | Monetary cost, item prices | 35k, 40000, 25 ngàn |
O | OUTSIDE | Non-entity words, syntax connecting words | cho em, giao qua, với, ạ, nhé |
seqeval framework.0.9771QUANTITY at the beginning and FOOD at the end). The Self-Attention mechanism in Transformer models (like PhoBERT) resolves this limitation efficiently..pth weights.1pip install torch huggingface_hub
2⚠️ IMPORTANT: You MUST replace theBiLSTM_CRFclass placeholder below with the exact PyTorch class definition you used during the training phase.
1import torch
2import torch.nn as nn
3from huggingface_hub import hf_hub_download
4
5# 1. DEFINE YOUR MODEL ARCHITECTURE (MUST MATCH TRAINING CODE)
6class BiLSTM_CRF(nn.Module):
7 def __init__(self, vocab_size, tagset_size, embedding_dim, hidden_dim):
8 super(BiLSTM_CRF, self).__init__()
9 # --- PASTE YOUR ACTUAL PYTORCH INIT CODE HERE ---
10 pass
11
12 def forward(self, sentence):
13 # --- PASTE YOUR ACTUAL FORWARD PASS HERE ---
14 pass
15
16 def decode(self, sentence):
17 # --- PASTE YOUR VITERBI DECODING HERE ---
18 pass
19
20# Initialize the model with your original hyperparameters
21# model = BiLSTM_CRF(vocab_size=..., tagset_size=15, embedding_dim=..., hidden_dim=...)
22
23# 2. DOWNLOAD AND LOAD WEIGHTS
24REPO_ID = "CS221DoAn/Do_an_group_BiLSTM_CRF"
25FILENAME = "bilstm_crf.pth"
26
27print("Downloading BiLSTM-CRF weights...")
28model_path = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
29
30# Load state dict
31# model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
32# model.eval()
33
34print("Model loaded successfully! Ready for inference.")
35
36# 3. PREDICT (Replace with your actual text processing pipeline)
37def predict_food_order(raw_text):
38 print(f"\nInput: {raw_text}")
39 # 1. Preprocess & Tokenize text
40 # 2. Convert to Tensor
41 # 3. Pass through model.decode()
42 # 4. Map ID to Label
43 pass
441@misc{cs221_food_order_ner_bilstm_crf,
2 author = {Vo Thanh Loc and Nguyen Anh Nguyen},
3 title = {Food Order Extraction: BiLSTM-CRF Baseline for Vietnamese NER},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = https://huggingface.co/CS221DoAn/Do_an_group_BiLSTM_CRF
7}
8