CourseNatural Language Processing: The Complete Course · Module 6: Word and Sentence Embeddings · part 42 of 73
Part 42 · Module 6: Word and Sentence Embeddings

Lesson 3: Sentence embeddings: one vector per message

56 min read·14 Oct 2026
Module 6 · Lesson 3 · About 50 minutes · Needs: basic Python; Module 4 Lessons 2 and 4 (TF-IDF, cosine, logistic regression) help; Lessons 1 and 2 of this module help but are not required

The situation

It is Wednesday 14 October 2026, project week 6. Ines keeps meeting messages that use none of the words she expects. Rosa asks: if a model compared whole messages by meaning, would it route better than TF-IDF, and could it group the inbox without labels?

One message runs through the lesson: HT28 from the hand-written test set (simulated). It reads "brakes squealing like a banshee lol. book me in?" Ines labels it repair_booking. Its nearest training message by TF-IDF is a price question that matched on "me in".

HT28, THE RUNNING EXAMPLE brakes squealing like a banshee lol. book me in? TF-IDF: 0.175 "...can u fit me in..." matched on "me in" sentence encoder: 0.331 "the brake pads are worn" matched on meaning
HT28 shares almost no words with the template messages: TF-IDF finds a neighbour through "me in", the sentence encoder finds one about worn brake pads (grey: background; blue: the system this lesson builds).

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.