LlamaIndexllama-index-core 0.14 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
30 small wins to finish your pathNext lesson →

Metadata: what gets embedded and what the model sees

Metadata is the set of facts attached to a node, and LlamaIndex lets you choose, per key, whether each fact is embedded, shown to the model, or kept out of both.

Last updated: 28 Sep, 2026 · LlamaIndex 0.14

The last two lessons attached metadata such as the file name to every node. This lesson controls where each key goes, because a key can help matching, help answering, both, or neither.

Reading a node two ways

get_content takes a metadata_mode: EMBED shows what the embedding model receives, LLM what the model reads. Each key is written as a key: value line above the text:

python
from llama_index.core import Document
from llama_index.core.schema import MetadataMode

doc = Document(text="Standard delivery takes 3 to 5 working days.", metadata={"file_name": "delivery.md", "reviewed_by": "ops-team"})
print(doc.get_content(metadata_mode=MetadataMode.EMBED))
print("---")
print(doc.get_content(metadata_mode=MetadataMode.LLM))

Seeing the embed and LLM views

Example
from llama_index.core import Document
from llama_index.core.schema import MetadataMode

doc = Document(text="Standard delivery takes 3 to 5 working days.", metadata={"file_name": "delivery.md", "reviewed_by": "ops-team"})
print(doc.get_content(metadata_mode=MetadataMode.EMBED))
print("---")
print(doc.get_content(metadata_mode=MetadataMode.LLM))

Reading the two views

  • Both views include every metadata key for a Document you build yourself, as key: value lines above the text.
  • reviewed_by appears in both, so it would be embedded and shown to the model, though it helps with neither.
  • SimpleDirectoryReader sets exclusions for the file keys it adds, which is why the query-engine lesson later shows none of them in the prompt.

Excluding a key from both views

Two lists on the document decide what to leave out of each view:

python
doc.excluded_embed_metadata_keys = ["reviewed_by"]
doc.excluded_llm_metadata_keys = ["reviewed_by"]
print(doc.get_content(metadata_mode=MetadataMode.EMBED))
print("---")
print(doc.get_content(metadata_mode=MetadataMode.LLM))

Excluding a key from embedding and the prompt

Example
doc.excluded_embed_metadata_keys = ["reviewed_by"]
doc.excluded_llm_metadata_keys = ["reviewed_by"]
print(doc.get_content(metadata_mode=MetadataMode.EMBED))
print("---")
print(doc.get_content(metadata_mode=MetadataMode.LLM))

Reading the excluded views

  • reviewed_by is gone from both views, so it no longer affects matching or answering.
  • It stays on the node for filtering or auditing; excluding it changes only what the two views show.
  • file_name remains in the model's view here, so a model could name the file it answered from.

MetadataMode.EMBED vs MetadataMode.LLM

MetadataMode.EMBEDMetadataMode.LLM
ReachesThe embedding modelThe answering model
AffectsWhich chunk matches a questionWhat the model can read and cite
Exclude withexcluded_embed_metadata_keysexcluded_llm_metadata_keys
Keep for a titleYes, it helps matchingYes, it helps citing

When to exclude a key

  • Embed what helps a question find the chunk, such as a title or product name.
  • Show the model what helps it answer or cite, such as the file name.
  • Keep audit fields, ids and machine paths out of both, on the node for filtering only.
Watch out. Metadata you forget to exclude is embedded silently, so a noisy key such as a timestamp or a reviewer name can shift which chunk matches a question without any error. Check both views with get_content when a match looks wrong.
Try it yourself
  • Exclude file_name from the embed view only and print both views.
  • Add a "product": "LMP-204" key and check it appears in both views.
  • Print the content with MetadataMode.NONE.

You understood something today that you didn't yesterday.