Suppose a teacher wants help drafting lesson plans or a team wants to turn routine paperwork into clearer communication. A language model can generate text for those tasks. A large language model (LLM) is trained on extensive text collections; modern LLMs are typically large transformer-based models trained to predict what comes next in a sequence. Fluent output is useful, but it does not make every answer reliable or every task a good fit. section 1.1 section 5.2 section 1.4
LLMs build on earlier approaches to language modeling, including N-grams and recurrent neural networks. Their scale—parameters, training data, and training time—helps them handle varied tasks, sometimes with only a few examples in a prompt. That same scale makes training and deployment resource-intensive. section 2.0 section 2.4 section 3.2
Choose the least costly route that proves the task works:
- Prompt an existing model first. Give it an instruction and, if useful, one or a few examples; specialized tasks do not always require finetuning. section 2.4
- Buy API access to prototype quickly and use a provider’s model and supporting systems. Test it on your domain before committing heavily. section 1.2.1
- Run or adapt an open model when control, data safety, cost transparency, or output policy justify the added deployment work. Training from scratch is possible, but requires substantial data and compute. section 1.3 section 1.4 section 5.2.1
Listing 2.9 Running our first LLM
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_NAME = "bigscience/bloom"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
prompt = "Hello world! This is my first time running an LLM!"
input_tokens = tokenizer.encode(prompt, return_tensors="pt", padding=True)
generated_tokens = model.generate(input_tokens, max_new_tokens=20)
generated_text = tokenizer.batch_decode(
generated_tokens, skip_special_tokens=True
)
print(generated_text)
A short Python example loads a tokenizer and a causal language model, encodes a prompt, generates more tokens, and decodes the result. It makes the path from prompt to generated text concrete without requiring training. section 2.4
If an existing model needs adaptation, a common path is to pretrain a foundation model on broad text, finetune it on a curated task dataset, then improve its use through prompting. From-scratch training also requires an architecture, tokenized data, and repeated weight updates; finetuning generally needs fewer resources. Do not choose a model by size or a convincing demonstration alone: compare its outputs with task-specific data and metrics, and check bias and potential harm. Avoid an LLM where a simpler solution needs lower latency or the risk of mistakes is too high. section 5.2 section 5.2.1 section 4.2 section 4.6


































































