Previous question · 57
Repeated DNA Sequences
mediumAlgorithms
Next question · 59
Create and Reshape an Array
easyML Coding
Random coding question

58. Word embedding lookup

easy
GeneralGeneral
senior
Function contract
Inputs
token_ids
np.ndarray
embeddings
np.ndarray
Returns
value
np.ndarray

Examples

Input
{
  "token_ids": [
    3,
    0,
    2,
    2,
    1
  ],
  "embeddings": [
    [
      0,
      0.5
    ],
    [
      1,
      -1
    ],
    [
      2.5,
      2
    ],
    [
      -0.25,
      0.75
    ]
  ]
}
Output
[
  [
    -0.25,
    0.75
  ],
  [
    0,
    0.5
  ],
  [
    2.5,
    2
  ],
  [
    2.5,
    2
  ],
  [
    1,
    -1
  ]
]

Constraints

Hint 1
Hint 2
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
senior
entry
Tags
numpy-fancy-indexing
nlp-embeddings
array-indexing
data-structures

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
19 people are solving this problem
Loading editor for the selected language
Ln 1, Col 1
Program Output
DATAINTERVIEW
Interactive coding terminal
Python / NumPy environment ready.
Type a command below or run code from the editor.
run scriptExecute the current editor contents
submitGrade the current editor contents against all solution test cases
python ("print hello world")Run an isolated Python command
helpShow all available commands