0Pricing
Deep Learning Academy · บทเรียน

แบ่งโทเค็นและสร้างคลังคำศัพท์

จับคู่ข้อความกับรหัสจำนวนเต็ม

แบ่งโทเค็นและสร้างคลังคำศัพท์ เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Deep Learning Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Networks Only Eat Numbers

A neural net cannot read raw letters. Before any learning happens, you must turn text into numbers the model can crunch. 🔢

First Step: Tokenize

To tokenize means to split text into small pieces called tokens. The simplest choice is to split a sentence on spaces into words.

text = "I love deep learning"
tokens = text.split()
# ["I", "love", "deep", "learning"]

Tokens Can Be Smaller

A token need not be a whole word. It can be a character or a sub-word piece, which helps the model handle rare or unseen words.

Build a Vocabulary

A vocabulary is the full set of unique tokens your model knows. You collect every distinct token across your training text.

Give Each Token an Id

Each unique token gets one integer id. This mapping from token to id is how words become numbers the network can index.

vocab = {"i": 0, "love": 1, "deep": 2, "learning": 3}

Encode a Sentence

To encode text, you look up each token in the vocabulary and replace it with its id, producing a list of integers.

ids = [vocab[t] for t in ["i", "love", "deep"]]
# [0, 1, 2]

Handle Unknown Words

Some tokens at test time were never seen in training. Map them to a special unknown token so the model still gets a valid id.

unk_id = vocab.get("dragons", vocab["<unk>"])

Special Tokens Help

Add special tokens like padding, start, and end markers. They give the model structure beyond the plain words themselves.

Lowercase and Clean

Normalizing text by lowercasing and stripping punctuation shrinks the vocabulary so Cat and cat share a single id.

Limit the Vocabulary Size

Real corpora have huge vocabularies. Keep only the most frequent tokens to control the vocab size; the rest become unknown.

Now Text Is a Tensor

Once encoded, a sentence is a list of ids you can wrap in a tensor. The pipeline from raw text to model input is complete.

import torch
ids = torch.tensor([0, 1, 2, 3])

Quick Check

What does building a vocabulary give every unique token?

Recap

You split text into tokens, gather the unique ones into a vocabulary, and map each to an integer id so text becomes numbers. ✅

คำถามที่พบบ่อย

บทเรียน “แบ่งโทเค็นและสร้างคลังคำศัพท์” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “แบ่งโทเค็นและสร้างคลังคำศัพท์” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Deep Learning Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “แบ่งโทเค็นและสร้างคลังคำศัพท์”

จับคู่ข้อความกับรหัสจำนวนเต็ม คุณปฏิบัติ Deep Learning Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Deep Learning Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Deep Learning Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “แบ่งโทเค็นและสร้างคลังคำศัพท์” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม

ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. แบ่งโทเค็นและสร้างคลังคำศัพท์
  2. nn.Embedding: เวกเตอร์คำที่เรียนรู้ได้
  3. เหตุใดเอ็มเบดดิงจึงเก็บความหมายได้
  4. ฝึกตัวจำแนกข้อความ
← กลับไปที่ Deep Learning Academy