ai/ml
Artificial intelligence, machine learning, and related topics including large language models, automatic speech recognition scripts, StableDiffusion workflows, and middleware for multimodal integration.
Thinking Like a Developer, Pt. 1
When our backup pump failed on the homestead, I built a calculator to figure out what we really needed. It’s a small, open-source tool born from necessity and a few iterations with self-hosted AI.
I live on a homestead in southern Oregon, surrounded by the vastness of the Umpqua National Forest in every direction. It’s the kind of place where nature dictates the rhythm of life. We rely on a natural mountain spring for water most days, but when that fails (as nature sometimes does), we turn to a small stream or a mile-long ditch. According to local lore, some intrepid homesteader dug that ditch in the early 1900s to water a single cow.
These water sources connect to a network of pipes, backup pumps, and an unoptimized system that could generously be described as "inventive." When our pump failed recently, we faced an immediate and critical question: how powerful does a replacement pump need to be?
From Problem to Solution
To answer that question, I did what any coder-lawyer-homesteader would do—I wrote a script. Specifically, a pump power calculator that factors in pipe diameter, flow rate, pipe material, and other inputs to calculate the horsepower needed for a given setup. The calculator takes inputs like pipe diameter, distance, flow rate, and water temperature to compute the minimum required pump power. It factors in key considerations like friction head loss, flow velocity, and static head, ultimately providing recommendations with a built-in safety margin. For example, in our setup, with a 4000-foot run of 1" pipe that rises up around 120 feet and delivers around 7.5 gallons per minute, it calculated we needed at least 0.75 HP—but 1 HP if we want a 30% safety margin.
You can try it out for yourself at pumpcalc.sij.ai, and if you’re curious about the code, it’s open source at sij.ai/sij/pumpcalc. I built the calculator in Python using FastAPI for the backend and Jinja2 for templating—simple, reliable tools that get the job done without unnecessary complexity.
This wasn’t a solo endeavor. I leaned on the open-source AI tool Ollama and specifically QwQ, a powerful 32 billion parameter research model that rivals leading commercial AI systems like ChatGPT o1 in reasoning capabilities. QwQ particularly excels at technical problem-solving and mathematical tasks, making it perfect for engineering calculations like this.
The Iterative Process of Coding
Developing this script wasn’t a one-and-done affair. It took five back-and-forth sessions with the AI to:
- Factor in relevant variables like pipe roughness and flow rate.
- Exclude unnecessary inputs that made the interface clunky.
- Add some polish, like the Gruvbox Dark color scheme that now graces the app.
Each iteration made the calculator more useful and user-friendly. By the end, I had something functional, simple, and—dare I say—elegant.
Why Share This?
I’m sharing this as the first in a series of "Thinking Like a Developer" stories, because I believe coding isn’t as mystifying as it might seem. If a lawyer on a homestead with a temperamental water system can write a pump calculator, anyone can. The key is thinking like a developer: break the problem into smaller, solvable pieces, and don’t be afraid to consult tools or collaborators along the way.
This approach to problem-solving—breaking down complex challenges and leveraging coding tools—mirrors how I approach legal technology challenges. I frequently rely on Python and AI libraries to streamline legal work, from document analysis to case law research. Whether it's calculating pump requirements or processing legal documents, the fundamental thinking process remains the same. Who knows? You might find your next project hidden in a problem you didn’t even know you wanted to solve.
Hello, world!
Welcome to my blog!
You likely already know me if you’re reading this, but in case these blogs reach new readers, please forgive a brief introduction. I’m Sangye Ince-Johannsen. I'm a staff attorney at the Western Environmental Law Center, where for five years I've litigated environmental cases in federal court on behalf of various local, regional, and national, and international conservation-oriented nonprofit organizations. My docket largely focuses on defending spotted owls, anadromous fish, grizzlies, wolves, and their respective habitats from federal and federally-licensed activities in cases brought under the Endangered Species Act, National Environmental Policy Act, Administrative Procedure Act, and Clean Water Act.
Before pursuing my legal career, I worked as a documentary filmmaker and videographer for four years in southern Oregon. During that time I had the privilege of working on documentaries including One Billion Rising (2013) by Eve Ensler and Robert Redford, When Giants Fall (2015) by Leslie Griffith, narrative films including Redwood Highway (2013) and Wild (2014), outreach videos for the Neighborhood Food Project among other regional nonprofits, and numerous music and event videos.
Going back even further, before my undergraduate studies in Anthropology, Videography, and International Relations at Southern Oregon University, my first interest—my first love, even—was computer science and programming. After a long hiatus, my passion for programming, especially AI/ML research and development, has been rekindled. Recent advancements in AI have me particularly excited about leveraging large language models and automatic speech recognition to become a more productive and effective advocate.
Vision for this blog
That’s what I hope to do with these blogs: share AI/ML scripts, workflows, and apps, along with key caveats and considerations, with other litigators and knowledge workers. I also intend to share some legal analysis and other fun stuff—AI image and speech generation, drone videography, self-hosting tools and tricks—along the way.
So, what’s with the two URLs, you may be wondering? For most of my posts, especially at the outset, you’ll get the same content whether you visit sij.law or sij.ai. However, if you’re a litigator and not necessarily an AI/ML enthusiast, there will likely be posts that aren’t interesting to you in the slightest, which I’ll save for sij.ai. If you’re passionate about AI/ML productivity hacks but not necessarily a litigator or interested in deep legal analysis, you’ll likely have a better time over on sij.ai. Either way, thanks for dropping by, feel free to explore some of my current projects in the site navigation, and I can’t wait to engage with you in the comments or on social media.
Cheers!
〄
Edit on 9/25/24:
I've decided to devote sij.ai to a dev and code hub rather than a parallel topical blog. That means all posts, whether related to law or ai/ml, will be consolidated here, and you can use the tags law and ai/ml to isolate one topic or the other.