VocabularyTermclass

Define domain-specific terminology with multilingual support for consistent AI understanding.

USAGE

VocabularyTerm(term, definition, synonyms=None, translations=None)

VocabularyTerm creates a professional glossary entry that ensures AI systems correctly interpret specialized terminology within specific business or technical contexts. These terms are designed to integrate seamlessly with PromptBuilder through the .vocabulary() method, where individual VocabularyTerm objects or lists of terms can be added to enhance prompt clarity and domain-specific understanding.

Unlike general language understanding, domain vocabulary provides precise definitions that prevent misinterpretation of terms that may have different meanings across industries, regions, or organizational contexts. The class supports sophisticated multilingual environments through language-aware synonyms and translations, enabling AI assistants to understand and respond appropriately when users employ terminology in different languages or regional variants.

Parameters

term : str

The primary term or phrase being defined. Should be the canonical name used within your organization or domain. Can include multi-word phrases, technical terminology, product names, or specialized concepts that require explicit definition within your context.

definition : str

Precise definition of what this term means in your specific domain context. Should be clear, unambiguous, and focused on the operational meaning rather than general dictionary definitions. Include relevant scope, constraints, or contextual boundaries that distinguish this term’s usage in your domain.

synonyms : Optional[List[str]] = None

Alternative ways users might refer to this term, including colloquial expressions, abbreviations, industry variants, and multilingual alternatives. Supports language-aware formatting using "lang:synonym" or "locale:synonym" notation (e.g., "es:cuota de mercado", "de-AT:Marktanteil", "fr-CA:part de marché") for international contexts.

translations : Optional[Dict[str, str]] = None

A dictionary of direct translations of the primary term for different languages and locales. Keys should use standard language codes (ISO 639-1/639-2) (e.g., "es", "de", "fr", etc.) or locale codes (e.g., "es-MX", "de-AT", "fr-CA"). Values are the translated terms in the target language, maintaining semantic consistency across linguistic contexts.

Research Foundation

Domain Knowledge Anchoring Theory. Research in cognitive linguistics demonstrates that specialized domains develop unique terminologies that carry specific semantic loads different from general usage. By explicitly defining domain vocabulary, AI systems can maintain semantic consistency and avoid misinterpretation that occurs when general language models encounter specialized terminology.

Multilingual Semantic Consistency. Studies in cross-linguistic communication show that direct term-by-term translation often fails to capture domain-specific meanings that have evolved within particular linguistic communities. VocabularyTerm addresses this by enabling explicit definition of how terms should be interpreted across different languages while maintaining semantic fidelity to the original domain concept.

Professional Glossary Psychology. Research in professional communication demonstrates that shared terminology is foundational to effective domain expertise. By providing explicit vocabulary definitions, AI systems can participate more effectively in professional contexts where precise terminology usage is critical for accuracy, credibility, and operational effectiveness.

Contextual Disambiguation Framework. Linguistic research shows that many terms carry multiple meanings across different contexts, and successful communication requires explicit disambiguation. VocabularyTerm provides this disambiguation by establishing clear contextual boundaries for term usage within specific domains.

Integration Notes

  • Semantic Consistency: ensures AI maintains consistent understanding of specialized terminology throughout conversations
  • Multilingual Support: enables accurate interpretation across different languages and regional variants
  • Professional Standards: aligns AI communication with industry-specific terminology conventions
  • Context Boundaries: prevents misinterpretation by establishing clear domain-specific definitions
  • User Experience: improves communication effectiveness by recognizing diverse ways users express domain concepts
  • Organizational Knowledge: captures and standardizes institutional terminology for consistent AI interactions

The VocabularyTerm class provides essential infrastructure for building domain-aware AI systems that can communicate effectively within specialized contexts while maintaining semantic accuracy across multilingual and multicultural environments.

Using translations= vs synonyms= with language codes

Understanding the difference between translations= and language-coded synonyms= is important for effective multilingual vocabulary design.

SYNONYMS with language codes. Alternative expressions users might use.

import talk_box as tb

recognition_term = tb.VocabularyTerm(
    term="Market Penetration Rate",
    definition="Percentage of target market currently using our services.",
    synonyms=[
        "market share",           # English alternative
        "adoption rate",          # Another English way
        "es:cuota de mercado",    # How Spanish users might say it
        "de:Marktanteil",         # How German users might refer to it
        "fr:part de marché"       # How French users might express it
    ]
)

builder = (
    tb.PromptBuilder()
    .persona("international business consultant")
    .vocabulary(recognition_term)
)

print(recognition_term)
**Market Penetration Rate**: Percentage of target market currently using our services.
  (Also: market share, adoption rate, de:Marktanteil, es:cuota de mercado, fr:part de marché)

TRANSLATIONS. Official term names in different languages.

standardization_term = tb.VocabularyTerm(
    term="Market Penetration Rate",
    definition="Percentage of target market currently using our services.",
    synonyms=["market share", "adoption rate"],     # English alternatives only
    translations={
        "es": "Tasa de Penetración de Mercado",     # Official Spanish name
        "de": "Marktdurchdringungsrate",            # Official German name
        "fr": "Taux de Pénétration du Marché"       # Official French name
    }
)

builder = (
    tb.PromptBuilder()
    .persona("international business consultant")
    .vocabulary(standardization_term)
)

print(standardization_term)
**Market Penetration Rate**: Percentage of target market currently using our services.
  (Also: market share, adoption rate)
  [Translations: de:Marktdurchdringungsrate, es:Tasa de Penetración de Mercado, fr:Taux de Pénétration du Marché]

COMBINED. Both official translations and alternative expressions.

comprehensive_term = tb.VocabularyTerm(
    term="Customer Lifetime Value",
    definition="Total revenue expected from a customer relationship over time.",
    synonyms=[
        "CLV",                                      # Common abbreviation
        "lifetime revenue",                         # English alternative
        "es:valor del cliente",                     # Informal Spanish expression
        "de:Kundenwert",                            # Casual German way
        "fr:valeur client"                          # Shortened French expression
    ],
    translations={
        "es": "Valor de Vida del Cliente",          # Official Spanish translation
        "de": "Kundenlebenszeitwert",               # Official German translation
        "fr": "Valeur Vie Client"                   # Official French translation
    }
)

builder = (
    tb.PromptBuilder()
    .persona("international business consultant")
    .vocabulary(comprehensive_term)
)

print(builder)
You are a international business consultant.

DOMAIN VOCABULARY:
- **Customer Lifetime Value**: Total revenue expected from a customer relationship over time.
  [Translations: de:Kundenlebenszeitwert, es:Valor de Vida del Cliente, fr:Valeur Vie Client] (Also:
  CLV, lifetime revenue, de:Kundenwert, es:valor del cliente, fr:valeur client)

The output clearly shows the difference:

  • Translations appear as "[Translations: de:Marktdurchdringungsrate, es:Tasa de...]"
  • Synonyms appear as "(Also: market share, de:Marktanteil, es:cuota de mercado)"

Use synonyms= with language codes** when users might naturally refer to concepts using different languages, informal terms, or abbreviations. Use translations= when you need to establish official, standardized terminology across languages.

Examples


Defining single vocabulary terms

Let’s define a single term for a customer success context. A useful pattern is to generate a VocabularyTerm object and then introduce it into a PromptBuilder via its .vocabulary() method.

import talk_box as tb

# Single term for customer success domain
churn_term = tb.VocabularyTerm(
    term="Customer Churn",
    definition=(
        "The percentage of customers who stop using our service during a specific time period."
    ),
    synonyms=["attrition rate", "customer turnover", "subscription cancellation rate"]
)

# Use in prompt builder
builder = tb.PromptBuilder().vocabulary(churn_term)

print(builder)

DOMAIN VOCABULARY:
- **Customer Churn**: The percentage of customers who stop using our service during a specific time
  period. (Also: attrition rate, customer turnover, subscription cancellation rate)

Defining multiple vocabulary terms

You might have to define several VocabularyTerm objects to cover different aspects of your domain. For that, create a list of VocabularyTerm objects and then pass that list object to the .vocabulary() method of PromptBuilder.

This example shows how to define technical terminology for software development contexts using a list of VocabularyTerm objects.

tech_vocab = [
    tb.VocabularyTerm(
        term="Blue-Green Deployment",
        definition=(
            "Deployment strategy using two identical production environments where traffic "
            "is switched between them to enable zero-downtime releases."
        ),
        synonyms=[
            "blue green strategy", "dual environment deployment", "zero downtime deployment",
        ]
    ),
    tb.VocabularyTerm(
        term="Circuit Breaker Pattern",
        definition=(
            "Microservices resilience pattern that prevents cascading failures by monitoring "
            "service health and temporarily blocking requests to failing services"
        ),
        synonyms=[
            "circuit breaker", "failure isolation pattern", "resilience pattern",
        ]
    ),
    tb.VocabularyTerm(
        term="Service Mesh",
        definition=(
            "Infrastructure layer that handles service-to-service communication, security, "
            "and observability in microservices architectures."
        ),
        synonyms=[
            "mesh architecture", "service communication layer", "microservices mesh",
        ]
    )
]

builder = (
    tb.PromptBuilder()
    .persona("DevOps architect", "cloud infrastructure and microservices")
    .vocabulary(tech_vocab)
    .task_context("Design resilient microservices architecture")
)

print(builder)
You are a DevOps architect with expertise in cloud infrastructure and microservices.

TASK: Design resilient microservices architecture

DOMAIN VOCABULARY:
- **Blue-Green Deployment**: Deployment strategy using two identical production environments where
  traffic is switched between them to enable zero-downtime releases. (Also: blue green strategy,
  dual environment deployment, zero downtime deployment)
- **Circuit Breaker Pattern**: Microservices resilience pattern that prevents cascading failures by
  monitoring service health and temporarily blocking requests to failing services (Also: circuit
  breaker, failure isolation pattern, resilience pattern)
- **Service Mesh**: Infrastructure layer that handles service-to-service communication, security,
  and observability in microservices architectures. (Also: mesh architecture, service communication
  layer, microservices mesh)

Multilingual vocabulary items

We can mark pieces of vocabulary with language codes to indicate the language or locale for which a synonym applies. This enables precise multilingual support where users may refer to terminology in different languages or regional variants.

In this example, we create international vocabulary with language-aware synonyms for global operations of hotel management.

room_types = [
    tb.VocabularyTerm(
        term="Ocean View Room",
        definition="Premium rooms on floors 15-20 with direct Atlantic Ocean visibility.",
        synonyms=[
            "seaside room", "beach view", "waterfront suite",
            "es:habitación con vista al mar", "fr:chambre vue sur mer",
            "de:Meerblickzimmer", "pt-BR:quarto vista oceano"
        ]
    ),
    tb.VocabularyTerm(
        term="Concierge Level",
        definition=(
            "Exclusive access tier with dedicated concierge services and premium amenities."
        ),
        synonyms=[
            "VIP services", "premium tier", "exclusive access",
            "es:nivel concierge", "fr:niveau concierge", "de:Concierge-Service"
        ]
    )
]

builder = (
    tb.PromptBuilder()
    .persona("multilingual hotel booking assistant")
    .vocabulary(room_types)
)

print(builder)
You are a multilingual hotel booking assistant.

DOMAIN VOCABULARY:
- **Ocean View Room**: Premium rooms on floors 15-20 with direct Atlantic Ocean visibility. (Also:
  seaside room, beach view, waterfront suite, de:Meerblickzimmer, es:habitación con vista al mar,
  fr:chambre vue sur mer, pt-BR:quarto vista oceano)
- **Concierge Level**: Exclusive access tier with dedicated concierge services and premium
  amenities. (Also: VIP services, premium tier, exclusive access, de:Concierge-Service, es:nivel
  concierge, fr:niveau concierge)

Healthcare domain vocabulary

Here’s an example of defining medical and healthcare terminology with precision requirements.

healthcare_vocab = [
    tb.VocabularyTerm(
        term="Electronic Health Record",
        definition=(
            "Digital version of patient medical history maintained by healthcare providers, "
            "including diagnoses, medications, treatment plans, and test results."
        ),
        synonyms=[
            "EHR", "electronic medical record", "EMR", "digital health record",
            "es:historia clínica electrónica", "fr:dossier médical électronique",
            "de:elektronische Patientenakte"
        ]
    ),
    tb.VocabularyTerm(
        term="Clinical Decision Support",
        definition=(
            "Health information technology that provides healthcare professionals with "
            "patient-specific assessments and evidence-based treatment recommendations."
        ),
        synonyms=[
            "CDS", "decision support system", "clinical guidance system",
            "es:apoyo a decisiones clínicas", "fr:aide à la décision clinique",
            "de:klinische Entscheidungsunterstützung"
        ]
    ),
    tb.VocabularyTerm(
        term="Health Level Seven",
        definition=(
            "International standard for exchanging healthcare information between different "
            "healthcare systems and applications."
        ),
        synonyms=[
            "HL7", "healthcare interoperability standard", "medical data exchange protocol",
            "es:estándar de interoperabilidad sanitaria", "fr:norme interopérabilité santé",
            "de:Gesundheitsdatenstandard"
        ]
    )
]

builder = (
    tb.PromptBuilder()
    .persona("healthcare IT consultant", "medical informatics and system integration")
    .vocabulary(healthcare_vocab)
    .constraint("Maintain strict patient privacy and HIPAA compliance")
    .avoid_topics([
        "medical diagnosis", "treatment recommendations", "patient-specific medical advice"
    ])
)

print(builder)
You are a healthcare IT consultant with expertise in medical informatics and system integration.

CRITICAL REQUIREMENTS:
- Maintain strict patient privacy and HIPAA compliance

DOMAIN VOCABULARY:
- **Electronic Health Record**: Digital version of patient medical history maintained by healthcare
  providers, including diagnoses, medications, treatment plans, and test results. (Also: EHR,
  electronic medical record, EMR, digital health record, de:elektronische Patientenakte, es:historia
  clínica electrónica, fr:dossier médical électronique)
- **Clinical Decision Support**: Health information technology that provides healthcare
  professionals with patient-specific assessments and evidence-based treatment recommendations.
  (Also: CDS, decision support system, clinical guidance system, de:klinische
  Entscheidungsunterstützung, es:apoyo a decisiones clínicas, fr:aide à la décision clinique)
- **Health Level Seven**: International standard for exchanging healthcare information between
  different healthcare systems and applications. (Also: HL7, healthcare interoperability standard,
  medical data exchange protocol, de:Gesundheitsdatenstandard, es:estándar de interoperabilidad
  sanitaria, fr:norme interopérabilité santé)

ADDITIONAL CONSTRAINTS:
- IMPORTANT CONSTRAINT: You MUST NOT provide any information, advice, or discussion about medical
  diagnosis, treatment recommendations, or patient-specific medical advice. If asked about any of
  these topics, politely decline and redirect by saying something to the effect of 'I'm not able to
  help with that topic. Is there something else I can assist you with instead?' (adapt the language
  and phrasing to match the conversation's language and tone).