Research to Reality: Bringing Frontier ML Research to Production - Vaidas Razgaitis, Higharc
AI Engineer · 14 min · 117 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01Hey, I'm Vitis and I'm a senior research engineer at Hyark on our labs team.
- 00:06So, at Hyark our labs team is basically our research and development arm where we have machine learning researchers who kind of explore the frontier of AI/ML uh and figure out ways to apply it to home building.
- 00:26Now, because we're in home building and we're in spatial reasoning, uh we pretty much end up needing to use a lot of what's out there in AI.
- 00:34So, computer vision to scan hand-sketched floor plans and parse them into our internal data model,
- 00:41[music]
- 00:42um reasoning agents to kind of carry the user through these agentic experiences, we have custom transformers, uh we use diffusion models for image gen, uh and basically a lot of kind of what's out there in AI/ML
- 00:58uh we end up needing to use because of the kind of multidisciplinary nature of our product.
- 01:06So, hopefully that video gives you some idea of the research areas that we focus on that I've mapped out here.
- 01:13And that kind of leads us to uh the problem, which is in this in this challenge of getting frontier research into production, uh we need to start working with
- 01:24software engineers, let's say platform engineers, infrastructure engineers, back-end engineers who are very familiar with building robust and production-grade code, but are likely not familiar with the methodology and research
- 01:41in computer vision, in training your own LLMs, uh and even some top secret uh topics that I can't reveal here.
- 01:49Now, you kind of have the flip side problem with our uh ML researchers who are very up-to-date with the latest papers and can uh pull together these concepts in novel and creative ways to develop new features,
- 02:02but they have not really worked as software engineers typically where they've been responsible for production grade APIs.
- 02:11So, that's kind of what I want to get into is this this handoff, this this baton pass how do we facilitate that and how do we do it productively?
- 02:22And we look at this basically as a systems and process problem and I want to kind of zero in on three main focus areas that you can use to
- 02:35improve this the velocity of teams that that are bringing research into production.
- 02:42So, the first thing we'll look at is research legibility.
- 02:45So, let's say you have a ML researcher has produced a prototype concept.
- 02:52How can they map that out and make it digestible and understandable for these different software engineers and product managers who are going to be jumping into the project.
- 03:02The second is how to structure your code base.
- 03:05So, we use a mono repo.
- 03:07How do you arrange your code and modularize it so that it's ready to receive these new prototype concepts and turn them around and stand them up quickly.
- 03:17And then the third thing we'll look at is basically, you know, making the jump from a mapped out proven out research prototype that's going to be going into this
- 03:28repo.
- 03:29How do you decompose that prototype and stand it up on best practices in software engineering.
- 03:37So, taking a look at the first step, there's a really good article that I that I want to link a blog from the the pragmatic engineer where he talks about
- 03:47software engineering teams as they grow and start to scale how important it is to write out technical design documents, request for comment, whatever you want to call it, specifications
- 04:00before building software as a way to align teams.
- 04:04So, we have a very analogous document um that we require from all research prototypes that we call the research prototype taxonomy document.
- 04:16So, it's really just a technical design document from software engineering uh with some specific twists uh that um make it more digestible given its its nature in machine learning.
- 04:30So, the first thing in that document, we use notion for this, but obviously any written document will work, is that we start with the kind of domain context and like what are the domain specific
- 04:41you know, we're in the architectural domain and home building.
- 04:44So, what are these kind of novel ways to represent data?
- 04:47Maybe it's a party diagram, maybe it's a graph to to represent the kind of circulation graph through a home, maybe it's embedding models or latent space representations.
- 05:00I like to say kind of picture a software engineer who just we just hired from JP Morgan.
- 05:06What are the kind of uh specific lingos and and data representations that they might need to know before jumping into this project.
- 05:14The second is kind of mapping out the business goal, right?
- 05:17What's the why does solving this problem matter and what's the value in this ML tool?
- 05:23And then the four uh remaining parts of this document are pretty kind of conventional software engineering principles you might see in a TDD.
- 05:32So, the type safety, so we'll see later what our machine learning repo looks like, but what is the type contract between our core product repository and this machine learning repo?
- 05:46How are those types shared and how do they stay in sync?
- 05:50Um then kind of mapping out the the persistence layer.
- 05:53Is there a database?
- 05:55Uh this is an area where uh we think it's probably best not to have our researcher spend too much time in the persistence layer and just map out how far they got and this is a great first entry point once we start bringing in software engineering
- 06:13help on the project.
- 06:14Uh then kind of mapping out the the overall system architecture.
- 06:18Um is this a workflow?
- 06:20Is this a chaining of workflows?
- 06:22Are there external LLM calls?
- 06:24Like what is the anatomy?
- 06:26What is the kind of taxonomy of this research prototype?
- 06:30And lastly, how are we going to merge this?
- 06:32How are we going to decompose it?
- 06:34Um and we'll get into that more uh later as well.
- 06:38So, going back to these kind of three levers we can pull, the first is kind of that research project taxonomy document.
- 06:47Uh the second I want to get into are how we structured our code and how we serve our existing uh features.
- 06:57So, we basically have a a separate um repository from our core product repo and this is uh all Python based, right?
- 07:07It's all AI ML stuff and it's basically a mono repo of uh cleanly isolated and fully decoupled microservices.
- 07:18And so, let's say data-driven entity prediction is our custom transformer model.
- 07:24So, that is able to up to um kind of grow and be iterated on and be fully decoupled from a different research initiative and it's pretty much a one-to-one
- 07:36researcher to microservice ratio.
- 07:41So, we find that works really well.
- 07:43We have a kind of gateway that that guards requests um and it's all in one Docker Bridge network.
- 07:48So, the core um consumers our clients in our in our web application make kind of API calls to this gateway which then routes them to the appropriate microservice.
- 07:58Now, uh looking a bit closer at these uh individual microservices, uh we tend to build them in a pretty simple layered architecture, right?
- 08:08There's an API layer, the business logic and the data layer.
- 08:12And then we tend to have like some really um really cleanly documented specs uh so that agents can navigate these repositories and help accelerate our ML researchers as much as possible.
- 08:25So, yeah, kind of taking a another way to look at this layered architecture, we have kind of the core business logic at the services layer.
- 08:33Uh that might, you know, make external uh LLM calls to to foundation models or we might need to pull in our own uh machine learning model weights in CICD.
- 08:45Then we wrap that business logic with controllers.
- 08:48Um then we put API routers around those and expose them in FastAPI applications.
- 08:53And each of those microservices is a standalone application.
- 08:57And like I said in the last slide, it's not really the client that makes a direct call to this microservice.
- 09:01It kind of goes to that uh gateway first which routes it to the appropriate microservice.
- 09:08And then within each of those microservices um in the root in the root directory, we have essentially metadata, build instructions, a Dockerfile on how to how to build this application,
- 09:19uh the the kind of project dependencies, and then poetry or or UV uh lock files um as needed.
- 09:27And then so I'd like to kind of map out this um anatomical arrangement of our kind of three microservices that we have in production.
- 09:35And we can kind of see these these trends and and consistent skeletal backbones of these projects.
- 09:41Uh and it's very easy to map them out and make sure that they're growing um along best practices in software engineering.
- 09:49So, that's basically it for our for our mono repo.
- 09:52We have these kind of microservices and then uh sharing basically like underneath all of that in the repository, we have some GitHub actions to to build and deploy our automated
- 10:03test suites and kind of linting, formatting, and type checks, all the stuff you'd you'd kind of expect.
- 10:09Uh we have some Jupyter notebooks that run on on Modal for GPU compute, um as well as some additional ML studies, but really the way we look at it is we have this kind of tooling layer and even this kind of fun
- 10:21CLI, but these all just support our ML engineers in bundling up these microservices that we uh serve in production.
- 10:32So, that's kind of the the RPT is the is the handoff document between an ML researcher and additional software engineering uh talent.
- 10:42The mono repo is is where that um research project is ultimately going.
- 10:48And then the only remaining step is, well, how do we get there, right?
- 10:52How do we jump from one to two?
- 10:54And the third lever I want to talk about is the kind of decomposition uh and PR review plan.
- 11:01Uh and we look at that really as a design problem where we need to kind of um figure out how to slice and dice a a large research uh monolithic prototype.
- 11:12So, here are just some images of of um an uh platform-wide agent feature where you know, we really studied what axes to slice uh and dice these projects up on, what that dependency graph would look like.
- 11:26And then we use Graphite um for kind of stack diffs to then uh decompose these large monolithic prototypes that have been proven out um and then get the right eyes on on review to make sure that these are ready for production.
- 11:40Uh we really like Graphite because it allows for asynchronous review, right?
- 11:45I could be working on a PR all the way up here while a domain specialist is still reviewing a different PR.
- 11:51And once we've kind of decomposed these PRs uh thoughtfully, we can start tapping uh subject matter experts throughout the organization on the specific slices or tightly uh decomposed PRs
- 12:06uh that need to look at.
- 12:10And so again, there's there's a lot of overlap between this initial research project uh taxonomy document where once we've mapped out these layers, these the architecture, what kind of persistence there is in the types,
- 12:23that tends to inform uh your decomposition strategy on how to bring it into the into the mono repo.
- 12:31So, to wrap things up, I want to revisit these kind of three focus areas that you can use to evaluate how well your team is bringing research into production.
- 12:43And I want to talk about kind of some some diagnostic frameworks to understand if you need to spend a bit more time and attention in any of these three.
- 12:53So, in the first step with your research legibility, as your team starts to staff research initiatives with product people, with software engineers, with AI engineers, is it obvious where they should concentrate
- 13:08their efforts?
- 13:09And is it clear uh what kind of tasks they need to pluck off to bring this prototype into production?
- 13:17If there's ambiguity in there, you may need to spend some time revisiting this process.
- 13:22In step two, your code repository.
- 13:26As you start getting ready to bring prototypes into your production grade code base, is it clear where these buckets lie to put in new code?
- 13:37Are there templates and existing frameworks and patterns that you can mimic?
- 13:42Or is it possible that maybe you've started to outgrow that code base and that system architecture, and every time you bring in new research concepts, you're fighting these old abstractions
- 13:54and having headaches from limitations of your repository.
- 13:58And then lastly, in the decomposition phase, are you able to consistently estimate the timelines and delivery dates for moving research concepts into your repository?
- 14:12Is it clear which subject matter experts you should tap for review and for productionizing this research?
- 14:20Uh and if you're having issues here, it probably points to the stream issues, either in uh how this research is being coordinated and handing off, or perhaps the code base that's hosting it.
- 14:35Uh anyway, that's about all I've got.
- 14:37I hope this is helpful.
- 14:39I love uh thinking about ways how our team can speed up how quickly we can bring research concepts into production.
- 14:47And if you made it this whole way, you're probably interested in that stuff, too.
- 14:51And I would love to compare notes uh and trade ideas anytime.