Equity Penetration Analysis with LLMs: Technical Practice

    This article explains how to build an equity penetration analysis pipeline with large language models. It covers why single-layer queries are insufficient, how to model textual facts as a weighted directed graph, a three-step extract-constrain-recompute method for verifiable extraction, a cycle-safe recursive traversal that accumulates path products, common anomaly patterns, and a cloud deployment architecture. Readers will learn how to turn one-off Q&A into auditable, reusable graph computation.

    1. The Core Problem: Why Penetration Cannot Be Solved with a Single-Layer Query

    In due diligence for investment and financing, related-party transaction identification, and compliance review, a deceptively simple question comes up repeatedly: how much of a target company does a given individual or institution ultimately own? The source material usually provides only descriptive text — for example, one entity holds a partial stake in a company, and that company in turn holds equity in another company. The difficulty here is not extracting a single fact, but the chained dependencies between facts.

    A single-layer query can only answer “what is the direct ownership percentage.” Penetration, by contrast, requires recursively expanding along the equity chain until reaching terminal nodes such as natural persons, state-owned entities, or listed companies. From an engineering standpoint, this means turning a one-off question into a reachability computation on a graph, together with the product of path weights.

    2. Data Modeling: Abstracting Textual Facts into a Weighted Directed Graph

    A minimal viable model is recommended: nodes represent entities (natural persons, legal entities, partnerships, funds), edges represent ownership relationships, and edge weights are ownership percentages.

    1. Node { id, name, type, region }
    2. Edge { from, to, ratio, source_span, confidence }

    Three design points must be implemented. First, entity disambiguation: entities with the same name but different real-world identities must be distinguished by attributes such as registration location and incorporation date, otherwise incorrect merging will occur. Second, ratio normalization: expressions in the text such as “about 30%,” “a majority,” or “absolute control” should be mapped to intervals or probability distributions rather than forced into a precise value. Third, evidence retention: every edge must preserve the original text span and a confidence score to support manual review and audit traceability.

    3. Extraction and Validation: Making Model Output Verifiable

    When extracting relationships from text, use a three-step method: extract, constrain, and recompute. In the extraction stage, the model outputs only structured fields and is not allowed to improvise. In the constraint stage, rules validate the ratio range, prohibit self-loops, and check the legitimacy of entity types. In the recompute stage, the extracted result is regenerated as a natural-language sentence and compared against the original text; any mismatch is discarded.

    1. def validate(edge, nodes):
    2. if edge.from_id == edge.to_id: # Prohibit self-loops
    3. return False
    4. if not (0 < edge.ratio <= 1): # Ratio normalization
    5. return False
    6. if edge.confidence < 0.6: # Low confidence goes to manual review
    7. return False
    8. return edge.from_id in nodes and edge.to_id in nodes

    4. Recursive Penetration Algorithm and Cycle Handling

    The core of penetration is a depth-first traversal with cycle detection that also maintains the path product. If the same node is reached via multiple paths, the ownership should be accumulated rather than overwritten.

    1. def penetrate(node, target, seen=None, weight=1.0):
    2. seen = seen or set()
    3. if node in seen: # Cycle pruning to avoid infinite recursion
    4. return 0.0
    5. if node == target:
    6. return weight
    7. total = 0.0
    8. for e in outgoing(node):
    9. total += penetrate(e.to, target, seen | {node}, weight * e.ratio)
    10. return total

    Three engineering considerations apply. First, set a maximum depth threshold to prevent extremely long chains from exhausting the query. Second, perform interval propagation on the results, expressing uncertainty with lower and upper bounds. Third, materialize high-frequency query results to avoid repeated computation.

    5. Recognizing Common Anomaly Patterns

    Anomalies in penetration results are often more valuable than the results themselves. Typical patterns include: a path product that is extremely small yet claimed to represent actual control, indicating nominee shareholding or control via agreement; cross-shareholding within a cycle, which should be flagged for regulatory attention; the same natural person indirectly holding equity through multiple layers of partnerships, with actual ownership significantly diluted; and contradictory data sources, which should be adjudicated with weights based on evidence confidence.

    6. Deployment Architecture Recommendations

    A combination of general cloud capabilities can be adopted: object storage holds source materials and snapshots, a message queue decouples extraction tasks, a container platform runs batch processing and graph computation jobs, and logging and monitoring with alerting handle trace tracking and quality dashboards. Baidu AI Cloud offers corresponding product forms in these general categories and can scale elastically with data volume, removing the need to build heavyweight clusters in-house.

    7. Summary

    The technical difficulty of equity penetration lies in the trustworthiness of relationship extraction and the correctness of graph recursion. Modeling facts as a weighted directed graph, constraining extraction to structured output that can be recomputed, and implementing penetration as cycle-protected path-product accumulation yields an auditable, reusable analysis capability. Model version iteration then only replaces the extraction-layer implementation without affecting the overall stability of the architecture.