DEV Community

shashank ms
shashank ms

Posted on

What is LLM? A Beginner's Guide to Large Language Models

Large language models, or LLMs, are neural networks trained to predict the next token in a sequence. In practical terms, they accept a block of text and generate a continuation. In this guide, we will build a working research assistant that summarizes articles and answers follow-up questions, using Oxlo.ai to run the model.

What you'll need

Before we start, make sure you have the following:

  • Python 3.10 or newer installed.
  • The OpenAI SDK: pip install openai.
  • An Oxlo.ai API key from https://portal.oxlo.ai.

Step 1: Make your first LLM call

Before we build the agent, we will verify that we can reach an LLM through Oxlo.ai. The code below sends a single user message to Llama 3.3 70B and prints the reply.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

user_message = "What is an LLM in one sentence?"

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "user", "content": user_message},
    ],
)

print(response.choices[0].message.content)

If that prints a coherent definition, the pipeline works. Oxlo.ai exposes Llama 3.3 70B and dozens of other models through a single OpenAI-compatible endpoint, so you can swap the model string later without changing client code.

Step 2: Shape behavior with a system prompt

An LLM has no fixed personality unless you give it one. A system prompt sets the rules. We will define a prompt that tells the model to act as a concise research assistant.

SYSTEM_PROMPT = """You are a research assistant. Your job is to summarize text clearly and answer follow-up questions based only on the context provided. Keep answers under three sentences unless the user asks for detail."""

Now we send the same test question, but this time with the system prompt included.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

user_message = "What is an LLM in one sentence?"

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": user_message},
    ],
)

print(response.choices[0].message.content)

The model now follows the formatting rules we specified. This is the main lever for controlling any LLM application.

Step 3: Build a multi-turn research assistant

Real assistants need memory. LLMs are stateless, so the client must resend the full conversation history each time. We will build a small loop that collects user input, appends it to a messages list, and prints the model reply.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are a research assistant. Your job is to summarize text clearly and answer follow-up questions based only on the context provided. Keep answers under three sentences unless the user asks for detail."""

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
]

print("Research assistant ready. Type 'exit' to quit.")

while True:
    user_input = input("\nYou: ")
    if user_input.lower() == "exit":
        break

    messages.append({"role": "user", "content": user_input})

    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=messages,
    )

    assistant_reply = response.choices[0].message.content
    print(f"Assistant: {assistant_reply}")

    messages.append({"role": "assistant", "content": assistant_reply})

Because Oxlo.ai uses request-based pricing, the cost of this call is flat regardless of how long the conversation grows. For a prototype or an internal tool that processes long transcripts, that predictability beats counting tokens.

Step 4: Add document summarization

Now we give the assistant a concrete task. The user will paste an article, and the assistant will summarize it. Then the user can ask questions. We will simulate the first turn by injecting a user message that contains a block of text.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are a research assistant. Your job is to summarize text clearly and answer follow-up questions based only on the context provided. Keep answers under three sentences unless the user asks for detail."""

article = """
Large language models (LLMs) are machine learning models designed to understand and generate human language. They are trained on vast text corpora using self-supervised learning, which means they learn patterns by predicting the next word in a sentence. Modern LLMs use transformer architectures, which allow them to process long-range dependencies in text. When you send a prompt to an LLM, the model converts your text into tokens, runs them through many layers of neural computation, and samples the most likely next tokens to form a response.
"""

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {"role": "user", "content": f"Summarize this article in two bullet points:\n\n{article}"},
]

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=messages,
)

summary = response.choices[0].message.content
print(summary)

messages.append({"role": "assistant", "content": summary})

After the summary prints, the messages list already contains the context. You can append another user question, such as "What is a transformer architecture?", and the model will answer using the article as context.

Run it

Here is the complete script. Save it as research_assistant.py, replace YOUR_OXLO_API_KEY, and run python research_assistant.py.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are a research assistant. Your job is to summarize text clearly and answer follow-up questions based only on the context provided. Keep answers under three sentences unless the user asks for detail."""

article = """
Large language models (LLMs) are machine learning models designed to understand and generate human language. They are trained on vast text corpora using self-supervised learning, which means they learn patterns by predicting the next word in a sentence. Modern LLMs use transformer architectures, which allow them to process long-range dependencies in text. When you send a prompt to an LLM, the model converts your text into tokens, runs them through many layers of neural computation, and samples the most likely next tokens to form a response.
"""

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {"role": "user", "content": f"Summarize this article in two bullet points:\n\n{article}"},
]

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=messages,
)

summary = response.choices[0].message.content
print("Summary:\n", summary)

messages.append({"role": "assistant", "content": summary})

# Follow-up question
messages.append({"role": "user", "content": "What does 'self-supervised learning' mean here?"})

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=messages,
)

print("\nFollow-up:\n", response.choices[0].message.content)

Example output:

Summary:
- LLMs are machine learning models that understand and generate human language by training on large text datasets and predicting the next word.
- They rely on transformer architectures to handle long-range dependencies in text, converting input into tokens and processing them through neural layers to produce responses.

Follow-up:
Self-supervised learning means the model learns from raw text without human-labeled answers. It repeatedly predicts the next word in a sentence, and the difference between its prediction and the actual word becomes the training signal.

Next steps

Try swapping the model string to qwen-3-32b or deepseek-v3.2 to see how different architectures change the tone of the summary. If you plan to deploy this internally, look at Oxlo.ai request-based pricing at https://oxlo.ai/pricing. It stays flat even when users paste long documents, which keeps costs predictable for text-heavy tools.

Top comments (0)