InferenceAI

Enter at least two characters to search.

Start free

Embedding Batch Deduplication

mediumProduction AI20 min25 XP

An embedding worker receives texts that may repeat. Implement deduplicate_embedding_jobs(texts) and return [unique_texts, positions], where unique_texts keeps first-seen order and each value in positions is the index of its text in unique_texts. Strings are compared exactly; do not trim or lowercase them. An empty input returns [[], []].

Examples

EXAMPLE WALKTHROUGHrepeated inputs

A guided view of the published example, not a trace of your code.

INPUT[["red","blue","red","green","blue"]]
TASKdeduplicate_embedding_jobs()
EXPECTED OUTPUT[["red","blue","green"],[0,1,0,2,1]]

Start with the input values shown in this example.

Example 1 of 2

Input: texts = ["red","blue","red","green","blue"]

Output: [["red","blue","green"],[0,1,0,2,1]]

Explanation: repeated inputs

Input: texts = ["AI","ai"]

Output: [["AI","ai"],[0,1]]

Explanation: case sensitive

Hint 1

Map each text to its index in the unique list.

Topics

PythonEmbeddingsCost Optimization