Previous question · 1393
Network AB Test Estimator
hardStatistics
Next question · 1395
Cheapest Flights Within K Stops
mediumData Structures
Random coding question

1394. Top k embeddings retrieval

easy
GeneralGeneral
senior
Function contract
Inputs
k
int
query
np.ndarray
embeddings
np.ndarray
Returns
value
list

Examples

Input
{
  "k": 2,
  "query": [
    1,
    0
  ],
  "embeddings": [
    [
      1,
      0
    ],
    [
      0,
      1
    ],
    [
      0.5,
      0
    ],
    [
      -1,
      0
    ]
  ]
}
Output
[
  0,
  2
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
senior
entry
Tags
cosine-similarity
top-k-retrieval
numpy-vectorization
similarity-search

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
15 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