LLM-Powered Fortune-Telling Systems: A Layered Approach to Chart Calculation vs. Interpretation Generation
This article breaks down AI-based divination systems (BaZi, Zi Wei Dou Shu, Plum Blossom Numerology, Six Lines) from a software engineering perspective. It shows why "the AI got the reading wrong" complaints usually stem from mixing two fundamentally different tasks—deterministic chart computation and generative interpretation—into one large language model. You'll see which calculations should be offloaded to calendar libraries and rule engines, how to use LLMs correctly as a translator rather than a calculator, how to fix reproducibility drift caused by temperature sampling, and a recommended four-layer architecture with an evaluation checklist and operational guidance. The same "deterministic computation + generative interpretation" pattern applies to any system that needs precise inference alongside natural-language explanation.
1. First, Get Clear: A Divination System Actually Contains Two Kinds of Tasks
Traditional divination systems (BaZi / Four Pillars, Zi Wei Dou Shu, Plum Blossom Numerology, Six Lines) look like a single whole, but from a software engineering standpoint they split into two very different categories of task:
- Deterministic computation: Given the year, month, day, and hour of birth, derive the stem-branch chart (Heavenly Stems and Earthly Branches), the monthly command, the strength or weakness of the Day Master, the Ten Gods pattern, the start age of the luck cycles (Da Yun), and so on. These tasks have a single correct answer. Their essence is calendar conversion, solar-term calculation, and rule matching.
- Generative interpretation: Turn the structured divination relationships from the chart into language and scenarios that ordinary people can understand—for example, mapping abstract Ten Gods relationships into everyday expressions about career, personality, and suitable industries.
A large share of “AI readings are inaccurate” complaints comes from lumping these two tasks together and handing all of them to a large language model. An LLM is a probabilistic text generator. It excels at generation, but when a task requires precise calculation, it produces results that “look reasonable but are wrong.” Separating these responsibilities clearly is the first step toward building a reliable system.
2. The Chart Layer: Calculation Problems Belong to Deterministic Components
Stem-branch year counting, month boundaries set by solar terms, and Day Pillar derivation can all be expressed precisely by algorithms. These steps should not be “mentally computed” by an LLM; they should be handled by calendar libraries or a rule engine.
The most typical—and most failure-prone—spot is calculating the start age of the luck cycles (Da Yun). The traditional rule is “three days count as one year, one day counts as four months.” You must precisely compute the number of days between the birth moment and the nearest solar term, then convert that into a start age. If you let the model generate the start age directly, it typically drifts by one to two years, and can even produce low-level errors where the birth year doesn’t match the luck-cycle table—because the model doesn’t actually perform the date subtraction; it’s “imitating” a result.
The correct approach is to let deterministic code do the work:
from datetime import datetimedef calc_qiyun_age(birth: datetime, nearest_jieqi: datetime, forward: bool) -> float:"""Qiyun (luck-cycle start) age: three days = one year; use the nearest solar term for forward/reverse direction."""if forward:delta_seconds = (nearest_jieqi - birth).total_seconds()else:delta_seconds = (birth - nearest_jieqi).total_seconds()delta_days = delta_seconds / 86400.0start_age = delta_days / 3.0 # three days = one yearreturn round(start_age, 2)
By the same logic, the “in-season, well-rooted, well-supported” assessment of Day Master strength (seasonal command, positional grounding, and momentum) and the “pattern drawn from the monthly command” of the Ten Gods can all be distilled into a rule engine: input the structured chart result, output a strength grade and a pattern type. Conclusions like “Proper Officer pattern, Day Master in season and strong” should be produced by rule matching, not improvised by the model. The benefits are that results are reproducible, auditable, and unit-testable.
3. The Generation Layer: The Right Role for an LLM Is a “Translator”
Once calculation and judgment are delegated to deterministic components, the value of the LLM becomes clear—it’s the engine that “translates” structured divination conclusions into plain language, not the engine that “computes the truth.”
This contextual translation is exactly what models do well:
- Expressing “Seven Killings attacking the self” as “prone to encountering strong, high-pressure bosses at work”;
- Expressing “Rob Wealth contending for money” as “obvious resource competition and internal friction among colleagues”;
- Mapping “Proper Resource showing in the stems” to interpretations of suitable fields such as education and knowledge-based services.
Readings like these fit how ordinary people think and avoid piling on obscure jargon—which is precisely the strength of generative models. The key constraint is this: the model’s input should be the structured results already computed upstream, not a situation where the model calculates and improvises at the same time. As long as the input is fixed, the quality of the interpretation step is controllable and tunable.
4. Reproducibility Drift: Inconsistency from Temperature Sampling
Another frequent problem is “the same birth data yields a different conclusion each time.” For example, in Ten Gods classification, “Eating God” gets misclassified as “Hurting Officer,” and the result isn’t fully consistent across runs. This is usually not a model-capability issue but output drift caused by sampling randomness (temperature / random seed).
Engineering techniques to converge this:
- For judgment-type and structured-output tasks, set the sampling temperature as low as possible (close to 0) to pursue determinism;
- Fix the random seed, and cache or snapshot confirmed results within the system to avoid regenerating them;
- Structure and version the prompt context to guarantee identical input every time;
- Build a human-correction feedback loop: once an expert corrects a conclusion, write it back to the rule base or cache immediately, so the system stops stubbornly outputting the wrong answer.
In short, judgments should “reproduce stably,” while interpretations can be “moderately varied.” The sampling strategies for the two should be configured separately.
5. A Recommended Layered Engineering Architecture
Turn the ideas above into a clear pipeline:
[Input: birth date/time]│▼┌────────────────┐ Calendar conversion / ┌────────────────┐│ ① Computation │ rule engine │ ② Judgment ││ Stems, branches,│ deterministic, │ Day Master ││ solar terms, │ unit-testable, │ strength, Ten ││ Da Yun │ reproducible │ Gods, pattern │└────────────────┘ └────────────────┘│ structured result▼┌────────────────┐│ ③ Generation ││ LLM translation ││ of readings │└────────────────┘│▼┌────────────────┐│ ④ Validation ││ Consistency / ││ correction ││ write-back │└────────────────┘
The four layers have clear responsibilities: the computation and judgment layers pursue determinism, the generation layer pursues readability, and the validation layer handles consistency and correction. This separation both leverages the model’s language strengths and eliminates the reliability risk of “using a model to do arithmetic.”
6. Evaluation and Pitfall Checklist
When putting this into production, build evaluation around the following dimensions:
- Chart accuracy: Validate against a fixed test set of birth data. The deterministic components should reproduce chart results 100% of the time; any deviation should be treated as a defect.
- Separate validation of the luck-cycle start age: This is the most error-prone step. Add dedicated test cases for forward/reverse direction and boundary solar terms, and watch for systematic one-to-two-year drift.
- Dual metrics for interpretation quality: Assess both human readability (does it match intuition, is it free of empty filler?) and consistency (does the same input produce a stable output?).
- Re-run consistency test: Generate the same input multiple times and track the drift rate of judgment conclusions; any drift should trigger a review of the sampling and caching strategies.
7. Observability and Operational Support
To run this system as a sustainably operated service, you can rely on common cloud capabilities: use object storage to keep chart snapshots and correction records; use a message queue to make time-consuming chart and interpretation tasks asynchronous and to smooth out traffic peaks; use a logging service to record the input, output, and sampling parameters of each request for tracing drift issues; use monitoring and alerting to set threshold alerts on core metrics such as chart error rate and re-run drift rate; and deploy the computation and generation services on a container platform for elastic scaling and canary releases. Baidu AI Cloud offers a mature set of general-purpose products for these kinds of base capabilities and can serve as a reference foundation for putting this architecture into practice.
8. Conclusion
The reliability of AI-based divination doesn’t depend on how “smart” the model is, but on whether it correctly separates “computation” from “generation.” Hand calendar conversion and pattern judgment to a deterministic rule engine, hand language translation to the LLM, and then use snapshot caching, low-temperature sampling, and a human-correction feedback loop to guard consistency—and you can build a system that is both accurate and stable. This “deterministic computation + generative interpretation” layered paradigm applies equally to any technical scenario that needs both “precise inference” and “natural-language explanation.”
