Tag: Retrieval

  • MSD0110 Semantic LLM Cache

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0103 Gmail Email Retrieval Ranking

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0101 RAG Evaluation Harness

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0097 Long-Document QA Backend

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0093 Answer Engine Citations

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • MSD0065 News Feed Ranking

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • CD0105 Dependency Version Resolver

    Mode B · Build & Trace 60 Min Python 3.10+ 4 Search Blanks

    OpenAI’s research and infrastructure teams launch training, evaluation, and data jobs inside pinned Python environments, so the tooling that turns loose requirements into an exact lock file sits on every engineer’s critical path. This tooling round (reported by candidates in 2026 interview banks) asks you to build the core of that lock step: resolve(packages, requirements) returns either a consistent {package: version} pin set or a structured Conflict. You may use only the standard library: operator, tuples, dicts, and plain recursion. Importing pip, resolvelib, or packaging is forbidden.

    The package index maps each package to its available versions, and each version to its dependency constraints. For example, {"A": {"1.0.0": {"C": ">=1.0,<3.0"}}} says that A 1.0.0 needs a C version inside that range. A constraint written as A>=2.0,<3.0 is stored as the key "A" with the spec ">=2.0,<3.0". Clauses are comma-separated, the only operators are >=, <, and ==, and an empty spec means any version. Versions are dotted integers compared as semantic-version tuples.

    Your resolver must (1) prefer the highest compatible version of each package, (2) make a diamond dependency converge on one shared version that satisfies every requirer, (3) terminate on cyclic dependencies, and (4) on unsatisfiable input return a Conflict naming the package, the clashing constraint chain, and the active pins, never a partial dict. Fill the 4 blanks below and trace the accumulated edges and pins after every decision.

    Skeleton Code (Fill Blanks 1-4):

    01  import operator
    02  from dataclasses import dataclass, field
    03  from typing import Callable, Dict, List, Tuple, Union
    04
    05  Version = Tuple[int, int, int]
    06  Bound = Tuple[Callable[[Version, Version], bool], Version]
    07  Edge = Tuple[str, str]           # (requirer, spec), e.g. ("A 1.0.0", ">=2.0,<3.0")
    08  Index = Dict[str, Dict[str, Dict[str, str]]]   # package -> version -> {dep: spec}
    09
    10
    11  @dataclass
    12  class Conflict:
    13      package: str                                    # package no version can satisfy
    14      chain: List[str] = field(default_factory=list)  # e.g. "A 1.0.0 -> C>=2.0"
    15      path: List[str] = field(default_factory=list)   # active pins, e.g. "A 1.0.0"
    16
    17      def message(self) -> str:
    18          return f"no version of {self.package} satisfies: " + "; ".join(self.chain)
    19
    20
    21  def parse_version(text: str) -> Version:
    22      parts = [int(part) for part in text.strip().split(".")]
    23      return tuple((parts + [0, 0, 0])[:3])          # "2.0" -> (2, 0, 0)
    24
    25
    26  def parse_constraint(spec: str) -> List[Bound]:
    27      # TODO (Blank 1): ">=2.0,<3.0" -> [(cmp, (2, 0, 0)), (cmp, (3, 0, 0))]
    28      #   for ops ">=", "<", "=="; "" means any version; other ops raise ValueError
    29      ...
    30
    31
    32  def allowed(version: Version, pkg_edges: List[Edge]) -> bool:
    33      # TODO (Blank 2): True iff version passes every bound of the given edges
    34      ...
    35
    36
    37  def resolve(packages: Index,
    38              requirements: Dict[str, str]) -> Union[Dict[str, str], Conflict]:
    39      edges: Dict[str, List[Edge]] = {}              # package -> constraining edges
    40      for name, spec in requirements.items():
    41          edges.setdefault(name, []).append(("root", spec))
    42      chosen: Dict[str, str] = {}                    # package -> pinned version string
    43      clash: List[Conflict] = []                     # dead ends, most recent last
    44
    45      def search() -> bool:
    46          # TODO (Blank 3): take the alphabetically first unpinned package in
    47          #   edges, try its versions newest first, add each pin's dependency
    48          #   edges, recurse, and restore edges and chosen on failure; append
    49          #   make_conflict(...) to clash at each dead end; True when all pinned
    50          ...
    51
    52      if search():
    53          return dict(chosen)
    54      return clash[-1]
    55
    56
    57  def make_conflict(package: str, pkg_edges: List[Edge],
    58                    chosen: Dict[str, str]) -> Conflict:
    59      # TODO (Blank 4): chain = one "requirer -> package+spec" string per edge,
    60      #   path = one "package version" string per pin, in pin order
    61      ...
    Resolver contract: requirements plus a package index flow through four question-marked steps (parse each spec, check a candidate, backtracking search, conflict record) to an output that is either a version pin dict or a Conflict; below, boxes list the forbidden libraries, the allowed building blocks, and the output contract

    Figure 1: the input is loose requirements plus a version index, and the output is either one pin per package or a Conflict record. The four steps in between are yours to write without any packaging library.

    Interactive Python Workspace: Switch to the split-screen workspace to fill Blanks 1-4 in the live editor and run the resolver fixtures.

    Open in Colab ↗
    Progressive Hints (Free · Zero Spoilers)
    1Inspection Checklist (Where to Look)

    (1) Comparable Versions: Every bound must order versions the way a release manager would, so 2.10.0 outranks 2.9.0 and 2.0 equals 2.0.0.
    (2) Every Edge Counts: A package can be constrained by the root and by several pinned requirers at once, and a candidate is only viable against all of them.
    (3) One Pin per Package: A diamond or a cycle reaches the same package twice; decide what the second arrival should do to an existing pin, and make every failed branch restore edges and chosen exactly.
    (4) A Record That Survives: Decide which containers search keeps mutating after a dead end is recorded, and what that means for the Conflict you hand back.

    2Visual Review Map (Figure 2)
    Review map for the resolver: the top row lists the return type each of Blanks 1 to 4 must produce, from a spec string to a Conflict record; the bottom row shows a diamond fixture where root requires A and B, both constrain C, and every pin plus every verdict for C versions 1.5.0, 2.10.0, 2.4.0, 2.9.0 and 3.1.0 is a question mark

    Figure 2: The review map a strong candidate narrates aloud. The top row gives the return type of each blank, and the bottom row is a diamond fixture whose pins and candidate verdicts are all left as question marks for you to trace.

    3Interviewer Nudge & Line Focus

    Answer each question with a concrete value or state before you write the blank:

    Blank 1 (Clause Parser): parse_version already turns "2.0" into (2, 0, 0). If you compared clause targets as raw strings, would "2.10.0" >= "2.9" hold, and what should a clause like ~=1.2, which this contract does not support, do to the result?
    Blank 2 (Edge Check): In the diamond, C collects one edge from A and one from B. If a candidate were tested against only the edge added last, which C version would the search pin, and would A still accept it?
    Blank 3 (Backtracking Search): What order does sorted(["2.9.0", "2.10.0"], reverse=True) produce, and which key fixes it? When B 1.0.0 adds an edge onto a package that is already pinned, is re-entering that package necessary, or is a cheaper test enough? After a failed branch, which packages would still look required if you only popped edges?
    Blank 4 (Conflict Record): search keeps popping edges and deleting pins after the dead end you record. If chain or path held a reference to those live containers, what would they contain by the time resolve returns?
    Answer
    Login to view more content

  • CD0103 In-Memory DB TTL Snapshot

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • CD0080 RAG Retrieval Pipeline

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

  • CD0067 Debug Streaming Top-K

    This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.