← All AI Engineer talks

AI Engineer World's Fair 2024

Making Open Models 10x faster and better for Modern Application Innovation

About this talk

Fireworks AI co-founder Dmytro Dzhulgakov substitutes for scheduled speaker Lin Qiao and explains how specialized open models can improve application latency, cost, and domain-specific quality. He discusses fine-tuned Llama and Gemma models, function calling, GPU deployment challenges, custom CUDA kernels, long-prompt RAG optimization and caching, multimodal image-model serving, and structured JSON generation.

Chapters

  1. 0:00Speaker substitution and Fireworks' PyTorch background
  2. 1:38Smaller open models, customization, and function calling
  3. 5:27Production GPUs, CUDA kernels, and long-prompt optimization
  4. 7:47Multimodal serving and fine-tuned deployment
  5. 14:30Structured generation, developer adoption, and closing

Talk transcript

  1. 0:00

    [upbeat music] Hello, everyone.

  2. 0:15

    So my name is Dima. Um, as mentioned, uh, unfortunately my co- uh, co-founder Lin, who was, uh, on the schedule couldn't make it today because of some personal emergency.

  3. 0:24

    So you, you got me and as you saw, we don't have yet AI to figure out video, uh, projection, but we have AI for a lot of other things.

  4. 0:32

    Uh, so today I'm gonna talk about Fireworks AI and generally gonna con- continue this theme which Caitlin started about open models, uh, and how we, uh, basically focus on productionization and customization of, uh, open source models, uh, in inference at Fireworks.

  5. 0:48

    But first, uh, as a introduction, uh, what's our background? Uh, so f- the founding team of Fireworks, uh, comes from PyTorch leads at Meta and some veterans from Google AI.

  6. 0:59

    So we combined have like probably decade of experience in productionizing AI in some of the biggest companies in the world and I myself personally have been core maintainer of PyTorch, uh, for the past five years.

  7. 1:11

    So topic of open source is really close to my heart and since we kind of led this revolution of open source tool chain for deep learning through our work through, on PyTorch and some of the Google technologies, we really believe that open source, uh, models are the future also for like, for, for GenAI application and our focus

  8. 1:32

    at Fireworks is precisely on that. Um, so

  9. 1:38

    I mean, uh, how many people in the audience actually like use GPT and deploy it in for production?

  10. 1:45

    And how many people-- how many folks use open models, um, or deploy to production? Oh, okay. So I was about to convince you that share of open source models is gonna grow over time, but it looks like in this audience it's already [laughs] already sizable, but nevertheless, um, so why, why basically this trade-off?

  11. 2:04

    Why go big or, uh, why go small? Um, currently still like bulk of production inference is still based on proprietary models and, uh, the catch is that those are really good models and they are often fr- frontier in ma- in, in many domains.

  12. 2:18

    Uh, however, the catch is that it's one model which is good in many, many sense and it's often served, uh, in the same way, uh, regardless of the use case which means that maybe if you have batch inference, uh, on some narrow domain or you have some super real-time use case, uh, where you need to, you need

  13. 2:35

    to do like voice, uh, assistant or something, uh, those are often s-served from the same infrastructure without customization. In terms of model capabilities, it also means, yeah, like GPT-4 is great, uh, or, uh, Claude is great and can handle a lot of sense, but you are often paying a lot for additional capabilities which are not needed in

  14. 2:52

    particular use case. You don't really need customer support chatbot to know about 150 Pokémons or be able to write, write you poetry, uh, but you really want it to be really good in the particular, uh, narrow domain.

  15. 3:06

    So this, uh, can, uh, this kind of discrepancy for large models leads to several issues. One, as I mentioned, is high latency because using a big model means, uh, longer response times, uh, which is particularly important for real-time use cases like voice assistants.

  16. 3:22

    It gets more and more important with agentic stuff because, uh, for stuff like, um, for example, n-next [laughs] time is gonna be a Devin, right? Like you, you need to do a lot of steps for like something like agent-like application to do reasoning and call the model many times, so latency is really, really important.

  17. 3:38

    And often you see that you can pick smaller models like Llama or Gemma [laughs] which we, which we just talk about and achieve the, for a narrow domain, uh, same or better quality while being, you know, up to 10 times faster.

  18. 3:51

    Uh, for example, for some of the function calling use cases like externally benchmark from, uh, from Berkeley, yeah, like the, you get similar performance from fine-tuned Llama 3 at 10X the speed.

  19. 4:03

    Cost is also, uh, is, is also an issue if you're running a big model for, uh, on a lot of traffic. You know, even if you have perhaps, I don't know, 5K tokens prompt and 10,000 users and each of them calls LLM 20 times per day, you know, on GPT-4, even on GPT-4o, it probably adds up to

  20. 4:20

    like 10K per day or something like several million per month. Also se- several million per year which is a sizable cost of a startup. You can easily cut that with much smaller models and that often we see as a, uh, as a kind of motivation for reaching out for smaller and more customizable models.

  21. 4:39

    Uh, but really the, uh, like where open models shine is, uh, domain adaptability and that comes, uh, in two aspects. First, um, there is so many different fine-tunes and customizations.

  22. 4:50

    Uh, I think Caitlin was mentioning about, you know, Gemma built Indian languages adaptations like there are models specialized for code or for medicine. If you head to Hugging Face, there are like tens of thousands of diff- different model variants and because the weights are open you can always customize to your particular use case and tune and, uh,

  23. 5:07

    tune quality specifically for, for what you need. So open source models are great, so what are the challenges? Uh, the challenges really come from three areas. Uh, first like what we usually see when people try to use, you know, open model, something like Gemma or whatever, uh, or, or Llama 2B, uh, you run into com- complicated setup

  24. 5:27

    and maintenance, right? You need to go and find GPU somewhere. You need to figure out which frameworks to run on those. You need to like download your models, maybe do some performance optimization and tuning and you kind of have to repeat this process end to end every time the model gets updated or new version is released, et

  25. 5:43

    cetera. Uh, on optimization itself, uh, there is especially for LLMs, but generally for GenAI models, there are many attributes, uh, and settings which are really de- really dependent on your use case and requirements.

  26. 5:56

    Somebody needs low latency, somebody needs high throughput. Prompts can be short, prompts can be long, et cetera, and choosing the optimal settings across the stack is actually not trivial and as I show later, in many cases you can get multiple X improvements from doing, from doing this efficiently.

  27. 6:12

    And finally, like just getting it production ready is actually hard. Uh, if y- as you sc- kind of go from experimentation to production, even just BBC and GPUs on public clouds is not, not as easy because GPUs are finicky and not always reliable.

  28. 6:26

    Uh, but getting to enterprise scale requires, you know, sca- all the scalability technology, telemetry, observability, et cetera. So those are, uh, things which we focus on, uh, solving, uh, at Fireworks.

  29. 6:38

    So starting with efficiency, we built, uh, our own custom service stack, which we believe is one of the fastest, if not the fastest. Uh, we did it, uh, did it from the ground up, meaning from writing our own, you know, CUDA kernels all the way to customizing how the s- uh, stuff gets deployed and orchestrated on the

  30. 6:56

    service level, and that brings multiple optimizations. But most importantly, we really focus on customizing the service stack to your needs, uh, which basically means for your custom workload and for your custom cost and latency, uh, latency requirements, we can, we can tune it for, uh, for those settings.

  31. 7:14

    What does it mean in practice? And what does customization means in practice? Uh, for example, many use cases use RAG and, uh, use very long prompts. Uh, so there are many settings you can tune actually on the runtime level and the deployment level to optimize for long prompts, which often can be repeatable, so caching is useful, or

  32. 7:31

    just m- tune in settings so the throughput is higher while maintaining latency. So this is i- independently benchmarkable. If you go to, uh, you know, Artificial Analysis and select Long Prompt, where Fireworks actually is the fastest, even faster than some of the other providers which are over there at Expo booth.

  33. 7:47

    Uh, and, uh, we don't only focus, we don't only focus on LLM inference. Uh, we are focused on many modalities. Uh, as an example, for image generation, we are the fastest provider serving SDXL.

  34. 7:58

    We're also the only provider serving SD3, uh, uh, in, in, uh, Stability's new model because their API actually routes to our servers. Um, and finally, as I mentioned, with like L- LLMs, like customiza- especially for LLMs, customization matters a lot.

  35. 8:14

    Uh, one requirement, like one problem we have to think about performance of LLMs often it's useful for use cases is to think about maxi- like minimizing cost under a particular latency constraint.

  36. 8:23

    We often have customers come and say like, "Hey, I need to like have this, my interactive implication. I need to generate that many tokens under two seconds." And that's where, that's really where like cross-stack optimizations shine, uh, whereby, uh, tuning the particular like latency cutoff and changing many settings, you can deliver much higher throughput, multiple times higher

  37. 8:43

    throughput, uh, which bas- higher throughput basically means fewer GPUs and lower cost.

  38. 8:50

    Uh, in terms, in terms of, uh, model support, we support, support best quality open source models. Uh, you know, we heard about Gemma now, obviously, uh, uh, Llama's, uh, some of the, uh, ASR and text-to-speech models, uh, pretty much from, from many providers.

  39. 9:05

    We also work with model developers. For exam- uh, for example, eLarge, uh, in US is also served on, uh, on Fireworks, launched, uh, laun-launched, uh, last week. And, uh, as a kind of pla- platform capabilities, as I mentioned, we have a lot of op- open source models to st- uh, to get you started or cus- uh, customized

  40. 9:23

    ones. We do some of the fine-tuning of those models, uh, in-house. So I'm gonna talk a little bit about function calling specialized models, uh, later on, or we do some of the, uh, vision-language models fusion, uh, ourselves, which we re-release as well.

  41. 9:38

    And of course, the key for open source, um, mo- open model development is that it can tune for a particular use case. So we do provide a platform for fine-tuning, uh, whether you're bringing your dataset collected elsewhere or collecting it live, uh, with the feedback wh-when served on our platform.

  42. 9:56

    Uh, specifically on customization is like one, uh, interest... One interesting feature which a lot of people expe- starting to experiment with models, uh, find interesting is if you try to fi-fine-tune and deploy the resulting model, how, uh, how to serve it efficiently.

  43. 10:10

    Uh, it turns out if you do LoRA fine-tuning, which a lot of folks do, uh, you can do, uh, s- smart tricks and deploy multiple LoRA models on the same GPU, uh, actually thousands of them, which means that we can give you still serverless inference with paying for, per token, even if you have like thousands of m-

  44. 10:26

    uh, model variants, uh, sitting and deployed there without having to pay any fixed cost.

  45. 10:33

    Of, of course, single model is all great, uh, but what we see increasingly more and more in applications is model is not the product, right, uh, uh, by itself.

  46. 10:43

    You need a kind of bigger system, uh, in order to solve target application. And the reason for that is because, uh, models by themselves tend to hallucinate, so you need some grounding, and that's where like RAG or a- access to external, uh, knowledge bases comes in.

  47. 10:57

    Uh, also, we don't have, you know, yet an industry magical multimodal, uh, AI across all the modalities, so often you have to kind of chain multiple types of models.

  48. 11:07

    And of course, you have all these like external tools and external actions which, uh, uh, kind of end-to-end applications might want to do in agentic form. Uh, so I think the term which I really like, which was basically popularized by Databricks, is like compound AI system.

  49. 11:22

    But basically, re- increasingly seeing like transition from just the model being the product to kind of this combination of maybe like RAG and function calling and external tools, et cetera, built together as the product, and that's pretty much the direction which we kind of see, uh, th-this field mo- uh, moving along, uh, o- o- over time.

  50. 11:40

    So what does it mean from, uh, from kind of our perspective, what we, what we do in this case? Uh, so, uh, we see kind of as a function calling like agent as a, at the core of this, uh, emerging architecture, which might be connected to either domain specialized, uh, models, uh, uh, se- served on our platform

  51. 11:58

    di- directly or maybe tuned for partic- different needs, and connected to external tools, uh, maybe it's a code interpreter or maybe it's like external APIs somewhere, uh, with really like this kind of central agentic, uh, view, uh, kind of central, central model kind of coordinating and trying to triage the, uh, user, user requirements if it's, for example,

  52. 12:17

    a chatbot or something. Uh, you probably all, uh, heard about like function calling, you know, popularized by OpenAI initially. That's, uh, that's basically the same idea. Uh, so yeah, the function calling is really like a how to- How to connect, uh, LLM to external tools and exter- and, and external elements.

  53. 12:36

    What does it mean in practice? So we actually, uh, uh, fo- focus on fine-tuning models specifically for function calling. So we released a series of models like that, like the latest one, FireFunction, which was released two, uh, two weeks ago.

  54. 12:48

    And, uh, what you can do with that is, uh... Oh. Okay, if I manage to click.

  55. 12:57

    If I manage to click on this button. [laughs]

  56. 12:59

    Uh, w- what it means is, like, you can build, uh, applications which kind of combine freeform general chat, uh, capabilities with function calling. So in this case, uh, this is, you know, this FireFunction has some, uh, chat capabilities.

  57. 13:13

    So you can see, you can, like, ask it what, what you can you do, and it has, like, some self-reflection to tell you what it can do. It's also connected in this demo app to a bunch of, uh, external tools.

  58. 13:22

    So it can, uh, query, uh, like, stock quotes. It can plot some charts, all those, like, external APIs. Uh, it can, um, also gener- gen- generate images. But what it really needs to figure out is how to translate user query into, do complex reasoning, translate it into function calls.

  59. 13:40

    So for example, if you ask it to generate a bar chart with top three, uh, like with stocks of top cloud providers, like the Big Three, it actually needs to do several steps, right?

  60. 13:51

    It needs to understand that, like, top three cloud providers means, you know, AWS, GCP, and, uh, and Azure, right? And Azure is o- owned by Microsoft. It needs to, uh, then go do function calls querying their stock prices.

  61. 14:04

    And finally, it needs to combine those information and send it to chat plotting API, which is what just happened, uh, in the, in the background. Uh, another important aspect which you have to do for, like, ef- efficient, uh, kind of function calling chat capabilities, you need to have contextual awareness.

  62. 14:20

    So if I ask it to add particular, uh, if I ask it to add Oracle to this graph, it needs to understand what I'm referring to and, like, still keeps the previous context and regenerates the image.

  63. 14:30

    And finally, you know, if I switch to a partic- to a different topic, it kind of needs to drop the previous context and understands that, like, "Hey, this is less, uh, this historical context is less important.

  64. 14:40

    I'm gonna start from scratch." So there is no, like, Oracle in that cat photo or whatever. Uh, so you know, this particular demo is, uh, is, is actually open source.

  65. 14:48

    You can, like, go to our GitHub and try it out. It's built with FireFunction, and it builds with, like, a few other mo- a few other models, including, like, SDXL, which are run on our platform.

  66. 14:58

    Uh, the model itself for function calling is actually open source. Uh, it's on Hugging Face. I mean, you can of course call it on, uh, at, at Fireworks with, for optimal speeds, but you can also, uh, run it locally if you want.

  67. 15:09

    It uses a bunch of, uh, you know, functionality on our platform. Uh, for example, like structure generation, uh, with, like, uh, with JSON model grammar mode, which I think was similar to some of the previous talks from, like, outline guys, uh, which were talking here yesterday.

  68. 15:25

    Uh, yeah, so finally, try, try it out. And generally, like, how to get started on Fireworks. So if you head, head out to fireworksai.models, you'll, uh, you'll find a lot of, uh, open, open source, open base models, which I mentioned about.

  69. 15:38

    They're available in the playground. In terms of product offering, uh, we have this kind of range which can take you from early prototyping all the way to enterprise scale.

  70. 15:47

    So you can start with serverless inference, which is, you know, not different from, uh, getting to OpenAI Pi- uh, OpenAI playground or something, where you pay per token. Uh, it's a constant price.

  71. 15:57

    You don't need to worry about, like, hardware settings or anything. As I mentioned, you can still do fine-tune in, so you can, uh, you can do hosted fine-tune on our platform.

  72. 16:05

    You can bring your own LoRA adapter and still serve it serverless. As you kind of graduate to, like, maybe, like, a startup, and you graduate to, uh, more production scale, uh, you might want to go to on-demand, where it, where it's more, like, dedicated hardware with more settings and modifications, uh, for your use case.

  73. 16:20

    Uh, you can bring your own custom model fine-tuned from scratch or do it on our platform. And finally, as you kind of, if you scale up, uh, to bigger volume and want to go to enterpr- enterpr- enterprise level, where it's kind of discounted long-term, uh, long-term contracts, and we also will help you to kind of personalize hardware

  74. 16:37

    setup and do some of those tuning, uh, for performance, which I, uh, which I talked about earlier. And in terms of use cases, I mean, we're running production for m- uh, for many, many companies, ranging from small startups to big enterprises.

  75. 16:50

    We're serving, like, last time I checked, like, more than 150 billion tokens per day. So, you know, companies like Quora built chatbots like Poe. Uh, Sourcegraph and Coursera, which I think, I think Coursera had a talk here yesterday.

  76. 17:03

    They use us for, like, some of their code assistant functionality, and their, like, latency is really important. Uh, as you can imagine, you know, folks like Upstage and Liner are building, like, different assistants and agents, uh, on top of that.

  77. 17:15

    So, uh, we are definitely production ready. Go try, try it out. Uh, finally, we care a lot about developers, you, uh, you guys. Um, so actually, this is external numbers from, uh, like, last year, LangChain State of AI stuff, where turns out we are one of the, like, a- after Hugging Face, the most popular platform for where

  78. 17:34

    people pull models, which is great. Which is very, was very nice to, uh, nice to hear. And again, for, like, for getting started, just, uh, you know, head out to, uh, head out to our website.

  79. 17:44

    You can go in the, go play in the playground, uh, right away. So for example, you can run, you know, Llama or Gemma or whatever at the, at the top speeds.

  80. 17:53

    Um, and kind of go start building from there. I'm really excited to see what you can build with open models of FireFunction or some stuff which you can, uh, which you can fine-tune on, uh, on your own.

  81. 18:04

    And yeah, last point, we are, as I mentioned, OpenAI API compatible, so you can still use your, you know, your, your favorite tools, uh, the same clients, or you can use frameworks like LangChain or LlamaIndex or et cetera.

  82. 18:16

    So yeah, really excited to, uh, to kind of, uh, to be here and talk, tell a little bit about open source, uh, open source models and how we at Fireworks are, uh, focusing on productionizing that and scaling it up.

  83. 18:30

    Uh, go try it out, and you can also find us at the booth, uh, at the expo. Thank you. [upbeat music]