search
HomeTechnology peripheralsAIOpenAI or DIY? Uncovering the true cost of self-hosting large language models

OpenAI or DIY? Uncovering the true cost of self-hosting large language models

Your service standards have been positioned as "AI-driven" by integrating large-scale language models. Your website homepage proudly showcases the revolutionary impact of your AI-driven services through interactive demos and case studies. This is also the first mark your company has left in the global GenAI field.

Your small but loyal user base is enjoying an improved customer experience, and you can see potential for future growth. However, as the month enters its third week, you receive an email from OpenAI that surprises you: Just a week ago, you were talking to customers to assess product market fit (PMF). ), now thousands of users flock to your site (anything can go viral on social media these days) and crash your AI-driven service.

As a result, your once-reliable service not only frustrates existing users, but also affects new users.

A quick and obvious solution is to restore service immediately by increasing the usage limit.

However, this temporary solution brought with it a sense of unease. You can't help but feel like you're locked into a reliance on a single vendor, with limited control over your own AI and its associated costs.

"Should I do it myself?" you ask yourself.

You already know that open source large language models (LLMs) have become a reality. On platforms like Hugging Face, thousands of models are available for immediate use, which provides the possibility for natural language processing.

However, the most powerful LLMs you will encounter have billions of parameters, run into hundreds of gigabytes, and require significant effort to scale. In a real-time system that requires low latency, you can't simply plug them into your application as you can with traditional models.

While you may be confident in your team's ability to build the necessary infrastructure, the real concern is the cost implications of this transformation, including:

Cost of fine-tuning
  • Hosting Cost
  • Service Cost
  • So, the big question is: Should you increase usage limits, or should you go the self-hosted, otherwise known as the "own" route?

Do some calculations using Llama 2

First of all, don’t rush. This is a big decision.

If you consult your machine learning (ML) engineer, they will probably tell you that Lama 2 is an open source LLM that seems to be a good choice because it performs as well as you on most tasks The currently used GPT-3 is just as good.

You will also find that the model comes in three sizes - 7 billion, 1.3 billion and 700 million parameters - and you decide to use the largest 7 billion parameter model to maintain consistency with the OpenAI model you are currently using. Competitiveness.

LLaMA 2 uses bfloat16 for training, so each parameter consumes 2 bytes. This means the model size will be 140 GB.

If you think this model is a lot to adjust, don’t worry. With LoRA, you don't need to fine-tune the entire model before deployment.

In fact, you may only need to fine-tune about 0.1% of the total parameters, which is 70M, which consumes 0.14 GB in bfloat16 representation.

Impressive, right?

To accommodate memory overhead during fine-tuning (e.g. backpropagation, storing activations, storing datasets), the best memory space to maintain is trainable Approximately 5 times the parameter consumption.

Let's break it down in detail:

When using LoRA, the weights of the LLaMA 2 70B model are fixed, so this does not result in memory overhead → memory requirement = 140 GB.

However, in order to adjust the LoRA layer, we need to maintain 0.14 GB * (5 times) = 0.7 GB.

This results in a total memory requirement of approximately 141 GB during fine-tuning.

Assuming you don’t currently have training infrastructure, we assume you prefer to use AWS. According to AWS EC2 on-demand pricing, the compute cost is about $2.80 per hour, so the cost of fine-tuning is about $67 per day, which is not a huge expense because the fine-tuning does not last for many days.

Artificial intelligence is the opposite of a restaurant: the main cost is in service rather than preparation

When deploying, you need to maintain two weights in memory:

Model weights, consuming 140 GB of memory.
  • LoRA fine-tunes weights and consumes 0.14 GB of memory.
  • The total is 140.14 GB.

Of course, you can cancel gradient calculations, but it is still recommended to maintain about 1.5x the memory — about 210 GB — to account for any unexpected overhead.

Again based on AWS EC2 on-demand pricing, GPU compute costs approximately $3.70 per hour, which works out to approximately $90 per day to keep the model in production memory and respond to incoming requests.

This equates to about $2,700 per month.

Another thing to consider is that unexpected failures happen all the time. If you don't have a backup mechanism, your users will stop receiving model predictions. If you want to prevent this from happening, you need to maintain another redundant model in case the first model request fails.

So this would bring your cost to $180 per day or $5,400 per month. You're almost close to the current cost of using OpenAI.

At what point do the costs of OpenAI and open source models tie up?

If you continue to use OpenAI, here is the number of words you can process per day to match the above fine-tuning and serving of LLaMA 2 cost.

According to OpenAI’s pricing, fine-tuning GPT 3.5 Turbo costs $0.0080 per 1,000 tokens.

Assuming most words have two tokens, to match the fine-tuning cost of the open source LLaMA 2 70B model ($67 per day), you would need to feed the OpenAI model approximately 4.15 million words.

Typically, the average word count on an A4 paper is 300, which means we can feed the model about 14,000 pages of data to match the open source fine-tuning cost, which is a huge number.

You may not have that much fine-tuning data, so the cost of fine-tuning with OpenAI is always lower.

Another point that may be obvious is that this fine-tuning cost is not related to the training time, but to the amount of data for model fine-tuning. This is not the case when fine-tuning open source models, as the cost will depend on the amount of data and the time you use AWS compute resources.

As for the cost of the service, according to OpenAI’s pricing page, a fine-tuned GPT 3.5 Turbo costs $0.003 per 1,000 tokens for input and $0.006 for output per 1,000 tokens.

We assume an average of $0.004 per 1000 tokens. To reach the cost of $180 per day, we need to process approximately 22.2 million words per day through the API.

This equates to over 74,000 pages of data, with 300 words per page.

However, the benefit is that you don’t need to ensure the model is running 24/7 as OpenAI offers pay-per-use pricing.

If your model is never used, you pay nothing.

Summary: When does ownership really make sense?

At first, moving to self-hosted AI may seem like a tempting endeavor. But beware of the hidden costs and headaches that come with it.

Aside from the occasional sleepless night where you wonder why your AI-driven service is down, almost all of the difficulties of managing LLMs in production systems disappear if you use a third-party provider.

Especially when your service doesn't primarily rely on "AI", but other things that rely on AI.

For large enterprises, the annual cost of ownership of $65,000 may be a drop in the bucket, but for most enterprises, it is a number that cannot be ignored.

Additionally, we should not forget about other additional expenses such as talent and maintenance, which can easily increase the total cost to over $200,000 to $250,000 per year.

Of course, having a model from the beginning has its benefits, such as maintaining control over your data and usage.

But to make self-hosting feasible, you will need user request volume well beyond the norm of about 22.2 million words per day, and you will need the resources to manage both the talent and logistics.

For most use cases, it may not be financially worthwhile to have a model instead of using an API.

The above is the detailed content of OpenAI or DIY? Uncovering the true cost of self-hosting large language models. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete
Can't use ChatGPT! Explaining the causes and solutions that can be tested immediately [Latest 2025]Can't use ChatGPT! Explaining the causes and solutions that can be tested immediately [Latest 2025]May 14, 2025 am 05:04 AM

ChatGPT is not accessible? This article provides a variety of practical solutions! Many users may encounter problems such as inaccessibility or slow response when using ChatGPT on a daily basis. This article will guide you to solve these problems step by step based on different situations. Causes of ChatGPT's inaccessibility and preliminary troubleshooting First, we need to determine whether the problem lies in the OpenAI server side, or the user's own network or device problems. Please follow the steps below to troubleshoot: Step 1: Check the official status of OpenAI Visit the OpenAI Status page (status.openai.com) to see if the ChatGPT service is running normally. If a red or yellow alarm is displayed, it means Open

Calculating The Risk Of ASI Starts With Human MindsCalculating The Risk Of ASI Starts With Human MindsMay 14, 2025 am 05:02 AM

On 10 May 2025, MIT physicist Max Tegmark told The Guardian that AI labs should emulate Oppenheimer’s Trinity-test calculus before releasing Artificial Super-Intelligence. “My assessment is that the 'Compton constant', the probability that a race to

An easy-to-understand explanation of how to write and compose lyrics and recommended tools in ChatGPTAn easy-to-understand explanation of how to write and compose lyrics and recommended tools in ChatGPTMay 14, 2025 am 05:01 AM

AI music creation technology is changing with each passing day. This article will use AI models such as ChatGPT as an example to explain in detail how to use AI to assist music creation, and explain it with actual cases. We will introduce how to create music through SunoAI, AI jukebox on Hugging Face, and Python's Music21 library. Through these technologies, everyone can easily create original music. However, it should be noted that the copyright issue of AI-generated content cannot be ignored, and you must be cautious when using it. Let’s explore the infinite possibilities of AI in the music field together! OpenAI's latest AI agent "OpenAI Deep Research" introduces: [ChatGPT]Ope

What is ChatGPT-4? A thorough explanation of what you can do, the pricing, and the differences from GPT-3.5!What is ChatGPT-4? A thorough explanation of what you can do, the pricing, and the differences from GPT-3.5!May 14, 2025 am 05:00 AM

The emergence of ChatGPT-4 has greatly expanded the possibility of AI applications. Compared with GPT-3.5, ChatGPT-4 has significantly improved. It has powerful context comprehension capabilities and can also recognize and generate images. It is a universal AI assistant. It has shown great potential in many fields such as improving business efficiency and assisting creation. However, at the same time, we must also pay attention to the precautions in its use. This article will explain the characteristics of ChatGPT-4 in detail and introduce effective usage methods for different scenarios. The article contains skills to make full use of the latest AI technologies, please refer to it. OpenAI's latest AI agent, please click the link below for details of "OpenAI Deep Research"

Explaining how to use the ChatGPT app! Japanese support and voice conversation functionExplaining how to use the ChatGPT app! Japanese support and voice conversation functionMay 14, 2025 am 04:59 AM

ChatGPT App: Unleash your creativity with the AI ​​assistant! Beginner's Guide The ChatGPT app is an innovative AI assistant that handles a wide range of tasks, including writing, translation, and question answering. It is a tool with endless possibilities that is useful for creative activities and information gathering. In this article, we will explain in an easy-to-understand way for beginners, from how to install the ChatGPT smartphone app, to the features unique to apps such as voice input functions and plugins, as well as the points to keep in mind when using the app. We'll also be taking a closer look at plugin restrictions and device-to-device configuration synchronization

How do I use the Chinese version of ChatGPT? Explanation of registration procedures and feesHow do I use the Chinese version of ChatGPT? Explanation of registration procedures and feesMay 14, 2025 am 04:56 AM

ChatGPT Chinese version: Unlock new experience of Chinese AI dialogue ChatGPT is popular all over the world, did you know it also offers a Chinese version? This powerful AI tool not only supports daily conversations, but also handles professional content and is compatible with Simplified and Traditional Chinese. Whether it is a user in China or a friend who is learning Chinese, you can benefit from it. This article will introduce in detail how to use ChatGPT Chinese version, including account settings, Chinese prompt word input, filter use, and selection of different packages, and analyze potential risks and response strategies. In addition, we will also compare ChatGPT Chinese version with other Chinese AI tools to help you better understand its advantages and application scenarios. OpenAI's latest AI intelligence

5 AI Agent Myths You Need To Stop Believing Now5 AI Agent Myths You Need To Stop Believing NowMay 14, 2025 am 04:54 AM

These can be thought of as the next leap forward in the field of generative AI, which gave us ChatGPT and other large-language-model chatbots. Rather than simply answering questions or generating information, they can take action on our behalf, inter

An easy-to-understand explanation of the illegality of creating and managing multiple accounts using ChatGPTAn easy-to-understand explanation of the illegality of creating and managing multiple accounts using ChatGPTMay 14, 2025 am 04:50 AM

Efficient multiple account management techniques using ChatGPT | A thorough explanation of how to use business and private life! ChatGPT is used in a variety of situations, but some people may be worried about managing multiple accounts. This article will explain in detail how to create multiple accounts for ChatGPT, what to do when using it, and how to operate it safely and efficiently. We also cover important points such as the difference in business and private use, and complying with OpenAI's terms of use, and provide a guide to help you safely utilize multiple accounts. OpenAI

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor