Language models, retrieval, prompting, and language adaptation · Autoregressive and open-weight model families · LNG035 · Model
LLaMA / Llama family
Provides openly released autoregressive model families for research and deployment, with later generations expanding capabilities and modalities.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's own run
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: The chapter's authors report running it; there is no record for this entry alone. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Provides openly released autoregressive model families for research and deployment, with later generations expanding capabilities and modalities. Versions and sizes are grouped rather than counted as independent modeling principles; licenses and capabilities are checkpoint-specific.
Question / objective
How do openly released causal language-model checkpoints perform under a specific deployment configuration?
Architecture / computational structure
Decoder weights include embeddings, attention and feed-forward matrices, and output projections; later family reports describe grouped-query attention configurations. Exact learned tensor shapes belong to the chosen checkpoint; size, precision, context, and adapters are design choices.
Assumptions
A base checkpoint is not an instruction-following assistant; mismatched chat templates can severely degrade results.
Formula / computational definition
Language pretraining minimizes next-token cross-entropy. The Llama 3 report describes architectural and post-training choices, including grouped-query attention in its model configurations; post-training objectives differ from base pretraining.
Parameters and notation
Learned parameters: identified in the architecture subsection. Hyperparameters, design and inference choices: Checkpoint generation, tokenizer, context length, grouped-query configuration, instruction template, precision/quantization, and adaptation strategy.
Fitting, fine-tuning, and adaptation
Use the correct tokenizer and chat template. Adapt with next-token or supervised response loss using supported LoRA/adapters or full updates; freeze base weights for parameter-efficient routes. Validate capability retention, multilingual behavior, license constraints, and adapter portability before merging or deployment.
How to use and calibrate
Evaluate the exact checkpoint on task accuracy, multilingual behavior, safety/factuality, long-context tasks, throughput, and memory. Compare base and instruction-tuned variants explicitly. Use development data for settings and an independent test set for the final estimate. Report uncertainty across examples or seeds when the evaluation design supports it; model scores and self-assessments are not automatically calibrated probabilities of correctness.
Example application
Create a domain assistant from an instruction checkpoint with a small verified training set.
Interpretation / pitfalls
Watch out
Open weights do not automatically imply unrestricted usage or complete training-data transparency. The code below isolates one stated component; successful execution does not validate model quality or reproduce the cited experiment.
Python and R code examples
Full implementation route: Supported checkpoints use Transformers causal-model loading and model-card chat templates. R generally calls Python through reticulate. The mathematical demo shows head-group sharing counts and does not instantiate or train a Llama model.
Example scope: Grouped-query head sharing count for an illustrative Llama-style configuration.
Dependencies: Python 3 standard library; base R; shared setup above. No model downloads or external services.
Validation: Python component executed in the combined example script; R counterpart supplied but not runtime-tested here. All numbers are synthetic.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Grouped-query head sharing count for an illustrative Llama-style configuration.
Shared setup for this chapter
import math
def softmax(xs):
m = max(xs)
es = [math.exp(x-m) for x in xs]
return [e/sum(es) for e in es]
def dot(a, b):
return sum(x*y for x, y in zip(a, b))
def matvec(matrix, vector):
return [dot(row, vector) for row in matrix]
def meanvec(rows):
return [sum(row[j] for row in rows)/len(rows) for j in range(len(rows[0]))]
def sigmoid(x):
return 1/(1+math.exp(-x))
def nll(probabilities):
return -sum(math.log(p) for p in probabilities)
query_heads, kv_heads = 32, 8
assert query_heads % kv_heads == 0
print({"queries_per_kv_head": query_heads//kv_heads, "kv_head_fraction": kv_heads/query_heads})
Component demo, not a trained model — Grouped-query head sharing count for an illustrative Llama-style configuration.
Shared setup for this chapter
softmax <- function(x) {
shifted <- exp(x-max(x))
shifted/sum(shifted)
}
query_heads <- 32L; kv_heads <- 8L
stopifnot(query_heads %% kv_heads == 0)
print(c(queries_per_kv_head=query_heads/kv_heads, kv_head_fraction=kv_heads/query_heads))
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry LNG035.