Scaling GenAI Inference From Prototype to Production: Real-World Lessons in Speed & Cost
Summary
- Prototype to Production Scaling: Scale GenAI inference from initial prototypes to processing millions of documents using Databricks Workflows, Model Serving, Serverless Compute, and Notebooks.
- Multi-Language AI Processing: Handle diverse languages and content types (ebooks, audiobooks, research papers) at scale using LLMs while managing language-specific challenges in GenAI inference.
- Modular, Cost-Efficient Pipelines: Design parameterized notebooks that run concurrently, enabling rapid prompt tuning, data iteration, and quality testing while keeping costs low through efficient compute management.
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in Speed & Cost

Talk by Anish Kumar, Lead Engineer, Scribd, Inc
This lightning talk dives into real-world GenAI projects that scaled from prototype to production using Databricks’ fully managed tools. Facing cost and time constraints, we leveraged four key Databricks features—Workflows, Model Serving, Serverless Compute, and Notebooks—to build an AI inference pipeline processing millions of documents (text and audiobooks). This approach enables rapid experimentation, easy tuning of GenAI prompts and compute settings, seamless data iteration and efficient quality testing—allowing Data Scientists and Engineers to collaborate effectively. Learn how to design modular, parameterized notebooks that run concurrently, manage dependencies and accelerate AI-driven insights. Whether you're optimizing AI inference, automating complex data workflows or architecting next-gen serverless AI systems, this video delivers actionable strategies to maximize performance while keeping costs low.
Databricks Named a Leader in the 2025 Gartner® Magic Quadrant™ for Data Science and Machine Learning Platforms: https://www.databricks.com/blog/databricks-named-leader-2025-gartner-magic-quadrant-data-science-and-machine-learning
Build and deploy quality AI agent systems: https://www.databricks.com/product/artificial-intelligence
See all the product announcements from Data + AI Summit: https://www.databricks.com/events/dataaisummit-2025-announcements
FAQs
What is Scribd's GenAI inference project about?
Scribd built an AI-powered metadata extraction system that processes millions of documents (ebooks, audiobooks, research papers) across 20+ languages. The system extracts text, transcribes audio, and uses LLMs to generate metadata for discovery and recommendations.
How does Databricks' Serverless Compute help with GenAI inference?
Serverless Compute automatically scales resources up and down based on demand, enabling cost-efficient processing of large document volumes. This allows teams to experiment with GenAI prompts and processes without worrying about manual resource management.
What makes this approach multi-language capable?
While LLMs excel at English, the system addresses language-specific challenges through careful prompt engineering and data handling. Scribd leverages Databricks' scalable infrastructure to process content efficiently across 20+ languages.
How are modular notebooks used for efficiency?
This approach uses parameterized notebooks that run concurrently, enabling rapid iteration on prompts and data. Data scientists and engineers can experiment and test quality in parallel, accelerating insights while minimizing wasted compute.
Full transcript
All right. Okay. Welcome everyone. I'll be talking about scaling Gen AI inference today. If you scan that barcode at the bottom of the screen there, it should take you to a a slides share presentation and so you can follow along. You don't have to take pictures and stuff unless you unless you want to. You can take pictures if you like, but uh it's all on there. You can follow along. Um so I'll be talking today about taking a few projects from prototype to production.
So a bit of background, I work at script. Script contains three brands, Everand, Slice Share, and Script. On Everand we have premium content from various publishers like Penguin Random House. It contains lots of ebooks and audio books. Everything from like mystery, romance, sci-fi, fiction, non-fiction. Script is another brand where users upload content. Um they upload a lot of interesting content. If you check it out, we have stuff all the way from like lecture notes, um uh research articles to things like software installation guides, manuals, all that sort of stuff.
And slides share. The slides share hopefully is the place where you're looking at this presentation. So the most important bit about this slide I want to cover is we have a fairly large corpus. We have about 280 million pieces of content. Uh we have a lot of audio books both in terms of the number of audio that's consumed by people and hosted millions and millions of hours. We also are multilingual so we have over 20 languages.
All right. So how did this get started? The way this got started is on a project called u metadata extraction. So in this project was one of the first ones we did using uh Jan LMS. The idea was that we want to extract text from ebooks and we want to transcribe audio books, extract the text and then we want to send it over to an LLM with a prompt to extract metadata. The kind of metadata I'm talking about is stuff like characters, character plots, themes, tropes, that sort of stuff because we're going to use that to help users find content on our site through discovery and recommendations. and we were going to hub search and SEO.
So the bigger picture you can think of this as we have some data that we need to prep for inference. We want to combine that with a prompt and then finally we want to derive some value. Now the unique challenges that we have like I was saying we have lots of languages. We know that LLMs are really good at handling English but not so much so in all other languages. We have languages such as Spanish, Portuguese, Indonesian.
Uh we also have a fair book of a bit of audio books and ebooks that we need to go through and at the time we needed to use real time whisper because data bricks had not supported pack whisper at the time. So before actually starting on this process, we need to evaluate LLMs. The graph by the way I'm trying to show that we started off really slow with audio transcription and then over time week five and week six was when we really figured out how to scale stuff and get lots of audio transcription going.
So this you know this slide talks about how the journey started and where we were able to get to. Speaking about evaluating LLMs, this is for a more recent project that I wanted to show you all. Um, evaluations are still under progress for this project and we don't want to disclose what models we talking about here. But this is a true graph. As you can see, cost and quality are really important because model 3 is really cheap compared to model one.
And model 3 performs at the same level as model one. So this sort of stuff is really important because when you're talking about a corpus of our size, it equates to millions and millions of dollars of savings. Talking about prompt engineering for this specific project, there's a few interesting things uh that I want to discuss here. Unit testing. So the previous graph you were seeing that was talking about quality was unit tests.
Unit test is a is a way for us to ascertain if the output can be used by downstreams. It's also actually a good way to figure out if you have hallucinations. We work with our data science team to kind of look at the output data and figure out a few metrics such as if the output is not parsible. If all the key value pairs aren't represented and if it's not the correct data type then we failed the unit test. For the particular project, we annotated about 20 ebooks and audio books.
And after the annotations were done, the scoring was similarity measured. So what that means is we have a particular character or character plots that the annotation datators have suggested. If it's similar to the LLM output, then it scores really well. Otherwise, no. We did a similar thing for precision and recall. So now we were ready to start our uh inference. I'm actually going to switch to using this one. I don't know why that's not working that well.
What I did was I went ahead and uh on a data bricks notebook I tried to do audio transcription. Um and this code shows what what I did. Essentially I need to convert the input data which is MP4 files into B 64 bytes. So I did that and then after that I sent it over to a realtime whisper inform. You can see the transcription is at the very bottom there. Um it looks kind of okay. So that was fine but it was really really really expensive and very slow.
So why was that the case? The reason for it being really slow and really expensive was was because I was spending a lot of time just waiting and waiting. The servers, the CPUs were doing one particular piece of audio file at a time and they were making single sync requests to the GPU and this ended up becoming really really really expensive. It would have taken a really long time and cost a lot of money. Uh so this is I mean a bit of a naive solution but a start.
So then uh we asked for help. We were like please help us. This isn't working. It's going to take a really long time. I um you can ask me afterwards. I did a whole bunch of other stupid mistakes too. Um uh which ended up costing us a lot of money as well. I left it running. I left those notebooks running for a night and it was really expensive. So anyways, the databicks team really partnered with us. Uh they kind of got to us, understood our problem.
Um kind of tried to figure out what they should suggest and they told us to go with data bricks workflows and batch inference. At the time they said async inference but now uh we have uh batch inference at data bricks. So I'm pretty sure that's what they would recommend. How many of you all are familiar with workflows? Okay, about 25%. So, um, workflows are really easy to get started off with in my opinion. If you scan that QR code, it take you to the intro page uh about workflows.
Um, so in in my opinion, start off with the UI, set up a task, you can point a task to a notebook, and then you should parameterize your notebook. In our case, the parame parameters would be document ID or batch ID. Batch ID is just a collection of documents in an input table and set your concurrency. Concurrency is basically the number of tasks or notebook instances that the workflow will run at the same time. The next thing I wanted to take a look at was if there are APIs and I'm very glad I'm very happy that APIs exist for everything.
That piece of code that I'm sharing there is the same piece of code I've been using for the last I think one one and a half years. It's very simple. Given a particular job ID from your workflow and given params, you can trigger any of these workflows and based on your concurrency setting, it'll run those many tasks. Now for visibility, one of the things and learning from my previous mistake about spending a lot of money not knowing, it's very important to try to finish in my opinion a task within one to two hours and to also uh kind of insert rows or do some sort of insert every 100 or every thousand rows in a time into the output table.
That way you know stuff is happening and things are working. Um and then the other thing we discover is that there's a constraint. The constraint is that if you have a particular task that's been infued but hasn't started for uh 48 hours will automatically get cancelled. So now knowing these things I next was thinking about how to structure the notebook. A few important things here are that we worked with our data scientists and we think we think it is really important and it's been working out really well for us to log experiments like all your evaluations and results and store the prompts and the versions so that everything is accessible to you within like the notebook in your workspace and you can put put it on GitHub for the 48 hour limit issue.
What I did was the params can be anything. They don't have to be integers. They don't have to be doc ids. They don't have to be single batch ID. I can supply an array of batch ids. So in this case, if batch ID 10 um doesn't start within 48 hours, no problem because the notebook is running u right it's been running from the start and the code there shows that essentially you're sequentially processing batches and you're producing outputs every 100 or thousand rows at a time.
Now in terms of you know thinking through this whole problem and thinking about solutions you know this is a very important point I believe there's no big problems there's a lot of really small problems if you make a problem into small little problems they're much more easier to solve if you scan that QR code it'll take you to everand there's a really good book about bulletproof uh problem solving that I highly recommend also especially just for you guys today we have a promo code D A I S25.
That's D AIS-25. Um you can use that promo code and you'll get a free unlock. So with that, you know, um um I worked with the team, we came together to think about a new way of solving this problem. And this way of solving the problem has lots of benefits. It's not only about like splitting the problem into smaller chunks for the purpose of you know pipelining. It also helps you understand where the risky portions are.
It also understands helps you understand where to put more resources on what things you already know how to do and what are the net new things. So we thought about it in this way and thinking about in this way has an advantage that preparing input data is something that we're already familiar with. So I'm going to talk about a few details to this. The thing that we think is most important about preparing input data is that we should partition the data to whatever batch ID and number of books can finish in an hour or two hours by an LLM.
I'm showing an example there of the audiobook transcription. And so by testing we came up with about a thousand books per batch finishes in that much time. Now I'm doing it all using spark. Uh so I think using dedicated compute is really good idea for this. Um I wouldn't use serverless compute for this because dedicated compute um you can select your M orc type cluster. We're in Amazon that's why MrC type clusters you know you can do the same thing on other clouds.
You can check the metrics and really optimize that. The reason for using workflow for this uh thing was that I could paralyze batches. So I could do 100 batches at the same time in the workflow and if a batch finishes uh or sorry if the batch fails if it finishes that's awesome. If it fails I just have to rerun that particular batch. So I can figure out my anti-ch and just do that one. So now we get to the place about talking about inference.
And this is where I think serverless compute shines. So the main thing about this image I'm trying to show is use serverless compute. You don't have to set up um any of the your configs and specs for dedicated compute. Serverless comput is going to be really good at doing this because the bottleneck is really the inference. It's not going to be your serverless compute. So you can save time by just doing it that way. So for real time inference the code we came up with and this is the same code we've been using um for multiple projects is we look through all the batches we do a collect operation and that collect operation brings in um the data onto the driver right so the so it's basically selecting like a thousand books and then this is showing you a real time call that's that's happening the real time call uh is essentially going to one of our LLM APIs and I'm saving results uh a thousand at a time in this case.
Now that talks about real time inference. We've been using the same thing for batch inference. Uh the code shown below is for AI query which I highly recommend because it's a uh with the serverless back inference that's available that's very easy to use with different LLMs especially llama but you can also use the same thing for doing uh for using open AI or Gemini Vertx AI because all the differences between batch inference and real time at this level is instead of making single API calls or async calls you're creating a batch batch of JSON payload with a thousand documents in our case and then you're pulling the batch and getting the responses and saving those responses into the output table.
So speaking about results we have been able to process across multiple projects quite a few different pieces of data. uh this spans not just uh tune AI projects some some of them are as you can see uh document embeddings uh and transcriptions but also other projects where we have external APIs involved and we've been doing uh most recently multimodal uh so that's why we have been uh doing screenshotting images and extracting images so in terms of uh the core improvements um these are the ones that I think are really important before um you know developing the system and this process we used to take about a month using airflow and data bricks jobs to complete this process.
Now using preparing data uh during your API calls uh to the LLM endpoint and then finally validating and producing the output data we're able to do it in two weeks. The cost estimation is also a lot faster because we're able to kind of you know just work on a P for the two first two stages and then extrapolate the numbers. So I would just do a thousand books, make sure the job finishes in in an hour or two and make sure the outputs look okay and then I can extrapolate those numbers.
And so the project that was going to cost a million ended up costing about $300,000 with all this optimization. So the thing I want to recap is we have a system now that you know bas these were requirements before uh you can think of them as goals we were able to achieve this we're able to separate out distinct steps for preparing input data using spark that's fast it's independent for performing a API calls using serverless we were able to figure out how to control concurrency using serverless just making it sure that it's at the API limit and made it easy to change prompts And finally, the validation is a separate step at the very end.
So we are not validating while performing API calls. We're just saving the JSON output as is and we're parsing and validating afterwards to make sure that it's going to be usable for downstreams. Yeah. So this slide this captures essentially what we did and lastly I mean all the results are available in the unity catalog for consumers. Check out uh tech. script. com we are hiring. There are lots of other cool projects that we work on other than the one I spoke about today.
Lots of cool stuff there. Uh we're going to we have blog articles coming out constantly. I do not have do not have all the time. I only have a minute left so I do not have all the time to discuss everything in detail. So I am going to post a blog article here. If you follow me on LinkedIn, you'll get to know when it's posted. Yeah. So these are just some of the interesting problems that we are solving. uh multimodal and multilingual are very huge for us and content trust also is something that is very challenging giving our corpus but uh we are working on all these challenges right now cool I think that's my time I'm happy to take any questions we have a few other people from script here as well so if you have any questions for them please feel free to ask
Learn more about the Databricks Data and AI platform.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.