Focuses on writing maintainable, readable, and robust code together with practical debugging approaches. Candidates should demonstrate principles of clean code such as meaningful naming, clear function and module boundaries, avoidance of magic numbers, single responsibility and separation of concerns, and sensible organization and commenting. Include practices for catching and preventing bugs: mental and unit testing of edge cases, assertions and input validation, structured error handling, logging for observability, and use of static analysis and linters. Describe debugging workflows for finding and fixing defects in your own code including reproducing failures, minimizing test cases, bisecting changes, using tests and instrumentation, and collaborating with peers through code reviews and pair debugging. Emphasize refactoring, test driven development, and continuous improvements that reduce defect surface and make future debugging easier.
EasyTechnical
0 practiced
As an AI engineer working with a PyTorch codebase, which linters, static analyzers, and pre-commit hooks would you configure to catch common bugs and style problems early? Explain why you'd choose tools such as flake8, black, isort, mypy, bandit, and pre-commit, and give examples of concrete rules or checks that help in ML projects (e.g., unused GPU tensors, hard-coded paths, magic numbers).
EasyTechnical
0 practiced
Describe a Test-Driven Development (TDD) approach to implement a metric function 'top_k_accuracy(preds, labels, k)' in Python for classification tasks. Specify the tests you would write first (including edge cases) using pytest and then summarize the minimal implementation that satisfies them.
HardTechnical
0 practiced
You're asked to refactor a monolithic training script used in production that lacks tests, comments, and uses global mutable state. Provide a step-by-step refactoring plan that breaks the monolith into testable modules, adds targeted tests without changing behavior, and introduces CI gates. Prioritize minimal-risk changes and explain how you'd validate behavioral equivalence during the migration.
EasyTechnical
0 practiced
Implement unit tests (using pytest) and minimal production code in Python for a data preprocessing function 'normalize_image' that takes a NumPy array image with dtype uint8 in range [0,255] and returns a float32 array in range [0,1]. Include tests for edge cases: empty array, non-uint8 dtype, and shapes (H,W) and (H,W,C). Provide the function signature in Python and the pytest tests you would write.
HardTechnical
0 practiced
Design a testing and safety pipeline for a large generative language model (e.g., fine-tuned GPT) before deployment. Include automated checks (toxicity filters, prompt-injection tests, hallucination detection heuristics), human review steps, adversarial test suites, and acceptance criteria for promotion to production.
Unlock Full Question Bank
Get access to hundreds of Code Quality and Debugging Practices interview questions and detailed answers.