Generative AI: How Self-Hosting Can Help Your Bussiness
Tags: informative, largelanguagemodels, generativeai, business
Published: 2023-11-05 13:08:10

---
title: Generative AI: How Self-Hosting Can Help Your Bussiness
published: true
date: 2023-10-31 17:19:16 UTC
tags: Informative,largelanguagemodels,generativeai,business
canonical_url: https://codesphere.com/articles/generative-ai-self-hosting-can-help-bussiness
---

 ![Generative AI: How Self-Hosting Can Help Your Bussiness](https://codesphere.ghost.io/content/images/2023/10/GenerativeAI.webp)

There is a lot of uproar about AI and its implications around the world. We do not believe that AI will be sentient anytime soon. Some of the hype around AI is just that, hype. However, companies need to understand the true effect of AI to stay ahead in the competitive market. Organizations should try to explore the possible use cases of generative and the way it can help their businesses.

We are going to discuss what artificial intelligence is and how generative AI has developed to its current state. We will also talk about the ways businesses can integrate self-hosted LLMs in their workflows and how [Codesphere](https://codesphere.com/?ref=codesphere.ghost.io) can help. So, let’s dive right in.  

## What is AI?

Artificial Intelligence is a field of computer science, that has gained insane popularity in the last two decades. AI tries to build a machine capable of making human-like intelligent decisions. AI systems are designed to analyze, reason, learn, and adapt. It allows them to perform tasks, such as problem-solving, language understanding, and decision-making. 

An AI model is basically a program that can be trained on data and make predictions or decisions based on it. The field of AI encompasses an array of technologies including machine learning, deep learning, natural language processing, and robotics. AI's potential is vast, and it continues to shape the future of technology. AI offers solutions to complex problems and unlocks new horizons in automation and decision support.

## What is Generative AI?

Generative AI is a sub-field of artificial intelligence where algorithms are used to generate plausible patterns for things like language or images. The general narrative about generative AI is that it makes machines able to come up with original ideas, like writing stories or making art. For example, it can write stories or generate images without being given specific examples. However, in reality, these machines are basically extremely efficient at recognizing patterns from the data they are trained on and recreating similar patterns. Generative AI is often used for things like making chatbots, translating languages, and creating content. 

## History of Generative AI

Much like every other field, generative AI has also had gradual and at times abrupt advances. If we try to trace back the history, we can see that it has been around since 1913, when the Markovian chain algorithm was developed. It was a statistical tool to generate new data. Here the input defined how the next sequence of data would look like.

However, the more useful generative AI era began after 2012. It was then we finally had powerful enough computers to train deep-learning models. These models were trained on large data sets. Deep learning models considerably improved many organizational tasks like language translation, image-to-text, and art generation. 

In 2014, a game-changing algorithm by Ian Goodfellow was released. The development of the Generative Adversarial Networks enabled the deep learning models to self-evaluate using game theory. It’s said that Generative Adversarial Networks (GANs) gave computers the ability to be creative while generating content. 

## Innovations in Generative AI

Shortly after the GANs, another technique called transformer networks came. This technique was based on the idea of attention. It gave an “attention score” to different parts of speech. It immensely improved AI models in understanding and generating content. This technique combined with the power of deep learning, gave birth to Large Language Models that we see today. 

## What are LLMs?

Large Language Models (LLMs) are complex deep learning models that are trained on huge datasets. They have ability to understand and use human language in a really advanced way. They can effectively perform tasks like text generation, language translation, chatbot development, and content summarization. These models are highly adaptable and efficient, which is why they are important in the development of advanced AI-driven solutions for various industries.

## Large Language Model Revolution

Previously there were a lot of smaller language models that were specific to different industries. These models needed months of work by AI experts. They were also extremely resource-intensive and time-consuming as they also took a lot of time to train. Moreover, the data required to train these models needed to be gathered, labeled, and prepared. 

So the innovation of large language models made this technology general and easier to use. LLMs didn’t serve a specific field, so they could be used for several use cases. They didn’t require you to gather labeled datasets and specialized engineering capabilities. This made them reliable and robust to be used anywhere. 

However, LLMs needed extremely high computing power to train and were expensive. This meant the big tech had a monopoly and the only option to use them was through the provided APIs. Many organizations could not use them because of several issues like lack of control over models, data protection, and data sovereignty. 

![Generative AI: How Self-Hosting Can Help Your Bussiness](https://codesphere.ghost.io/content/images/2023/10/LLMs.webp)
_Small language models vs Large language models_

Things took a turn after Meta released LLAMA-2. It made top-notch LLM models available to everyone that could be used by anyone without compromising data integrity. The open-source community has been since rolling out many updated versions on a daily basis. Now, you can find a ready-to-use, fine-tuned version for almost any niche or use case. 

**Suggested Reading: [7 Open Source LLMs you need to know about](https://codesphere.com/articles/7-open-source-llm-text-generators?ref=codesphere.ghost.io)**

## How Can You Use LLMs?

Now you may ask how to use LLMS on an organizational or business level. Let’s talk about different ways to do that.  

### Prompt Engineering

One way to work with LLMs is prompt engineering. It involves asking LLM the right questions. You can test different models rapidly using prompt engineering. So, It is a fast and efficient way to get the results you want.

 Nonetheless, there are drawbacks to consider. It sends out data to OpenAI, which is not suitable for sensitive data. The other downside is that the prompt you can send out cannot be more than 2048 words, which is very limiting. 

### RAG (Retrieval-Augmented-Generation)

Retrieval Augmented Generation known as RAG is basically an AI framework. It tries to improve the quality and accuracy of responses generated by LLMs. This framework allows you to integrate an external database, which your LLM can fetch information from. 

How it works is, that when a query is made, RAG first searches the database to find relevant information. The retrieved information is then used to craft a coherent response to the query. This makes these models factually accurate and relatively fast to implement. 

Although, you will still need to deploy your own LLM if you don’t want to share your data with OpenAI. Also, whether you use self-hosted LLMs or API-based you would require ML OPs or DevOps engineers. 

### Fine-tunning

This approach involves improving or customizing an existing LLM model with your own unique data. Multiple experiments have shown that smaller LLMs trained with specific data perform as well as or better than larger LLMs.

The benefit of this approach is that you get complete data autonomy. It also allows you to have complete control over your LLM model as it won’t get impacted by any updates of terms from an API provider. Moreover, on a large scale, this could be the cheapest possible solution for you. The downside to this approach is that you need your own data center and DevOps experts to implement these models.

## Comparison of API-Based vs Self-Hosted LLMs

If you look at the benefits and drawbacks of [API-based vs self-hosted LLMs](https://codesphere.com/articles/self-hosted-vs-api-based-llms?ref=codesphere.ghost.io), these are the points that will stand out.

### API-Based LLMs Highlights

- You can start using them immediately and get a good performance from the get-go.
- The initial pricing for these models is low and you don’t need ML Ops engineers to set up.
- With managed LLMs you can only work only with very limited data, typically limited to a few thousand words only, even if data is injected via RAG and your company does not own the IP.
- You have to send your sensitive data over the internet to large (maybe foreign) companies.
- You do not have control over the model and can be affected by the changing policies or terms of the service provider.

### Self-Hosted LLMs Highlights

- These models are customizable and fast.
- You do not risk any data leaving the country where your data centers are located.
- You can work with unlimited amounts of data via fine-tuning.
- Self-hosted LLMs typically require expensive hardware, typically a few A100 GPUs that cost ~15k per month.
- These models also need constant infrastructure maintenance that can cost you around 20% of your project cost. 
- You need expensive DevOps Engineers for the setup, hosting, versioning, and application layer around the model. In addition to that to evaluate, fine-tune and improve the model you require ML Ops engineers.
- After all these financial and workforce resources it can take up to 6 months until the infrastructure project is set up.

## How Codesphere Helps Businesses Self-Host LLMs?

So, the two major issues when it comes to self-hosted LLMs are cost and complexity. Here is how Codesphere can help you navigate through these challenges.

### Cost

Servers where you run LLMs usually have a fixed size regarding computing and memory. Running inference (serving requests/sending queries and getting an output) for AI models takes high computing resources per request. This is quite higher than what a normal website takes. 

In LLMs, a single request from a user takes multiple seconds and (almost) fully occupies one server. If we want to serve multiple requests in parallel we need multiple servers or server cores (which refer to the number of virtual CPUs in a server). 

The traffic and the number of requests your model gets fluctuate and are hard to predict accurately. What happens usually is that organizations estimate the peak traffic and pay for them to accommodate the peak hours. This for obvious reasons increases the cost. 

Codesphere offers “off when un-used” server plans, which automatically turn off when you are not getting user requests. These servers have super fast cold starts and they can be up and running in (10-20ms in the future) 1-5 seconds currently. For example, if you have a chatbot for internal use in your organization, it will only cost you computing resources during office hours. 

Our educated estimate suggests it is over 90% cheaper to run low-traffic models. Moreover, scaling your models can be 35% cheaper because you do not have to reserve the maximum computing capacity to accommodate peak traffic hours.

<!--kg-card-begin: html--><style>
@import "https://rsms.me/inter/inter.css";

:root {
  font-family: 'Inter', sans-serif;
}

@supports (font-variation-settings: normal) {
  :root {
    font-family: 'Inter var', sans-serif;
  }
}

.info__container{display:flex;padding:40px;align-items:center;justify-content:center;position:relative;overflow:hidden;border-radius:19px;border:2px solid rgba(129,75,246,.4);background:linear-gradient(0deg,rgba(43,27,78,.4) 0%,rgba(43,27,78,.6) 100%),#080809}.content__wrap{display:flex;align-items:center;max-width:900px;flex-direction:row;gap:16px;justify-content:space-between}.blur-effect{width:728px;height:311px;position:absolute;left:-25px;bottom:-71px;fill:linear-gradient(140deg,rgba(175,44,187,.45) 0%,rgba(0,26,255,.45) 100%);opacity:.4000000059604645;filter:blur(52px)}.left __container{display:flex;position:relative;z-index:999;flex-basis:37%;flex-direction:column;justify-content:center;align-items:flex-start;gap:24px;align-self:stretch}.text__ container{display:flex;flex-direction:column;align-items:flex-start;gap:16px;align-self:stretch}.text __heading{display:flex;flex-direction:column;align-self:stretch;margin:0;color:#FFF;font-family:Inter;font-size:32px;font-style:normal;font-weight:700;line-height:96.023%}.text__ desc{display:flex;flex-direction:column;align-self:stretch;margin:0;color:#CCC;font-family:Inter;font-size:16px;font-style:normal;font-weight:400;line-height:normal}.btn{display:flex;padding:10px 40px;justify-content:center;align-items:center;gap:10px;border-radius:3px;background:#814BF6;color:#FFF!important;font-family:Inter;font-size:16px;font-style:normal;line-height:normal;text-decoration:none!important}.btn:hover{background-color:rgba(129,75,246,.75)}.right __container{display:flex;position:relative;z-index:999;flex-basis:63%;flex-direction:column;justify-content:flex-end;align-items:flex-start;gap:32px;align-self:stretch}.usp__ container{display:flex;align-items:center;justify-content:start;gap:26px;align-self:stretch}.usp __icon{display:flex;padding:8px;justify-content:center;align-items:center;border-radius:5px;border:1px solid #814BF6}.usp__ text span{color:#FFF;font-family:Inter;font-size:16px;font-style:normal;font-weight:700;line-height:normal}.usp __text p{color:#CCC;font-family:Inter;font-size:16px;font-style:normal;margin:0}.usp__ svg{width:24px}.text__container p{padding:0 0 0 0!important;margin:0 0 0 0!important}@media screen and (max-width:600px){.content__wrap{flex-direction:column;gap:40px}}@media screen and (min-width:950px){.left__container{flex-basis:33%}}
</style>
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 693 218" fill="none">
    <path d="M-1.45455 174.421L-19.2727 12.2249L-25 -22L15.7273 -18.0319H131.545L211.727 6.27273L243.545 53.3939L368.273 62.8182L522.273 68.2743L703 150.612L624.727 289L216.818 140.196L-1.45455 174.421Z" fill="url(#paint0_linear_38_57)" fill-opacity="0.45"></path>
  <defs>
    <filter id="filter0_f_38_57" x="-129" y="-126" width="936" height="519" filterunits="userSpaceOnUse" color-interpolation-filters="sRGB">
      <feflood flood-opacity="0" result="BackgroundImageFix"></feflood>
      <feblend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feblend>
      <fegaussianblur stddeviation="52" result="effect1_foregroundBlur_38_57"></fegaussianblur>
    </filter>
    <lineargradient id="paint0_linear_38_57" x1="103.545" y1="-9.59964" x2="469.427" y2="296.954" gradientunits="userSpaceOnUse">
      <stop stop-color="#AF2CBB"></stop>
      <stop offset="1" stop-color="#001AFF"></stop>
    </lineargradient>
  </defs>
</svg>

Zero config cloud made for developers

From GitHub to deployment in under 5 seconds.

[Sign Up!](https://signup.codesphere.com/?utm_source=blogSnippet&utm_campaign=blog)

<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 15 16" fill="none">
    <path d="M4.03783 10.516C3.92061 10.3988 3.88276 10.2361 3.93283 10.0851C4.01973 9.8273 4.13563 9.49121 4.2747 9.10588L4.51642 8.43614H3.8044H0.704948C0.631302 8.43614 0.562855 8.3965 0.526438 8.33298C0.490608 8.27049 0.491168 8.19366 0.5283 8.13122L0.528559 8.13078L2.06649 5.53833C2.06652 5.53829 2.06654 5.53825 2.06656 5.53821C2.35762 5.048 2.88288 4.749 3.44992 4.749H5.86093H6.14402L6.28967 4.50625C6.354 4.39905 6.41919 4.29839 6.4868 4.19694C8.72808 0.89276 12.0526 0.771759 14.0874 1.14629L14.0888 1.14655C14.22 1.17031 14.3272 1.27405 14.3543 1.41447C14.7286 3.45236 14.604 6.77378 11.3016 9.01454L11.2995 9.01592C11.2076 9.07896 11.1053 9.14372 10.994 9.21046L10.7513 9.35611V9.63921V12.0502C10.7513 12.6183 10.4514 13.1452 9.96338 13.4327L9.96205 13.4335L7.36941 14.9714L7.36898 14.9717C7.30652 15.0088 7.22968 15.0094 7.16718 14.9736C7.10265 14.9366 7.06402 14.8705 7.06402 14.7951V11.6547V10.9516L6.39989 11.1824C5.99229 11.324 5.63625 11.4398 5.36493 11.5274C5.23272 11.5698 5.0836 11.5417 4.96858 11.4468L4.94306 11.4212L4.03783 10.516ZM11.2513 5.92078C11.6947 5.92078 12.1199 5.74465 12.4334 5.43113C12.7469 5.11761 12.9231 4.69239 12.9231 4.249C12.9231 3.80561 12.7469 3.38038 12.4334 3.06686C12.1199 2.75334 11.6947 2.57721 11.2513 2.57721C10.8079 2.57721 10.3827 2.75334 10.0691 3.06686C9.7556 3.38038 9.57946 3.80561 9.57946 4.249C9.57946 4.69239 9.7556 5.11761 10.0691 5.43113C10.3827 5.74465 10.8079 5.92078 11.2513 5.92078Z" stroke="white"></path>
    <path d="M4.28516 8.6008C4.61996 7.77497 5.43688 5.8153 6.02614 4.58325M11.0482 9.40431L6.89663 11.2122" stroke="white"></path>
    <path d="M3.91176 13.2941C3.91176 14.2363 3.14802 15 2.20589 15H2.20224H2.19857H2.19487H2.19116H2.18742H2.18366H2.17988H2.17608H2.17226H2.16841H2.16455H2.16066H2.15676H2.15283H2.14889H2.14492H2.14093H2.13692H2.13289H2.12885H2.12478H2.12069H2.11659H2.11246H2.10831H2.10415H2.09997H2.09576H2.09154H2.0873H2.08304H2.07876H2.07447H2.07015H2.06582H2.06147H2.0571H2.05272H2.04831H2.04389H2.03945H2.035H2.03052H2.02603H2.02152H2.017H2.01246H2.0079H2.00332H1.99873H1.99412H1.9895H1.98486H1.9802H1.97553H1.97084H1.96614H1.96142H1.95669H1.95194H1.94717H1.94239H1.93759H1.93278H1.92796H1.92312H1.91827H1.9134H1.90851H1.90362H1.89871H1.89378H1.88884H1.88389H1.87892H1.87394H1.86895H1.86394H1.85892H1.85389H1.84885H1.84379H1.83872H1.83363H1.82854H1.82343H1.81831H1.81317H1.80803H1.80287H1.7977H1.79252H1.78733H1.78213H1.77691H1.77168H1.76645H1.7612H1.75594H1.75067H1.74539H1.7401H1.7348H1.72948H1.72416H1.71883H1.71349H1.70814H1.70277H1.6974H1.69202H1.68663H1.68123H1.67582H1.6704H1.66498H1.65954H1.6541H1.64864H1.64318H1.63771H1.63223H1.62675H1.62125H1.61575H1.61024H1.60472H1.5992H1.59366H1.58812H1.58258H1.57702H1.57146H1.56589H1.56031H1.55473H1.54914H1.54355H1.53795H1.53234H1.52673H1.52111H1.51548H1.50985H1.50421H1.49857H1.49292H1.48727H1.48161H1.47595H1.47028H1.4646H1.45893H1.45324H1.44755H1.44186H1.43617H1.43047H1.42476H1.41905H1.41334H1.40763H1.40191H1.39618H1.39046H1.38473H1.379H1.37326H1.36752H1.36178H1.35604H1.35029H1.34454H1.33879H1.33304H1.32728H1.32152H1.31576H1.31H1.30424H1.29847H1.29271H1.28694H1.28117H1.2754H1.26963H1.26386H1.25809H1.25231H1.24654H1.24077H1.23499H1.22922H1.22344H1.21767H1.21189H1.20612H1.20035H1.19457H1.1888H1.18303H1.17726H1.17149H1.16572H1.15995H1.15418H1.14842H1.14266H1.13689H1.13113H1.12538H1.11962H1.11387H1.10811H1.10236H1.09662H1.09087H1.08513H1.07939H1.07365H1.06792H1.06219H1.05646H1.05074H1.04502H1.0393H1.03359H1.02788H1.02218H1.01648H1.01078H1.00509H0.999398H0.993714H0.988035H0.98236H0.97669H0.971026H0.965366H0.959711H0.954062H0.948418H0.94278H0.937147H0.93152H0.925899H0.920284H0.914675H0.909072H0.903476H0.897885H0.892302H0.886725H0.881155H0.875591H0.870035H0.864486H0.858944H0.853409H0.847882H0.842363H0.836851H0.831346H0.82585H0.820362H0.814882H0.80941H0.803946H0.798491H0.793045H0.787607H0.782178H0.776758H0.771348H0.765946H0.760553H0.75517H0.749797H0.744433H0.739078H0.733734H0.728399H0.723075H0.717761H0.712457H0.707163H0.70188H0.696608H0.691346H0.686096H0.680856H0.675627H0.67041H0.665204H0.660009H0.654826H0.649655H0.644495H0.639347H0.634211H0.629088H0.623976H0.618877H0.613791H0.608716H0.603655H0.598607H0.593571H0.588548H0.583539H0.578543H0.57356H0.568591H0.563635H0.558693H0.553765H0.54885H0.54395H0.539064H0.534193H0.529335H0.524492H0.519664H0.514851H0.510052H0.505269H0.5005H0.500005L0.500009 14.621L0.500017 13.2941C0.500017 12.352 1.26376 11.5883 2.20589 11.5883C3.14802 11.5883 3.91176 12.352 3.91176 13.2941Z" stroke="white"></path>
  </svg>

Review Faster by spawning fast Preview Environments for every Pull Request.

<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 17 16" fill="none">
    <rect x="6.16406" y="0.500122" width="9.83581" height="11.6665" rx="2.5" stroke="white" stroke-linejoin="round"></rect>
    <rect x="1" y="3.83337" width="9.83581" height="11.6665" rx="2.5" stroke="white"></rect>
  </svg>

AB Test anything from individual components to entire user experiences.

<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 17 16" fill="none">
    <path d="M8.5 1.5C4.91031 1.5 2 4.41031 2 8C2 11.5897 4.91031 14.5 8.5 14.5C12.0897 14.5 15 11.5897 15 8C15 4.41031 12.0897 1.5 8.5 1.5Z" stroke="white" stroke-miterlimit="10"></path>
    <path d="M8.50043 1.5C6.68574 1.5 4.97949 4.41031 4.97949 8C4.97949 11.5897 6.68574 14.5 8.50043 14.5C10.3151 14.5 12.0214 11.5897 12.0214 8C12.0214 4.41031 10.3151 1.5 8.50043 1.5Z" stroke="white" stroke-miterlimit="10"></path>
    <path d="M4.16699 3.6665C5.36199 4.51494 6.86637 5.02088 8.50043 5.02088C10.1345 5.02088 11.6389 4.51494 12.8339 3.6665" stroke="white" stroke-linecap="round" stroke-linejoin="round"></path>
    <path d="M12.8339 12.3334C11.6389 11.4849 10.1345 10.979 8.50043 10.979C6.86637 10.979 5.36199 11.4849 4.16699 12.3334" stroke="white" stroke-linecap="round" stroke-linejoin="round"></path>
    <path d="M8.5 1.5V14.5" stroke="white" stroke-miterlimit="10"></path>
    <path d="M15 8H2" stroke="white" stroke-miterlimit="10"></path>
  </svg>

Scale globally as easy as you would with serverless but without all the limitations.

<!--kg-card-end: html-->
### Complexity

Setting up an AI model is easy on Codesphere. It takes under two minutes to [deploy an open-source LLM model like LLAMA2](https://codesphere.com/articles/self-hosted-chatgpt-in-codesphere?ref=codesphere.ghost.io). You do not need to have DevOps or Machine learning engineers to set it up or maintain it. So, there are no maintenance costs. 

If you want to fine-tune your model, that can be done by anyone. This can be achieved by fine-tuning your model with the help of services like chatGPT. Moreover, setting up the whole application follows Google’s software development standards. It is pre-set and can be used without any configuration.

**Suggested Reading: [Software Development: Moving Away from Sequential Workflows](https://codesphere.com/articles/software-development-process?ref=codesphere.ghost.io)**

## Conclusion

Generative AI has progressed exponentially in recent years in terms of performance as well as availability. The open-source LLM models are at par with the API-based LLMs and much more beneficial in most cases. It is neither complex nor expensive to host your own LLMs anymore. It is a great development for businesses and organizations who want to use the technology without giving up data autonomy and control. Codesphere, effectively resolves the cost and complexity issues that organizations face when they opt for self-hosting.