Back to Articles
AI Security

What are Large Language Models in AI?

What are Large Language Models in AI?

If you have used ChatGPT, Gemini, Claude, or another AI assistant, you have already used an Large Language Models. But what is actually happening after you type a question and press enter?

LLM stands for Large Language Model. In simple words, it is an AI model that has been trained on a very large amount of data so it can learn patterns in language and generate text. It can answer questions, summarise a document, write code, translate text, and help with many other language tasks.

There is one thing I would keep in mind from the start. An LLM does not think about an answer in the same way a person does. When you give it a prompt, it processes the tokens in that prompt and predicts what tokens should come next based on the patterns it learned during training.

The word large mainly refers to the scale of the model. One part of that scale is the number of learned parameters. Parameters are values inside the neural network that are adjusted during training. More parameters can give a model more capacity, but a bigger number does not automatically make one model better than another. The training data, model design, training process, and the job you want the model to do all matter.

How Do LLMs Work?

The easiest place to start is with tokens. An LLM does not receive your sentence as plain text in the same way we see it on a screen. A tokenizer breaks the text into smaller pieces called tokens. A token can be a whole word, part of a word, a number, or punctuation, depending on the tokenizer.

For example, when you type a sentence such as “Cybersecurity is important”, the tokenizer converts that text into token IDs. The model then works with those numbers rather than directly working with the letters on the screen.

Most modern LLMs are based on the Transformer architecture. The Transformer became widely known after the 2017 paper Attention Is All You Need. One of its important ideas is self-attention.

Self-attention helps the model look at the relationship between different tokens in the input. Take a sentence like, “The bank approved the loan because it had enough money.” When processing the word “it”, the other words in the sentence can provide useful context. Attention helps the model work out which parts of that context are more relevant.

This is not the same as a person reading the sentence and thinking about its meaning. The model uses mathematical operations to calculate relationships between tokens and build a representation of the context.

How are large language models trained?

Training an LLM is not simply a matter of giving a model a huge pile of text and letting it read everything. The data needs to be prepared, the model makes a very large number of predictions, and its parameters are updated again and again during training.

How large language models are trained

1. Collecting and preparing data

Training starts with large collections of data. Depending on the model, this can include things such as web pages, books, articles, code, and other text. The data normally needs cleaning and filtering first. Duplicates, poor-quality material, unwanted content, and other problems can affect the quality of training.

2. Breaking text into tokens

The prepared text is converted into tokens. Since neural networks work with numbers, the tokenizer turns those pieces of text into token IDs that the model can process.

3. Predicting the next token

For many generative LLMs, a major part of pre-training involves next-token prediction. Imagine the training text contains: “The security team checked the server logs and found…” The model is given the earlier tokens and tries to predict what should come next.

Early in training, the predictions can be very poor. The training process compares the model’s output with the training target and uses the difference to update the model. Repeating this over a huge number of examples helps the model learn useful patterns in the training data.

4. Loss and backpropagation

This part is often explained by saying that the model checks whether it was right or wrong. That is a simple way to describe it, but the real process is more detailed. A loss function measures how different the model’s prediction is from the target. The training system then calculates gradients and uses an optimisation method, such as gradient descent, to update the parameters.

Backpropagation is used to calculate how the loss should affect the parameters through the network. This happens over and over across a very large number of training examples. The model is not learning a list of ready-made answers. It is adjusting its parameters so it becomes better at the patterns represented in its training data.

5. Fine-tuning and post-training

Pre-training gives a model broad capabilities, but it does not automatically make the model good at every task. Developers can use additional training and post-training methods to make a model follow instructions better or behave in a way that is more useful for a particular purpose.

Zero-shot, few-shot learning and fine-tuning are different

These three terms are often mentioned together, which can be confusing at first. They are not the same thing.

  • Zero-shot: You ask the model to do a task without giving examples of that task in the prompt. For example, you could ask it to classify a security alert as high, medium, or low risk without showing example classifications first.
  • Few-shot: You put a small number of examples in the prompt and then ask the model to do the same kind of task. The examples show the model the pattern or format you want.
  • Fine-tuning: The model is further trained using a dataset for a particular purpose. This is different from putting examples in a prompt because the examples become part of a separate training process.

How Big Is an LLM? What Do 3B, 8B and 70B Mean?

You may have seen AI models described as 3B, 8B, 70B or 405B. The “B” means billion parameters. Parameters are learned values inside the model that are adjusted during training.

For example, Meta has released Llama models in different sizes. Llama 3.2 includes 1B and 3B text-only models, as well as 11B and 90B vision models. Llama 3.3 has a 70B model, while Llama 3.1 includes 8B and 405B models. Meta describes the 1B and 3B Llama 3.2 models as lightweight models for edge and mobile use. Meta’s Llama model documentation lists the model sizes and their licenses.

But don’t look at the number and assume that bigger always means better. It doesn’t work that way. Training data, model architecture, training methods, optimisation, and the task itself all make a difference. A smaller model can also make more sense when you need lower cost, faster responses, or local processing.

Frontier Models vs Open Source Models

You will also hear terms such as frontier model and open source model. They are talking about different things.

A frontier model generally means a model that is at or near the leading edge of AI capability at a particular point in time. There is no single parameter number that makes a model a frontier model. Capability, not just size, is the important part.

Open source models take a different approach. Depending on the model and its licence, developers may be able to download the model weights and run or adapt the model themselves. Llama is one example. Meta makes several Llama model weights available, but they are distributed under Meta’s own Llama Community License Agreements.

There is also a practical difference. With a hosted commercial model, the provider runs the infrastructure. If you run an open-weight model yourself, you have to think about the hardware or cloud compute, storage, updates, security, monitoring, and the people needed to manage it.

How Much Does It Cost to Use an LLM?

This depends on how you use the model. If you use a commercial API, you normally pay based on usage. If you run an open-weight model yourself, you may avoid a per-request API charge, but the machine running the model still costs money.

For example, OpenAI’s current API pricing lists GPT-6 Sol at $2 per million input tokens and $10 per million output tokens under standard short-context pricing. GPT-6 Luna is listed at $0.10 per million input tokens and $0.50 per million output tokens. Prices can change, so these numbers are examples of current API pricing rather than a permanent price list. OpenAI’s current pricing page has the latest rates.

Anthropic also uses token-based API pricing. Its current Claude Sonnet 5 pricing is listed at $2 per million input tokens and $10 per million output tokens. Again, pricing can change, so it is better to check the provider before making a cost comparison. Anthropic’s pricing announcement has the current details.

Running an open-weight model yourself is different. A small model may be practical on modest hardware, while a larger model can need much more GPU memory or multiple GPUs. You also have the cost of deployment, updates, monitoring and security. So an open model may be available to download, but that does not mean running it is free.

ApproachWhat you pay forWho manages the infrastructure?
Commercial APIUsually tokens or another usage metricAI provider
Hosted open modelUsually compute or usageHosting provider
Self-hosted open-weight modelHardware or cloud compute, storage and operationsYou or your organisation
Training a model from scratchLarge-scale compute, data and engineeringYou or your organisation

Personally, I would not start by asking, “Which model is the biggest?” I would first ask what the model actually needs to do. If a smaller model can handle the job at a lower cost and with the right privacy controls, there may be little reason to use a much larger one.

Training, Fine-Tuning and Inference: What Is the Difference?

These words come up everywhere when you start reading about LLMs, but the basic difference is not very complicated.

  • Pre-training: The model learns broad patterns from a large training dataset by adjusting its parameters.
  • Fine-tuning: An existing model is trained further with more specific data so it can perform a particular task or follow a desired behaviour better.
  • Inference: You use the trained model to generate an answer. When you type a question into an AI chatbot, you are normally doing inference, not training the model.

There is another approach called Retrieval-Augmented Generation, or RAG. Instead of changing the model every time new information is added, an application can retrieve relevant information from documents or a database and give that information to the model as context. For example, a company could connect an LLM to its internal security policies. When someone asks a question, the application can first retrieve the relevant policy and then give it to the model to help form the answer.

What Are LLMs Used For?

LLMs are now used in many different applications. What a model can actually do depends on the model itself and also on the software, data and tools connected to it.

  • Chatbots and assistants: They can answer questions, summarise text, draft messages, and help people work with information.
  • Writing and summarisation: An LLM can turn notes into a draft, shorten a long document, or rewrite something for a different audience.
  • Code assistance: LLM-based coding tools can generate code, explain code, suggest changes, and help developers investigate possible problems. The output still needs to be reviewed and tested.
  • Translation and language tasks: Language models can help with translation, classification, extraction, rewriting and other text tasks. It is better not to assume that every translation service is simply an LLM, because different systems can use different models and technologies.
  • Research and knowledge work: LLMs can help summarise papers, organise information, generate questions and work with large amounts of text. For security or other high-stakes work, the output should still be checked.

Why Can an LLM Give a Wrong Answer?

This is one of the most important things to understand about LLMs. A response can sound very confident and still be wrong.

When an LLM generates text, it is using the patterns it learned during training together with the context in the prompt and any other information supplied to it. It is not automatically checking every sentence against a trusted database before answering. Because of that, it can produce an incorrect technical detail, a citation that does not exist, or an answer that simply sounds right.

In security work, this can become a real problem. Imagine asking an LLM for the CVE number, affected version, or impact of a vulnerability. It may give you a very convincing answer. I would still check that information against the vendor advisory, NVD, CISA, source code, or another trusted primary source before using it in a report.

For me, this is one of the biggest differences between using an LLM casually and using one for security work. The tool can save a lot of time, but the person using it still needs to know when an answer needs to be verified.

LLMs and Security: What Should You Watch?

From a security point of view, the model is only one part of the system. The application around it matters too. A company might connect an LLM to internal documents, databases, APIs, email, or other tools. Once those connections exist, the security question is no longer just about the model. You also have to think about what the model can access and what actions it is allowed to take.

Privacy is another concern. Sending confidential source code, customer information, credentials, or internal documents to an AI service can create risk depending on how that service handles the data. Before using an LLM with company information, I would check the provider’s data handling, retention, training, access and security policies.

Training data also needs care. Large datasets can contain personal information, copyrighted material, poor-quality content, or other unwanted data. That does not mean every LLM will simply memorise and reveal personal information. But research has shown that models can sometimes reproduce information from training data under particular conditions, so privacy needs to be considered during data collection, training and deployment.

My Take on LLMs

What I find interesting about LLMs is not just that they can write an email or answer a question. The bigger change is what happens when you connect a language model to real data and tools.

For example, an LLM connected to security documentation could help an analyst search and summarise information. Connect it to logs and other tools, and it can become part of a larger security workflow. But every extra connection also gives you another security boundary to think about.

I also would not treat an LLM like a person who has checked every fact before speaking. The wording can sound certain even when the answer is wrong. In cybersecurity, that difference matters. A fast answer is useful, but a fast wrong answer can waste even more time.

That is how I look at LLMs today. They are very capable tools for working with language and information, but they still need good data, proper controls and human judgement around them.