Domain Glossary and Ontology Injection
Embedding domain-specific terminology and knowledge into system prompts.
The Disambiguation Problem
Domain language is full of ambiguity. 'Yield' means bond yield in finance and crop yield in agriculture. 'Resolution' means screen resolution in UI and issue resolution in support. Without domain context, models default to the most common general-language meaning — which is wrong in specialized domains.
Glossary Injection Pattern
Inject a domain glossary directly into the system prompt. This overrides the model's default vocabulary and ensures domain-specific terms are interpreted correctly throughout the session.
FINANCE_GLOSSARY = '''
DOMAIN GLOSSARY (these definitions override general language meaning):
- yield: bond yield (annual return as percentage of bond price), NOT crop or harvest
- duration: interest rate sensitivity measure (modified duration), NOT time length
- spread: yield spread between two bonds, NOT physical spreading
- convexity: second-order price sensitivity to interest rate changes, NOT geometry
- tenor: remaining time to maturity of a financial instrument, NOT musical pitch
- floor: minimum interest rate in a rate agreement, NOT building floor
- cap: maximum interest rate, NOT a hat or market capitalization
- swap: exchange of cash flows between counterparties, NOT physical exchange
- basis: difference between spot and futures price, NOT foundation
'''
FINANCE_SYSTEM_PROMPT = (
'You are a fixed income analyst.\n\n'
+ FINANCE_GLOSSARY +
'\nAlways use these domain definitions when answering questions.'
)
import anthropic
client = anthropic.Anthropic(api_key='YOUR_API_KEY')
response = client.messages.create(
model='claude-opus-4-5', max_tokens=500,
system=FINANCE_SYSTEM_PROMPT,
messages=[{'role': 'user', 'content': 'What is the yield of a 10-year bond?'}]
)
print(response.content[0].text)All lessons in this course
- Legal Domain Prompt Patterns
- Medical and Clinical Prompting
- Financial and Quantitative Prompts
- Domain Glossary and Ontology Injection