Skip to content

Working with AI tools

In this chapter, I want to talk about how to effectively use artificial intelligence - more specifically, generative AI tooling - within a data scientist's workflow.

The speed of thought

The primary win that you get with generative AI tools is the ability to code at the speed of thought. This is transformative for productivity!

There's a fascinating paper that illustrates why this is so powerful: humans have approximately \(10^9\) bits/second capacity for information ingestion, but our brain's cognitive processing runs at about 10 bits/second - a \(10^8\) difference in capacity (source). Similarly, there's a significant gap between how fast we can think and how fast we can type.

This is where generative AI comes in - it helps bridge that gap. It's a much faster way to get a polished first draft of code, documentation, and other written work.

The right kind of lazy

Before AI-assisted coding, my productivity bottleneck was, for the most part, my typing speed. Now that we're in a world of GenAI, it's shifted to how quickly I can generate ideas and review written work. The last part is the most important, and is now the new bottleneck. But it's not a bad situation to be in, compared to the old alternative of being bottlenecked by my typing speed.

However, here's the crucial part: while you can (and should) use AI to accelerate your work, you can't relinquish your intellectual responsibility. There's a difference between:

  • ✅ Being "Bill Gates lazy" - finding the most efficient way to accomplish work
  • ❌ Being intellectually lazy - blindly trusting machine outputs without review

You, the human, must remain responsible for the final output. AI is a powerful tool for augmenting your capabilities, not replacing your judgment.

Effective patterns for AI interaction

The key to working effectively with AI tools is understanding how to structure your interactions. Here's what I've found works best:

Start with the big picture

Before diving into code generation, spend time articulating what you're trying to accomplish. AI tools work best when you give them context about:

  • The problem you're solving
  • Any constraints you're working within
  • The style and approach you prefer

In the old days, you may have had the habit of starting with a fat finger sketch of what needs to be built. Don't skip this! It'll help you gain clarity over what you're trying to accomplish. A vague prompt is no help here, so use whatever tools you need to gain a clear understanding of what you're trying to accomplish. For me, my "fat finger sketch" manifests itself as the code I wish to see myself writing and maintaining, which leaves room for the AI to fill in the details.

Iterate rapidly

One of the biggest mistakes I see is treating AI outputs as final products. Instead, think of them as collaborative drafts. When I work with AI:

  • I start with a rough request
  • Review the output critically
  • Refine my prompt based on what's missing
  • Repeat until the output satisfies what is in my head.

It's perfectly natural for what you're thinking to evolve as you see the output. I would strongly suggest that you embrace this fact, rather than fight it.

Verify and validate

Just as you wouldn't trust untested code from a human colleague, don't blindly trust AI-generated code. Develop a habit of:

  • Reading through generated code line by line
  • Testing edge cases explicitly
  • Verifying that the solution actually solves your problem
  • Checking for potential security or performance issues

Beyond code generation

While code generation gets most of the attention, I've found AI tools particularly valuable for:

Documentation acceleration

Getting documentation started is often the hardest part. I use AI to:

  • Generate initial function and class docstrings
  • Draft high-level architectural descriptions
  • Create example usage scenarios

The key is to treat these as starting points that you'll enhance with your specific knowledge and insights.

Code review assistance

AI tools can serve as a preliminary code reviewer by:

  • Identifying potential bugs or edge cases
  • Suggesting performance optimizations
  • Flagging deviation from best practices
  • Proposing clearer variable names or better documentation

Learning and exploration

One of my favorite uses is accelerating the learning process. When exploring new libraries or techniques, I'll often:

  • Ask for minimal working examples
  • Request explanations of complex code sections
  • Generate practice exercises with solutions

Moving forward

The landscape of AI tools is evolving rapidly. The key is developing a mindset that embraces these tools while maintaining intellectual rigor. Don't be afraid of AI tools - harness them to your advantage. They are tools, part of your toolkit. Sharpen your ability to use them effectively.

Remember: the goal isn't to replace your thinking, but to amplify your capabilities. Use AI to handle the mechanical aspects of coding, freeing your mind to focus on the harder problems that truly require human insight and creativity.