<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Faisal Masood on Medium]]></title>
        <description><![CDATA[Stories by Faisal Masood on Medium]]></description>
        <link>https://medium.com/@masood.faisal?source=rss-cd9dca17cb81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3IMRgko-RZOEBsHUirw24A.png</url>
            <title>Stories by Faisal Masood on Medium</title>
            <link>https://medium.com/@masood.faisal?source=rss-cd9dca17cb81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 12:32:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@masood.faisal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building GenAI solutions on Amazon EKS]]></title>
            <link>https://medium.com/@masood.faisal/building-genai-solutions-on-amazon-eks-f7e52ad1edcc?source=rss-cd9dca17cb81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7e52ad1edcc</guid>
            <category><![CDATA[agentic-applications]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Faisal Masood]]></dc:creator>
            <pubDate>Wed, 14 May 2025 22:37:18 GMT</pubDate>
            <atom:updated>2025-05-14T22:37:18.167Z</atom:updated>
            <content:encoded><![CDATA[<p>Large language models (LLMs) are everywhere and have become integral part of our daily lives. Software developers use them to write code more efficiently, and business users employ LLMs to improve their productivity, such as by automating the data analysis and creation of reports. Then there are domain specific models for certain fields — for example, in healthcare, LLMs can help medical professionals write patient reports and analyze test results with greater efficiency. The array of fit-for-purpose models resulting on organizations adopting multiple model strategy instead of focusing on just one model.</p><p>AWS provides multiple ways to use market leading LLMs such as Claude and DeepSeek through it managed services. However, organizations may adopt self-hosting approach because it provides more control of the stack and enforcing policies (specifically data regulations) with ease. Self-hosting also enables your developers to easily access multiple models and switch them as needed. Adopting self-hosting may result in the following benefits for your organizations.</p><p><strong>Confidentiality and Security:</strong> Self-hosting enables you to have more control of all your sensitive data and hybrid deployment, and a consistent inferencing layer across multi-cloud or hybrid cloud. You can integrate existing sensitive data sources such as internal documents, policies, and data sources directly into the AI model resulting in improved quality and productivity for your teams. You can establish additional safeguards to protect sensitive information to achieve more advanced security.</p><p>Self-hosting allows you to be <strong>flexible</strong> in terms of hardware and software stack resulting in more choices and cost control.</p><p><strong>Model Customization:</strong> Self-hosting allows you to tune the LLMs to your specific needs. You can fine-tune smaller models with sensitive and domain specific data to achieve competitive performance with much larger models while being more cost efficient and better alignment with your organization’s specific requirements.</p><p><strong>Latency:</strong> With your model hosted on the same platform as your application, remote calls will have better latency due to reduced hops as compared to fully managed models. This is particularly helpful when your application has strict SLA requirements for latency and can help to provide better end user experience.</p><p>However, deploying generative AI applications in production requires more than just hosting LLMs itself. There are several complementary components that organizations will need to deploy alongside the LLM to create a robust, production-ready system. For example, prompt caching is crucial for improving performance by reducing the latency of repeated queries. Guardrails are also essential to ensure the models are used safely, such as by implementing input validation and content filtering. Observability tools are key for debugging issues and monitoring model performance. And perhaps most importantly, model evaluation capabilities are needed to continuously assess the models’ effectiveness in delivering value for the specific use case. Without these additional supporting components, organizations may find it hard to successfully deploy LLMs in a production environment and maintain their business impact over time.</p><p>A successful self hosting stack needs multiple components, as you seen above, and Open Source Software (OSS) provides the required components to build your stack. In this blog, we present a framework that consists of open-source components to self-host LLMs in production, as well as building all the key components mentioned above to create a comprehensive solution. We present a curated set of open source components paired with <a href="https://aws.amazon.com/eks/">Amazon EKS</a> to provide elastic and cost optimized infrastructure. The framework allows you to run a variety of models as required by your teams while simplifying the hosting complexity to a minimum.</p><p>This framework makes it easier to run many different models in production in a cost-efficient manner and builds the foundation for your self-hosted models and agentic workflow. You may choose to adapt it fully or pick the components that is suitable for your use cases.</p><p>The framework consists of the following four main components. It is important to remind that all of these components are running as containers where Amazon EKS provides the core for scale, choice of hardware (compute, GPU and disk), elasticity and cost efficiency:</p><p><strong>1- Model Gateway Service:</strong> A model gateway is the central place to access all your models in a consistent manner across your organization. Teams can use the gateway to find the available models which increases the agility to consume and integrate LLMs across many applications. A model gateway provides access management, prompt caching and integration with observability components. The gateway service also allows to provide secure access to your model.</p><p>An interesting capability that model gateway could provide is a hybrid inferencing capability. The model gateway routes the traffic to different back-ends (such as self-hosted and managed model services such as <a href="https://aws.amazon.com/bedrock/">BedRock</a>) based on certain scenarios. For example, a use-case would be that you have stable workload during the peak hours and occasional request during off-peak hours. For this scenario a gateway can route requests to self-hosted LLMs during peak hours and to managed services during off-peak for cost efficient inferencing.</p><p><strong>2- Model Hosting Services:</strong> Model hosting services allows you to take the model weights and expose them as consumable APIs. The right runtime not only provides efficient inferencing, it also allows seamless integration with the monitoring stack to capture and take action on model performance. One of the most useful feature for runtime optimization is <a href="https://huggingface.co/docs/optimum/en/concept_guides/quantization">quantization</a> (which represent the weights of neural networks using lower precision data types) resulting in less intensive requirement for the hardware such as GPU memory. Consider selecting a runtime that offer quantization capability to optimize the usage of your hardware and reduce cost. Finally is the runtime capability to serve smaller models on CPU. Recently smaller models such as <a href="https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct">LLaMa 3.2 3B</a> demonstrates the possibility of CPU based inferencing resulting in reduced cost.</p><p>When deploying LLMs, you may require multiple run-times such as <a href="https://docs.vllm.ai/en/latest/">vLLM</a> or <a href="https://github.com/ggml-org/llama.cpp">LLaMa.cpp</a> to host different models. A container-based hosting service allows you to deploy multiple run-times with ease while providing the elasticity (scale up and down) to consume the right hardware in a cost optimal manner. A model hosting service also captures the primitive observability metrics such as CPU, memory and request latency for better management.</p><p><strong>3- Model Evaluation Services:</strong> Choosing the right LLM for a specific use case can be challenging because models can vary significantly in capabilities, biases, and behaviors, even for seemingly similar tasks. Evaluation services allow you to rigorously test and compare candidate models not only on generic benchmarks but also against your specific business requirements and real- world data.</p><p>Model evaluation service allows you to evaluate request offline and in real-time using predefined and/or custom function tailored to your use case. The service will also associate the evaluation metrics with the captured data so you can visualize and assess the suitability of the solution.</p><p>However, evaluation is not just for responses. Language models and their associated prompts are the “soul” of any generative AI application. Evaluation services also enable you to continuously optimize these prompts by identifying areas for improvement and iterating to maximize performance. Some services even offer automated prompt engineering capabilities, further streamlining the process Evaluation services become a crucial feedback loop, ensuring your generative AI systems remain optimized and effective throughout their entire lifecycle.</p><p><strong>4- Model Observability Services:</strong> While standard metrics such as CPU and memory are expected to be available as part of platform. The observability service in the framework provides a way to capture request and response payloads and LLM specific metrics such as Time to first token (TTFT) and overall latency. These metrics help you assess the feasibility of the model for your changing business needs.</p><p>The observability data and insights gathered can be reused in various ways. For instance, you might use them to fine-tune your selected LLM on relevant data or to inform the development of new, more specialized models. The evaluation service will also utilize the data captured bu th observability service to run evaluation functions.</p><p>The observability data captured may include sensitive data and an observability service enable you define where this data has persisted. You can capture the logs within the cluster, or you can choose to store the logs on a managed service such as S3 based on your data security and encryption requirements.</p><p>You have seen the major components of the framework. However, the framework is not limited to these four components. An additional optional component could be running your agentic workflow manager. However, we think as more and more application adapts LLMs, more patterns will result in additional components. And we expect you to enhance the components as suitable for your use case.</p><p>The framework components are captured in the diagram below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J7Ci1wYupqPOrZrc6fKlIA.png" /><figcaption>A framework for self hosting Agentic Applications on Amazon EKS</figcaption></figure><p>Now, let see how we can leverage popular open-source frameworks/services to fulfill the role of the key components discussed above. Please note that, you can also choose to use other open-source solutions that provide similar capabilities to replace the ones mentioned in this blog. As mentioned before, this solution has designed to provide the flexibility for you to choose to adopt certain modules as per your requirements. The aim is not to recommend a particular software component but to provide a prescriptive guidance and a set of considerations to help make an informed choice.</p><p>Let’s dive into details of these components.</p><p><strong>Model Gateway with LiteLLM :</strong> Different team in your organization may need different models, or your application may evolve to change the models as time progresses. Baking your model choice into your code can result in heavy technical debt with increased maintenance and time to upgrade your production applications.</p><p><a href="https://litellm.ai/">LiteLLM</a> makes it easy for developers access LLMs using OpenAI API compatible API and secure access. LiteLLM provides team-based access keys management capabilities to ease management of security keys for model access. It also allows integration with databases to provide caching for your LLM invocations. Additionally, LiteLLM provides capabilities to improve reliability of your production applications, such as rate limiting and timeout, which helps to reduce complexity in the downstream services.</p><p><strong>Model Hosting with vLLM:</strong> <a href="https://docs.vllm.ai/en/latest/">vLLM</a> provides an OpenAI API-compatible server with modern capabilities for efficient inferencing. It offers in-flight batching (aimed at reducing idle time) and paged attention (which eliminates the need for continuous memory allocation by partitioning the KV cache into blocks), among many other benefits. The advantages of using containers are that you can easily switch the runtime to another framework, such as llama.cpp, or use a mix of runtimes based on your needs. In the next part of this blog series, we will use multiple runtimes such as llama.cpp and vLLM, in the same cluster to demonstrate the flexibility and efficiency of the container-based solution.</p><p><strong>Observability with LangFuse:</strong> <a href="https://langfuse.com/">LangFuse</a> is one of the widely used frameworks that offers a comprehensive set of capabilities that fulfils the production requirements for observability. Running models in production, this service track data such as the user input queries, input variables, generated responses, number of input/output tokens, latencies and additional run- time metadata. More importantly, it is integrated with LiteLLM which serves as the LLM gateway; therefore you can easily capture the runtime invocation data to Langfuse automatically.</p><p>Evaluation with LangFuse: Assessing LLMs require two things. First is that it completes the assigned task such as summarization, question/answer, or sentiment analysis. Second is the model is fair and robust including good performance on unseen inputs aka generalization, and does not carry inherent bias and resistance to adversarial inputs. So, each task we evaluate requires a benchmark tailored for that specific task.</p><p>It is quite difficult and time consuming to make sure that the model generated output is satisfactory. You can either ask a human to perform validation which is time consuming and expensive. Otherwise, you can use an automated valuation method such as leveraging another LLM to automate the evaluation process (commonly known as LLM-as-a-judge).</p><p>LangFuse not only captures all the traces but also allows you to add scores or metrics to be associated with each call via its APIs and a custom function. This enables you to execute your custom evaluation function for the LLM invocations and save the associated score with the trace during real-time or in an off-line evaluation scenario. Associating a score with production data gives us the capability to measure the effectiveness and take actions timelier, especially during a/b testing with a new LLM family or a fine-tuned model.</p><p>In the context of this framework, our focus is to continuously evaluate models in production to assess their effectiveness and how closely they are delivering business value against your chosen evaluation criteria. Evaluation during model training or fine tuning is a different subject which is not our focus in the current context.</p><p>You have seen how Amazon EKS and open-source frameworks and models enable you for a production grade deployment for your Agentic workloads. A working code is always the best enabler and in the second part of this blog series, I will present a blueprint to host this complete stack on Amazon EKS with infrastructure as code. Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7e52ad1edcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>