AI Engineer World's Fair 2024
Navigating Challenges and Technical Debt in LLMs Deployment
Read the talk
The Engineering Around an Enterprise LLM
Enterprise data can give language models useful organizational memory, but deploying that memory requires retrieval, authorization, infrastructure and governance beyond the model itself.
From a talk by Ahmed Menshawy
Before you start: Familiarity with language-model prompting and the distinction between model training and inference will help; retrieval-augmented generation is explained as it appears.
From structured predictions to organizational memory
What happens when the data an organization wants to use is mostly outside the structured datasets its machine-learning systems handle well? Ahmed Menshawy opens with that mismatch. Supervised learning and deep learning made labeling and prediction valuable enterprise capabilities, but much of an organization’s knowledge remains unstructured.
Menshawy cites estimates that more than 80% of organizational data is unstructured and that 71% of organizations struggle to manage and secure it. The talk does not establish the survey populations or measurement methods behind those figures. The practical problem is nevertheless clear: possessing information does not mean an organization can safely turn it into answers or recommendations.
Language models offer a way to use that information as external memory. Supply relevant domain data as context, and a model can formulate an answer around information specific to the organization. That changes the deployment problem: the system must make organizational knowledge available to the model while retaining the constraints that governed that knowledge before it entered an AI application.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Augmentation, current risks and autoregressive errors
At Mastercard, Menshawy frames generative AI as augmenting human productivity. He contrasts that goal with job-replacement predictions and doomsday rhetoric, invoking the Nature editorial Stop talking about tomorrow’s AI doomsday when AI poses risks today. His criticism is pointed: some prominent advocates of catastrophic-risk narratives also release systems that expose users to immediate risks. Identifying those existing harms gives regulators concrete targets for policy, while leaving room to adapt when new algorithmic approaches emerge.
He then separates the usefulness of LLMs from his expectations about artificial general intelligence. Referring to Yann LeCun’s work on objective-driven learning, Menshawy argues that current LLM foundations do not provide the route to AGI. The technical concern he emphasizes is autoregressive dependence: each generated token becomes part of the context for subsequent tokens. An early mistake can therefore influence later generation and grow into a longer, internally consistent but incorrect answer.
Menshawy connects this concern to Ada Lovelace’s 1843 discussion of the Analytical Engine: a machine performs operations it is directed to perform rather than originating something independently. He treats that observation as still relevant roughly 180 years later. Extending an argument about the Analytical Engine to modern machine learning is his interpretation; the concrete deployment concern remains the dependence of later output on earlier generated content.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
The interface breakthrough and a fraud-detection application
Next-token prediction did not begin with OpenAI. The idea of predicting a token from its context predates today’s assistants by decades. In Menshawy’s account, ChatGPT made the capability accessible through a conversational interface: users could ask for something naturally and receive a response without learning how to interact with a raw language model.
That interface also depended on training data. Menshawy describes a base model trained on internet-scale material, followed by additional phases using manually produced question-and-response pairs. Conversational examples supplied behavior that was comparatively scarce in the underlying corpus. The distinction is between learning broad language patterns and making those capabilities usable as an assistant.
A critique of the foundations does not preclude useful adoption. Menshawy describes Mastercard’s approach as responsibly reducing the risks of the technology and points to its February 2024 fraud-detection announcement. Mastercard’s initial modelling for Decision Intelligence Pro reported fraud-detection-rate improvements of 20% on average and up to 300% in some instances. Rollout was then forecast for later in 2024; the announcement did not disclose an evaluation dataset or a precise baseline, and it did not establish a conversational LLM architecture.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Four requirements for a deployable application
A successful generative AI application needs more than a foundation-model endpoint. Menshawy identifies four essentials: access to a variety of models, an environment for contextual customization, tools for building and deploying applications, and scalable ML infrastructure. Scaling includes the time required to bring replicas online: capacity that arrives too late does not solve the user’s immediate demand.
| Requirement | Main deployment challenge |
|---|---|
| Foundation-model access | Balance model size against cost |
| Customization environment | Accommodate models larger than existing platforms expect |
| Build and deployment tools | Work with a young, changing ecosystem |
| Scalable ML infrastructure | Add usable capacity quickly enough |
Menshawy rates model access as comparatively straightforward because models are available, even though selection still involves trade-offs. Existing enterprise AI environments are less certain to fit these models. He considers application tooling the hardest part: much of the earlier tooling does not fit the new workflows, while the replacement ecosystem is itself new. His slide uses color to distinguish these levels of difficulty.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
The model is a small part of the system
Infrastructure demand also continues after training. Menshawy describes an OpenAI chart as showing inference GPU compute and RAM growing beyond the resources used for training. Without the chart’s workload and accounting conditions, that comparison cannot serve as a capacity-planning ratio; its relevance here is that serving a model can become a substantial, continuing infrastructure obligation.
The 2015 paper Hidden Technical Debt in Machine Learning Systems provides the broader architectural picture: ML code occupies a small box surrounded by the rest of the production system. Menshawy describes model code as less than 5% of the pipeline and surrounding engineering as more than 95% of the work. The paper’s numerical example is narrower: under a glue-code anti-pattern, a mature system might contain at most 5% ML code and at least 95% glue code. That is a warning about code composition, not a measured allocation of engineering labor.
AI engineering includes responsibility for the end-to-end system. Connecting APIs is part of that work, but it does not account for everything surrounding the model. The small central box is useful precisely because it redirects attention to the components that make a model usable, maintainable and operable.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Where closed-book models meet enterprise constraints
The first architecture Menshawy considers is closed-book generation. An application uses a foundation model directly, supplies a few examples, or fine-tunes it on domain data. In each case, the application relies on knowledge held in the model rather than consulting an external source at answer time. Enterprise accuracy requirements expose several limitations of that arrangement.
- Hallucination: The model can produce incorrect information confidently.
- Attribution: An answer does not necessarily reveal why the model produced it or which source supports it.
- Staleness: Knowledge embedded in parameters becomes outdated.
- Revision: Changing or removing particular information requires difficult model editing.
- Customization: Domain fine-tuning does not by itself ensure that generated claims come only from the organization’s information.
For revision, Menshawy invokes GDPR and an unspecified California law to motivate honoring opt-outs and limiting the future influence of personal information. Those references motivate an engineering requirement here, rather than establish a blanket legal obligation to remove every training influence. Editing information in either a foundation model or a fine-tuned model remains the technical difficulty.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Give the generator an external memory
Retrieval-augmented generation, or RAG, retains the foundation model and adds context retrieved from domain-specific data. The application can consult external memory when answering instead of requiring every relevant fact to be encoded in the model’s parameters.
Retrieved evidence can improve factual recall and reduce hallucination. Menshawy points to Retrieval Augmentation Reduces Hallucination in Conversation, which evaluates that benefit in knowledge-grounded dialogue. Reduction is the relevant claim: supplying context does not guarantee that a generator will use it correctly or restrict itself to approved facts.
External memory also changes how knowledge is maintained. Updating or swapping a vector index can refresh the information available to retrieval without editing the generator’s parameters. Removing material from that memory supports revision of what the application retrieves, although it is a different operation from erasing information learned during training. Returned sources provide an attribution path: an application can inspect the evidence supplied for a generated answer or decision.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Retrieval and generation must work together
The contextualization diagram surrounds its retrieval-and-generation path with questions about chunking, retrieval, prompting, verification, memory and optimization. Menshawy emphasizes that even these are only part of the production problem. A central question is whether the retriever and generator are optimized to work together.
A common RAG implementation connects two independently developed components: the retriever returns passages, and the generator receives them as context. Menshawy calls them “two separate brains.” The original FAIR paper, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, instead describes coordinated optimization of retrieval and generation. His phrase about training in parallel refers to that shared optimization, not merely running two unrelated training jobs simultaneously.
Access to model parameters makes this coordination possible. With open model weights, teams can fine-tune the generator to produce factual answers from the evidence the retriever actually supplies. The objective goes beyond attaching memory: the generator must learn how to use the retrieved information. That is a different level of control from treating the model as an opaque endpoint and modifying only its prompt.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Governance and the decision to use an LLM
Mastercard’s adoption framework, as Menshawy describes it, includes seven responsible-AI principles. He names privacy, security and reliability, then adds the organizational mechanism that makes principles enforceable: a governing body and a clear strategy for applying them during development. Adopting an LLM for a service remains conditional on safeguards, including access controls and protection against biased output.
That work can change the decision about whether to use an LLM at all. Menshawy recalls that a reviewer who accepted the deployment paper nevertheless wondered whether LLMs were the right tools for some applications, given the challenges and technical debt it described. His response is that transformative technology brings implementation difficulty with it. The tension is productive: potential value does not remove the obligation to assess the engineering burden, and that burden does not automatically negate the value.
He closes by directing readers to Mastercard’s AI engineering blogs for work on putting AI into production—the same surrounding components represented by the boxes outside the model. The application has to deliver useful answers while preserving the organization’s operational and governance requirements. Those obligations remain even when the model itself is only an API call away.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
The 2015 paper examining maintenance costs, data dependencies and system design anti-patterns around machine learning.
Research evaluating retrieval-based dialogue models and their reduction of factual hallucinations.
The original RAG paper combining a neural retriever, external document memory and a generative model.
Further reading
A compact presentation of deployment requirements, retrieval architecture and the engineering systems surrounding an LLM.
An author-contributed overview of the April 2024 ACM paper on production deployment challenges.
Read the complete timestamped transcript
- 0:00
[on-hold music] Hi, everyone. I'll try to touch on three main things and, uh, mainly how AI moved from excellence in structured data to LLMs and the use of unstructured data
- 0:25
that most of our organizations have. And also we'll touch on intelligence augmentation and really the hype around AGI and, and the doomsday. Uh, and finally, we'll, we'll, we'll briefly talk about the challenges and technical debt and, and highlight the findings, um, that we have, uh, published recently.
- 0:44
So over the last ten to fifteen years, uh, most of the AI values that we have seen is really coming from structured data. And, and we have seen, uh, supervised learning and deep learning doing really well at labeling things.
- 0:59
And, um... But this is not the reality. Like, the... Most of the organizations, it, it's estimated that most of the organizations' data is unstructured. Specifically, more than eighty percent of the organizations' data is unstructured.
- 1:12
Uh, and it's also estimated that seventy-one percent of them really struggle in managing and, and securing this kind of data. Um, and it would have been ideal to really build automated systems, try to do certain recommendations, uh, based on this data.
- 1:29
Uh, but now it's easy to, to really use it and, and have it to conte-contextualize, uh, or customize the contextual language models. Uh, so you can easily have this as an extended memory to, to your language model, uh, and have it formulate answers based on the domain-specific data, uh, that you have within your or-organization.
- 1:52
Um, and, uh, talking about the AGI and, and, and the, the way we see, uh, uh, uh, LLMs or generative AI in general at Mastercard, it's really augmenting human productivity.
- 2:05
Uh, and, and we have seen a lot of hype around, you know, uh, generative AI is gonna replace our jobs and, and doomsday, and it's taken over. And I, I recommend you this great article from, from Nature, which is really talking about, uh, stop talking about tomorrow's AI doomsday when AI poses risks today.
- 2:23
So stop doing speculations about what AI will become tomorrow and what kind of risks, uh, that, that it will have tomorrow, and really focus about the, the current risks that it poses today.
- 2:35
And, and funny enough, some of the, the, the big speakers about the doomsday are actually ones who have AI systems out there to the end users with, with a lot of risks, as we have seen, uh, in the past.
- 2:48
Uh, and, and this, of course, will help regulators as well be more focused. Like, if we highlight the, the current risks, and so it will help them more focus to have the laws and the policies that can really help them regulate the current AI systems and at the same time be, uh, early sort of, uh...
- 3:04
or proactive enough to, to adopt any new laws whenever new algorithmic approach, uh, come up. Uh, also when it comes to the algorithmic foundation, like, you know, like, uh, you know, AI and generative AI specifically has been transforming our lives in so many ways, but the, the algorithmic foundations itself behind LLMs is not really the ones that
- 3:25
will get us to AGI. And also I, I recommend this talk from LeCun, one of the fathers of machine learning, where he talks about the objective-driven, uh, learning, um, and the whole idea that, you know, you know, despite the fact that it's transforming our life in so many ways, it's really so dumb at the core of it.
- 3:45
Uh, and it's... Because of the whole idea that it's autoregressive, and whenever it's making a mistake, this mistake really amplifies over time because the other generation of tokens is so dependent on what it's already generated.
- 3:58
And I can't help but by, by, uh... but quote, you know, bring this quote from, uh, Ada, uh, Lovelace, uh, otherwise known as the world's first computer programmer. So in, in her 1843 Analytics Engine paper, she mentions that the analytical engine or machine learning, as we call it today, cannot originate anything by itself.
- 4:19
Uh, it can only do what, what we ask it or what we order it to perform. Uh, because basically we don't have this algorithmic foundation that can really get us to something that can originate something by itself.
- 4:30
And despite being, you know, about a hundred and eighty years old, this statement still holds, uh, despite the transformations that we have in so many, uh, AI algorithms and applications.
- 4:41
And, um, funny enough, like, I've met a lot of people that thinks OpenAI is the one behind language models, and I, I do hope that you folks don't share the mi- the same misconception.
- 4:52
Uh, the whole idea of predicting the next token given a specific context is very intuitive and simple idea, uh, that it's not only a few years old, it's few decades old.
- 5:02
Uh, but was... What was really broken with this is, is the whole user interface. Um, and, and a lot of folks have really, uh, misunderstood what ChatGPT is all about.
- 5:13
So ChatGPT really fixes this whole user interface idea, that you are able to naturally, as, as we speak, be able to prompt the, the LLM in, in a natural way and, and get your response.
- 5:25
And this is what was, was really broken with the, with the language models before GPT assistants and the ChatGPT specifically. Because this kind of data is really rare and, and, you know, LLMs or, or, uh, OpenAI specifically have built their base model based on the internet scale data.
- 5:42
But then in subsequent phases before they released this GPT assistant, they had to go through, uh, outsourcing a lot of, a lot of folks to really go about generating manual pairs of responses and, uh, questions and responses.
- 5:57
Uh, and, and as I said, like, you know, LLMs despite, you know, being dumb at the core of it, it's really accelerating, uh, innovations everywhere. And, and we have seen great adoption in, in so many industries.
- 6:09
And Mastercard is no different. Uh, so we have been de-risking this technology responsibly, of course. Uh, and we have a recent press release, uh, in Feb, uh, where our president, uh, announced how we used LLMs, generative AI specifically, to boost fraud detection, in some cases by three hundred percent.
- 6:32
And to go into the, the, the last topic of my, uh, of my session is, is basically about the challenges. So let's first, you know, understand the essentials that anyone needs for building, uh, a successful GenAI application.
- 6:46
So basically, you need to have access to a variety of foundation models, and you need to have an environment to customize contextual LLMs, and you need to have an easy-to-use tool to build and deploy applications.
- 6:59
So basically, all the, you know, the, the widely used tools that we have seen before GenAI wasn't really applicable to the GenAI landscape. And finally, we need to have a scalable ML infrastructure that can really help in scaling up and down, not just creating replicas, but really creating replicas at a speed that can work for our, uh,
- 7:19
for our end users. And I've tried to color code the different essentials based on the challenges that we, we would see in, in, in building such applications. So access to a variety of foundation models is, is, is not so challenging.
- 7:33
Yes, still you need to do this kind of trade-off between cost and the model size, but it is available. And the environment to customize the, the language model itself is, is, is a bit challenging because, yes, we-- most of the enterprises have their own AI environment, but it is not really something that is built for, uh, such
- 7:51
models, such large models. And, and the easy-to-use tool, I think is the most challenging part of the whole equation, because n-none of the tools that we have seen before, and, and most of the tools that, that most of you guys use now, is really, is really as new as LLMs.
- 8:07
None of them has existed before. Uh, and finally, the need to have the scalable ML infrastructure is, is a bit of a challenge as well. Uh, and, and we have seen this nice curve from OpenAI, where this shows that the GPU compute and RAM, uh, for inference is actually getting more, uh, or greater than the, the, the
- 8:26
compute they use for training the model itself. Um, and, and before I, I, I talk about the, uh, the challenges in LLM and highlight the papers that we have recently published, uh, I just want to bring up this really nice chart from the NEPS paper, two thousand and fifteen paper.
- 8:42
And it shows that ML code, which is at the core of building any machine learning system, is only a small fraction of what goes into building the end-to-end pipeline.
- 8:52
And specifically, it's less than five percent of what goes into building the end-to-end pipeline. And this is what I call-- like, I've met a lot of folks, uh, during, you know, before my talk, and, and they think that, you know, an AI engineer is all about really, you know, connecting APIs and, and getting this kind of plumbing,
- 9:09
uh, in place. But I think it's more than that. It's, it's really everything around this ML code box. It's really building this end-to-end pipeline, which is-- accounts for more than ninety-five percent of the work.
- 9:22
Um, sorry. Uh, so before the challenges, so we'll just highlight the, the two different approaches that are widely used by, uh, in, in the industry. So the, the first one is, is really the closed book approach.
- 9:36
So you have a foundation model, you use it as it is, zero-shot or few-shot learning, or even fine-tune it with your domain-specific data. And, you know, if you ask any of the, the folks in the enterprises, they will tell you, "We really have hard time operationalizing such models because we have certain accuracy constraints."
- 9:54
So basically, the hallucination, and they do it very, you know, confidently. Uh, attribution. Um, uh, you know, we can't really understand why the models are saying what they are saying.
- 10:04
Uh, staleness. They go, they go out of date, and we have seen, uh, the different releases that, uh, that, uh, comes out of OpenAI. Revision. As, as you know, in GDPR or even in, in California AI law, uh, folks can opt out of the AI systems, and, and their information can't be used again for training or, or
- 10:23
influencing the model decisions. So you need to be able to do the model editing. And, and this is really hard in, in the foundation model or even if you fine-tune your model.
- 10:32
Um, and finally, customization. So you need to be able to customize these models with your own do-domain-specific data and have it really more grounded or more factual to generate information only based on your info-- your domain-specific data.
- 10:46
And it turned out that the, the solution to all of these problems is really to couple the foundation model to an external memory, uh, also known as the RAG.
- 10:58
Uh, so RAG, as you can see, that, you know, the, the original setup remains as it is, but we have added this additional context, which is coming from your domain-specific data.
- 11:09
Um, and it, it is grounding, so it's improved the, the, the factual recall. Uh, there is very nice paper, uh, around, uh, RAG augmentation reduces hallucination in, in conversation.
- 11:20
It, it kind of rhymes, but, like, it's very nice and shows how this kind of architectures really reduces the hallucination of the LLM systems. And you can also have it up to date.
- 11:30
So you can easily swap in, out ver-vector indices. So you can do the revision, you can do, uh, attribution, of course. Like all of the problems we have mentioned in the previous slide, you can also do as part of this, uh, RAG setup.
- 11:43
So y-you have access to the sources coming out of your retriever, so you can easily go back and understand why the model generated certain, certain text or certain, uh, decisions.
- 11:54
But i-i-it's not so easy, right? So, like, there are so many questions that need to be answered for this system really to be optimized and, and be able to work in production.
- 12:05
And this is not even half of the questions that, that we have out there. So mes- mostly, how do we optimize the retriever and generator to work together? Uh, so despite, like, the mainstream, uh, kind of RAGs that z- z- most of the people are doing right now is really having the retriever and, and the generator as
- 12:24
two separate brains that don't-- that none of them knows that each other exist. Uh, but the actual RAG paper, uh, that was released, uh, by, by FAIR is, is actually about training these two in, in parallel.
- 12:37
So you need to have access to the model parameters, and this is now thank- thanks to the people who are believing in the open source, uh, is possible. Uh, so you can have access to the model parameters, the open source model parameters.
- 12:49
So you can fine-tune the generator to generate factual information based on what it gets from the retriever. So it's not just, you know, attaching an external memory and, and, you know, two sides of the brain that, that, that are totally separated.
- 13:03
So this is our paper. Uh, so it's, it's very similar to, um, the, the NIPS one, but it, it, it really shows the unique and different challenges that, that we would see in, in building an end-to-end LLM application.
- 13:16
So you can see that, you know, the, again, the, the, the surrounding boxes around the LLM code or the adoption of foundation model is, is really, you know, accounts for more than ninety percent of what goes into building such application.
- 13:30
And it's not really just about, you know, if, if we pick one box about the domain-specific data collection, it's not just about building, uh, or generating the domain-specific data.
- 13:39
It's also how do we, how do we preserve the access controls within our enterprises into the, uh, into these ecosystems. So, like, you know, I'm sure most of the organizations that you work with have access controls.
- 13:52
Like, you can have access to certain systems but not others. So how do we make sure that we don't have a global LLM system that can really have access to all of the data that we have behind the scene?
- 14:02
So we need to maintain the same access controls, uh, and, and have certain specialized models that can work for certain tasks. And also, you know, coming back to this Nature article that we need to focus about the, the current risks that AI poses today and how we build safeguards around it.
- 14:19
And this was really the core, uh, I, I would say, you know, principle behind Mastercard to move to, to adopt LLMs. So we have the seven, the seven core principle of building responsible AI.
- 14:31
And, and it, it, you know, it's all everything around privacy. It's around security, reliability. Um, and, and, you know, we, we, we also have this governing body and clear strategy that really enforces these core principles into, into the building of such LLM applications.
- 14:48
So yes, we can go about really de-risking new technologies such as LLMs and use it for some of the services that we have. Uh, but at the same time, we need to have the right safeguards to really make sure that, you know, the access controls are in place and also we are not, you know, generating any biased
- 15:04
information. And, um, so funny enough, one of the reviewers, one of the reviewers who accepted this paper, uh, mentioned that, you know, after he, he read the paper, he was wondering, uh, if, uh, if LLM is, is the right tool to use for, for solving some of the applications given the huge number of challenges and technical debt,
- 15:24
uh, that, that, uh, that he have seen. Uh, but as the saying goes, like, you can't make an omelet without really breaking a few eggs. You can't really use this kind of transformative technology, uh, in your business without really being challenged in so many ways.
- 15:39
Uh, and that's all I have for you. And do check out some of the boxes that we have from the AI engineering team, uh, from Mastercard. It's all about putting AI in production and, and the whole other boxes around ML code or the LLM, uh, that we have seen in the figures.
- 15:55
Thank you. [outro music]