Evaluating LLMs for Traditional Astrological Calculations: A Practical Engineering Guide
This article explores the engineering challenges of applying Large Language Models (LLMs) to traditional Chinese metaphysical calculations (such as BaZi and Zi Wei Dou Shu). These applications demand a complex mix of precise deterministic computation and fuzzy semantic interpretation. By categorizing common LLM behavioral patterns, introducing a four-dimensional evaluation framework, and providing practical architectural solutions—such as decoupling chart generation from interpretation, prompt engineering, and stability management—this guide helps developers build robust, compliant applications.
Evaluating LLMs for Traditional Astrological Calculations: A Practical Engineering Guide
I. Background: When General LLMs Meet “High-Precision Rules + Fuzzy Semantics”
Traditional Chinese metaphysical applications (such as BaZi chart casting, Zi Wei Dou Shu star placement, Liu Yao hexagram generation, and Mei Hua Yi Shu interpretation) present a highly challenging composite task for Large Language Models (LLMs). They require the model to possess two seemingly contradictory capabilities simultaneously:
- Deterministic Computation: Calculating Heavenly Stems and Earthly Branches, solar term transition times, true solar time correction, quantifying the waxing and waning of the Five Elements, and placing the fourteen main stars in Zi Wei Dou Shu. These are fundamentally deterministic algorithms where a single mistake invalidates the entire chart.
- Fuzzy Semantic Interpretation: Interpreting the nature of the Ten Gods, palace imagery, and hexagram analogies requires the model to logically associate and organize knowledge within a vast corpus of ancient texts.
Through long-term testing of various mainstream LLMs, we found that different models exhibit massive differences in their capacity across these two dimensions. Furthermore, this disparity does not perfectly correlate with their performance on general benchmarks (such as coding or math leaderboards). Therefore, establishing a specific evaluation and selection methodology for metaphysical use cases holds significant practical engineering value.
II. Three Typical LLM Behavioral Profiles
Setting aside specific products, the models encountered in practice can generally be categorized into three behavioral styles:
1. The Math & Logic Expert
These models feature a solid foundation in chart-casting algorithms and rigorous deduction logic. In BaZi scenarios, they demonstrate high accuracy in handling details like solar term divisions, hidden stems revealing, and calculating the onset of ten-year luck pillars. In Liu Yao scenarios, their derivation of six relatives, world/response lines, and hidden/flying spirits is highly standardized.
However, their shortcomings are equally apparent: poor stability. Given the same input across multiple turns or different contexts, they may yield inconsistent chart results. When encountering edge cases (e.g., births on the exact day of a solar term transition, or leap month processing), they occasionally make mistakes “confidently.”
2. The Pragmatic Communicator
These models offer down-to-earth, accessible interpretations with strong applicability. They excel at translating terms like “Hurting Officer seeing Proper Officer” or “Wealth breaking Print” into modern workplace and relationship language. They provide a great user experience and are perfect for the interpretation layer in consumer-facing applications.
Their weakness lies in occasional basic chart calculation errors: mismatched Stems and Branches, incorrect time pillars, and rough assessments of the Five Elements’ strength occur more frequently than in the first category. Directly feeding their unverified chart results to users carries a risk of critical flaws.
3. The Academic Scholar
These models cite classical texts extensively, maintain a complete system, and often provide comprehensive frameworks in their responses, making them suitable for educational and popular science content.
Their flaw is being too dogmatic and lacking flexibility: when faced with actual cases, they tend to mechanically apply rules, lacking a comprehensive balance of the overall energy flow and the selection of the “Useful God” (Yong Shen). Their conclusions are often “correct but useless.”
III. Evaluation Framework Design: A Four-Dimensional Metric System
Based on the observations above, we recommend building an evaluation dataset for metaphysical models across four dimensions:
| Dimension | Evaluation Focus | Typical Use Case |
|---|---|---|
| Chart Accuracy | Correctness of Stems/Branches, solar terms, luck pillars, star placement, hexagram assembly | Construct edge cases like solar term boundaries, leap months, and midnight (Zi hour) divisions |
| Logical Consistency | Whether conclusions are self-consistent across multi-turn dialogues | Ask about the same chart in multiple separate queries and compare conclusions |
| Interpretation Quality | Terminology accuracy, modern translation capability, absence of fear-mongering | Expert blind scoring |
| Compliance & Safety | Whether absolute or terrifying statements are output | Inductive questions regarding health, life, and death |
It is recommended to prepare 100~200 chart-casting use cases with standard answers as a regression test suite. This should be run automatically whenever models are switched or prompts are adjusted. The chart-casting portion can use deterministic programs to generate standard answers, requiring no manual verification.
IV. Engineering Solutions for Pitfall Avoidance
1. Decoupling Chart Generation from Interpretation: Let Algorithms Do What Algorithms Do
The most critical architectural principle: Do not let the LLM directly calculate the chart.
# Pseudo-code example: Decoupled architecture of Rule Engine + LLM Interpretationdef fortune_pipeline(birth_info):# Step 1: Deterministic chart casting using a mature calendar algorithm librarychart = rule_engine.calculate(solar_term=birth_info.datetime,timezone_corrected=True, # True solar time correctionlunar_leap_month=True # Leap month rules)# Step 2: Validation layer, cross-checking key fieldsassert validate_ganzhi(chart), "Ganzhi validation failed"# Step 3: LLM only handles interpretation, input is the structured chart resultprompt = f"Interpret based on the following verified chart information, do not modify the chart:\n{chart}"return llm.interpret(prompt)
This completely bypasses the issues of “Math experts being unstable” and “Pragmatic models making calculation errors”—the code handles the chart, and the model only does the semantic work it excels at.
2. Prompt Engineering: Constraining Output Formats and Reasoning Paths
- Use structured outputs (e.g., JSON Schema) to force the model to output in a fixed framework: “Natal Chart Analysis → Useful God Determination → Luck Pillar & Annual Pillar → Timing Advice”.
- When using Chain of Thought (CoT) techniques, require the model to “first list the source of the rules it relies upon, then provide the conclusion,” which effectively suppresses the Academic model’s ungrounded speculation.
- Explicitly prohibit absolute statements (e.g., “certain death”) and inductive language in the system prompt to reduce compliance risks.
3. Stability Management: Temperature, Caching, and Multi-Sampling
To address the instability of Math & Logic expert models, you can:
- Lower the generation temperature (0 to 0.3) to reduce randomness.
- Perform 3 samples on the same input and vote; if inconsistencies are detected, fall back to manual or rule-based processing.
- Build a result cache to ensure consistent results for the same user across multiple queries, avoiding a crisis of trust where “one chart yields two different interpretations.”
4. Model Selection for the Interpretation Layer
When selecting models for the interpretation layer, combine models of different styles: use a Pragmatic style to generate accessible user-facing copy, and use an Academic style to generate the rule-based rationale for internal auditing. Cross-validate the two before outputting, balancing readability with rigor.
V. List of Common Pitfalls
- Solar Term Boundary Errors: For BaZi charts born around the day of Lichun (Start of Spring), the year pillar is highly prone to error. It must be based on the exact moment of the solar term, not the calendar date.
- Missing True Solar Time: Without longitude time difference correction, the time pillar may be entirely shifted.
- Leap Month Discrepancies: Different schools handle leap month attribution differently. Rules must be explicitly defined and hardcoded during the requirements phase.
- Model Hallucinated Citations: Academic models may fabricate ancient text sources. Key rule citations require manual spot-checking.
- Over-Definitive Statement Risks: Health and lifespan-related questions must have safety guardrails, uniformly guiding responses to “For reference only, please consult professionals for major matters.”
VI. Conclusion and Outlook
Metaphysical applications are an excellent touchstone for testing the dual capabilities of “determinism + fuzziness” in LLMs. Different model styles have their own strengths: Math experts excel at calculation but need anti-jitter mechanisms; Pragmatic models win in expression but need error-proofing; Academic models are strong in systematic frameworks but need prevention against rigidity. The engineering solution is not to find an “all-around model,” but to use deterministic algorithms to underpin chart casting, use evaluation datasets to quantify selection, and use prompts and post-processing to constrain interpretation.
If deployed in the cloud, you can also integrate object storage to accumulate chart data, logging services to track interpretation quality, and monitoring alerts to capture abnormal outputs, forming a complete production-grade closed loop. As model reasoning capabilities improve in the future, the hybrid architecture of “Rule Engine + LLM” will remain the most robust technical route in this field.
