Natural Language Processing

Give the word more than an address

BOTIE

Turn the incoming word into an ID using the vocabulary, then use that ID to retrieve its embedding row.
Ready to test
0 passed · 0 failed · 1 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Turn the incoming word into an ID using the vocabulary, then use that ID to retrieve its embedding row.

Botie's word ID names an entry but carries no measured semantic features. A second lookup retrieves the vector assigned to that entry in an embedding table.

Look up the incoming word's vocabulary ID, then use that ID to retrieve a row from the supplied embedding table.

Examples and results
Word
cat
Word-to-ID table
{
  "cat": 0,
  "car": 1
}
Embedding rows
0.80.2
0.10.9
Required result
0.80.2
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

A word's ID differs from its dictionary position

This check uses the pieces from “Follow a word through its ID to its embedding row”.

BOTIE

Look up river's ID in the vocabulary, then retrieve the corresponding embedding row. Return the one-row result expected by the lookup operation. Dictionary display order does not determine the row address.
Word
river
Word-to-ID table
{
  "bank": 0,
  "river": 2,
  "road": 1
}
Embedding rows
0.10.9
0.80.2
0.20.7

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

What would need to happen during learning for distances between these vectors to become useful?

Assigning vectors is not itself evidence of semantic structure; useful geometry depends on training and data.

This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out.

Work through the Python challenges →
Continue the courseDistance and Similarity →
← Finite Scalar Quantisation