Module 1 · LlamaIndex architecture
Settings: LLM, embeddings and tokenizers
5 min read
LlamaIndex combines several models: an LLM that writes answers and runs some transformations, an embedding model that turns texts into vectors, and a tokenizer that counts tokens to respect limits. The Settings object sets their defaults for the whole application. Setting it well — and knowing when to depart from it — avoids costly mistakes, including a very current one with recent Claude models.
The Settings object
Settings is a global singleton: every LlamaIndex component reads its models from it when not given one explicitly.
from llama_index.core import Settings
from llama_index.core.node_parser import SentenceSplitter
Settings.llm = main_llm()
Settings.embed_model = embed_model()
Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=64)
| Setting | Role |
|---|---|
llm | Default model for engines, extractors, evaluators |
embed_model | Default embedding model, at ingestion and at query time |
node_parser / transformations | Default chunking when an index is built from documents |
tokenizer | Token counting function (context budget) |
context_window, num_output | Limits used to fill the context without overflowing it |
callback_manager | Legacy tracing system (instrumentation replaced it, lesson 5.4) |
In Lumen, the models.configure() function sets these values once, at startup. But the singleton has a downside: changed in one place, it changes behavior everywhere. For any component that needs another model — a fast model for extraction, a judge for evaluation — pass the model explicitly rather than changing Settings on the fly. That's what Lumen does: summary_index(..., llm=models.fast_llm()).
The LLM: Claude through the Anthropic integration
from llama_index.llms.anthropic import Anthropic
llm = Anthropic(model="claude-opus-5-5", max_tokens=4096, max_retries=3)
Lumen uses two models: Claude Opus 5.5 to write answers and reason, Claude Haiku 5.5 for auxiliary tasks — document summaries, engine selection, sub-question generation, extraction. The fast model costs a fraction of the large one; on a pipeline that calls it thousands of times, the difference is considerable.
The temperature trap
Recent Claude models no longer accept sampling parameters as before:
| Model | temperature |
|---|---|
| Claude Opus 5.5, Sonnet 5.5 (and Opus since 4.7) | Rejected: any value causes a 400 error |
| Claude Haiku 5.5 | Only the value 1 is accepted; any other value causes a 400 error |
Yet the LlamaIndex integration sends temperature=0.1 by default. It removes the parameter by itself for models it knows to be incompatible (Opus 5.5, Sonnet 5.5…), but, in the version used for this course, not for Haiku 5.5. Hence this explicit setting in Lumen:
def fast_llm() -> LLM:
# Claude Haiku 5.5 refuse toute temperature différente de 1 (erreur 400) ; l'intégration envoie 0,1
# par défaut et ne connaît pas encore ce modèle : on fixe donc explicitement la valeur acceptée.
return Anthropic(model=config.FAST_MODEL, temperature=1.0, max_tokens=2048, max_retries=3)
The lesson goes beyond this specific case: integrations always lag behind models. After every change of model or integration version, check the parameters actually sent (the object exposes _model_kwargs) and make a test call. If you used temperature=0 to get stable answers, know that it never guaranteed identical outputs anyway: stability comes from structured outputs and precise instructions.
The embedding model
The embedding model is the most structuring architectural choice: vectors computed at ingestion and those of questions must come from the same model. Changing it means reindexing everything.
Lumen uses FastEmbed, which runs embedding models locally, with no API key and no per-request cost:
from llama_index.embeddings.fastembed import FastEmbedEmbedding
embed_model = FastEmbedEmbedding(
model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
)
| Criterion | What to look at |
|---|---|
| Language | A French corpus requires a multilingual model; many default models are English-only |
| Quality | Public leaderboards (MTEB) give an idea, but nothing replaces a test on your questions (lesson 5.3) |
| Dimension | 384, 768, 1024…: more dimensions, more storage and compute |
| Hosting | Local (FastEmbed, Ollama): free and private; API (Voyage AI, Cohere…): often better, but paid and your texts leave your systems |
| Maximum length | A passage longer than the model's limit is silently truncated |
The tokenizer and the context budget
LlamaIndex counts tokens to fill the model's context without overflowing it (how many passages fit in one call, how to split). By default, it uses a generic tokenizer that doesn't exactly match Claude's: counts are approximations. So keep a margin: with 512-token passages and four passages per question, you stay far from the limits of current models.
Lumen's offline mode
All configuration goes through a single module, lumen/models.py. With LUMEN_FAKE_LLM=1, it returns a fake, deterministic LLM and embeddings instead of the real ones. That's what lets the 27 tests run in seconds, with no network and no cost. The principle is general: a single access point to models makes the application testable, and lets you change provider in one place.
Key takeaways
Settingssets default models; set it once at startup, and pass models explicitly when another one is needed.- A large model to write, a fast model for auxiliary tasks.
- Claude Opus 5.5 rejects
temperature, Claude Haiku 5.5 only accepts 1: check the parameters the integration actually sends.- The embedding model is structuring: multilingual for a French corpus, the same at ingestion and query time.
- A single access point to models makes the application testable offline.
Practice
- Create Lumen's two models with a dummy key and print their
_model_kwargs: which parameters would be sent to the API? - Compute the embedding of "délai de retour" and "return window" with the multilingual model, then with
BAAI/bge-small-en-v1.5: compare the similarity obtained. - Find every place in
lumen/where a model is passed explicitly rather than read fromSettings, and explain each choice.