LLMs - A Deep Dive
LLMs a Deep Dive

Today, we want to delve into large language models, starting with the fundamental question: What exactly is a large language model, and where did it originate?

Let's begin with a bit of history. It all started with a project related to functional programming. Those of you who, like me, have been around for a while might recall Eliza, a chat program from the 1960s, written in Lisp. It was essentially a computational therapist, cleverly combining rule-based responses in a faux therapy setting. Despite its simplicity, it was quite effective in mimicking a real therapist, laying the groundwork for what was to come.

As machine learning evolved, the focus shifted to creating artificial intelligence by emulating something we already know well – our brains. This led to the conceptualisation and implementation of neural networks in the 1990s, becoming an integral part of machine learning.

The journey continued with the realisation that to effectively process text and language, we should treat sentences as vectors and perform matrix multiplication on them. This gave rise to frameworks like Word2Vec. However, merely using tokenised vectors wasn't enough; we needed to teach our neural networks to understand context. This led to the development of LSTM, standing for Long Short-Term Memory, allowing models to keep segments in context and analyse and recombine them to answer specific questions, significantly aiding in summarisation and classification in natural language processing.

This progress sparked another group of innovators to take things further. We all remember the early translators, translating a sentence from French to English and getting clunky results. Google, investing significant effort to improve this, introduced the concept of Transformers. This was a leap forward in effectively handling translations, especially considering the vast differences in syntax and grammar across languages.

The Transformer Era and The Rise of Large Language Models

Transformers are based on a couple of key principles: having an encoder that reads a sequence and a decoder that predicts the most likely next token. The model learns by taking partial sentences, masking parts of them, and predicting the words that should fill these gaps. When it correctly matches these predictions with the actual sentences, the model improves, allowing transformer-based models to essentially learn by themselves.

To achieve the capabilities of modern systems like OpenAI's ChatGPT, a tremendous amount of data is required. This is where large language models differ significantly from traditional machine learning models; they are fed vast quantities of data. For example, they use datasets like Common Crawl, which contains 50 billion web pages, and Wikipedia. Particularly for models providing code assistance, they utilise combinations of public repositories from Jupiter and GitHub.

But what are the common implementations of large language models? Google Translate, for instance, uses a form of large language model. While it has evolved from the original Transformer model, it retains similarities and offers the ability to translate between any language pair. Another significant presence in this field is OpenAI, whose large language models like ChatGPT have garnered widespread attention for their ability to generate creative content like poems.


Training, Fine-Tuning and Prompt Engineering: A LLM Deep Dive 

Creating a large language model involves pre-training on large datasets, which is a complex task. Data sources like Common Crawl contain a significant amount of irrelevant information, requiring extensive refinement to create a usable dataset. Additionally, access to large quantities of digitised books is essential, as more text equates to a better model. However, this introduces a bias, as English, constituting 60% of the internet's content, is better represented than other languages.

On top of refining datasets, it's crucial to ensure that the data used for training does not contain private data. As a result, a lot of resources go into validating and filtering these datasets to avoid leaking sensitive information.

There's also a misconception that “more parameters are always better”.

A larger model requires more resources to run, as it needs to load itself into memory and utilise GPU memory, which can be costly. Sometimes, a smaller model with fewer parameters might be more suitable due to the performance trade-off.

The alternative approach is to take a general-purpose language model and fine-tune it with specific domain knowledge. This technique involves post-training an existing model with additional data, turning it into an expert in a particular field. This method also enhances performance and can be used to create domain-specific models.

Regarding interaction with large language models, there are two primary modes: chatting and instructing. Chatting is what most people are familiar with – having conversations with a model. Instruct mode, however, involves asking the model to perform specific tasks, like summarising text or classifying content. This mode is particularly useful for integrating large language models in enterprise contexts and applications.

The interaction with a large language model typically involves prompt engineering, which might sound strange, especially to software developers. Prompt engineering involves instructing a large language model in natural language to perform a specific task. Despite its simplicity, prompt engineering is a critical aspect of working with large language models, as it essentially guides the model to generate the desired output.

This process allows us to treat a large language model as a service. By utilising an HTTP interface, we can send prompts and receive responses, integrating the results seamlessly into our applications. This approach opens up a myriad of possibilities for automating and enhancing various tasks, especially in fields where natural language processing is essential.

One of the great strengths of large language models lies in tasks like classification, summarisation, and entity extraction. These are areas where traditional methods often fall short, but large language models excel. For instance, extracting specific information from unstructured documents like PDFs can be extremely challenging, but large language models can do this with relative ease, outputting structured data such as JSON formats.

In the realm of enterprise applications, large language models have transformative potential. They can automate mundane tasks, analyse and classify large volumes of documents, and even assist in decision-making processes in sectors like healthcare, legal, and customer support.

Deploying large language models has become more accessible in recent months. There are three primary deployment methods: using an inference API, which is the simplest method and involves interacting with models like GPT via their APIs; using a hosted model as a service provided by cloud providers or companies like Hugging Face; and hosting your large language model in a container with GPU instances in a Kubernetes cluster for more privacy-conscious or regulatory-bound scenarios.

The last method is particularly notable because of its flexibility and security. Kubernetes offers an ideal environment for running large language models, thanks to its ability to create bespoke configurations tailored to the specific needs of these models.

The impact of LLMs is significant. They democratise machine learning, making it accessible to non-data engineering professionals. This is because they are pre-trained and plugable, reducing the complexity to prompt engineering. However, as the models lack reasoning capabilities, they predict answers solely based on likelihood. This comes with challenges like hallucinations, where a model provides a plausible but false answer.

Steering the Future of LLMs with Retrievable Augmented Generation (RAG)

Here’s where retrievable augmented generation (RAG) comes into play. Traditionally, LLMs are trained on massive datasets and generate responses based on this training. RAG changes this paradigm by detaching the primary data source from the model itself. Instead of relying solely on its training data, the model looks for answers in an external, vectorized data store. This approach uses embedding models for storing data, allowing the language model to access relevant information externally. This has several advantages:

By relying on external, curated data, RAG significantly reduces the likelihood of generating false information.

With RAG, there's less need for continuous retraining of the model with new data. The model leverages up-to-date information from the external data store, which can be updated independently of the model itself.

By separating the model from the data, RAG allows for tighter control over data privacy. The data used to generate the answers is not in the model itself, which reduces the risk of sensitive information being inadvertently disclosed to unauthorised third parties. Private data remains in the hands of the company operating the model, which enables better compliance with data protection guidelines and regulations.

LLMs offer great potential in areas such as the healthcare sector, the legal sector or even in business processes - be it in the search for precedents, in recognising cancer or in industrial applications, where they can help navigate complex manuals and documentation. Especially in these areas that deal with highly sensitive data, the use of fine-tuned RAG large language models is essential.


To summarise, the deployment and use of large-scale language models, particularly through innovative architectures such as Retrievable Augmented Generation, represents a significant leap forward in the field of AI and machine learning. RAG not only increases the efficiency and accuracy of these models, but also addresses critical issues such as data privacy and operational costs. As technology continues to evolve, the customisation and integration of such advanced solutions is critical to maintaining competitive advantage and ensuring compliance with evolving data regulations. 

If you are interested in using LLMs for your organisation and want to know how you can seamlessly integrate it into your business processes, don't hesitate to contact us. We will be happy to guide you through the complexity of modern AI applications and help you utilise their full potential for your company.

Journey Beyond the Ordinary 
with Hivemind's Expertise 

Hivemind Technologies stands ready to guide your business or organisation in harnessing the full potential of LLMs with RAG. Whether it's integrating these models into existing systems or exploring new applications, we offer the expertise and insights to navigate this new era of AI-driven innovation.

Get in touch to see how we can customise LLMs for your specific needs, and be part of a journey where technology goes beyond the ordinary.