PDF Google Drive Downloader v1.1


Report a problem

Content text [SGU] [NLP] Project (2025-2026_HK1).docx



pip install spacy torch torchtext python -m spacy download en_core_web_sm python -m spacy download fr_core_news_sm Tokenization from torchtext.data.utils import get_tokenizer en_tokenizer = get_tokenizer('spacy', language='en_core_web_sm') fr_tokenizer = get_tokenizer('spacy', language='fr_core_news_sm') Xây dựng từ điển (Vocabulary) ● Dùng build_vocab_from_iterator. ● Thêm token đặc biệt: <unk>, <pad>, <sos>, <eos>. ● Giới hạn: 10.000 từ phổ biến nhất mỗi ngôn ngữ. Padding & Packing ● Dùng pad_sequence để đồng bộ độ dài trong batch. ● Dùng pack_padded_sequence trước khi vào LSTM. ● Sắp xếp batch theo độ dài giảm dần → enforce_sorted=True. DataLoader ● Batch size: 32–128 ● Sử dụng collate_fn tùy chỉnh để xử lý padding và packing. 6.2. Xây dựng mô hình Encoder ● Input: Chuỗi token tiếng Anh → embedding (size 256–512). ● Output: o Chuỗi hidden states o Context vector = → truyền sang Decoder. Decoder ● Input: o Ban đầu: <sos> + context vector từ Encoder. o Các bước sau: token trước đó (ground truth hoặc dự đoán).

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.