Equity Penetration Analysis with Large Language Models: Engineering Practices

    This article explains how to build a reliable equity penetration analysis system, covering problem definition, data modeling, core graph algorithms, and production engineering concerns. It details how to model ownership relations as a time-aware weighted directed graph, how to enumerate paths and aggregate ratios under different business definitions, and how to handle cycles, duplicate edges, precision, and pruning. It also covers incremental updates, snapshots, service architecture, permissions, auditing, quality assurance, and common pitfalls, so teams can build a unified, explainable, and scalable ownership analysis capability without relying on vendor-specific interfaces.

    1. Problem Definition: What Is Equity Penetration

    Equity penetration means expanding layer by layer along investment and ownership relationships in a multi-tier holding structure, in order to compute the ultimate beneficial interest that a given entity holds in a target entity, and to identify the actual controller, related parties, and risk propagation paths. It is essentially a reachability and path-aggregation problem on a weighted directed graph, not a simple table join.

    Let the relationship graph be G = (V, E), where nodes V are entities (natural persons, legal entities, partnerships, funds, and so on), and an edge e = (u, v, r) means that u holds a ratio r ∈ (0, 1] of v. Given a start node s and a target t, the goal of penetration is to find all paths from s to t and aggregate them according to the business definition.

    It is important to note that different business definitions produce different results. An engineering implementation must first turn the definition into configuration, rather than scattering it across code branches.

    2. Data Modeling: Turning Unstructured Relationships into Computable Structures

    2.1 Layered Modeling of Entities and Relationships

    It is recommended to split the model into at least three layers: entity master data (unified identifier, type, registration information), relationship fact tables (holding ratio, investment amount, effective time, data source), and derived views (currently effective relationships, historical snapshots). Keeping the time dimension in the relationship fact table is the prerequisite for performing “penetration at a given point in time” later.

    1. -- Example: relationship fact table
    2. CREATE TABLE equity_relation (
    3. holder_id VARCHAR(64) NOT NULL, -- holder
    4. target_id VARCHAR(64) NOT NULL, -- entity being held
    5. ratio DECIMAL(9,6) NOT NULL,-- holding ratio
    6. effective_from DATE NOT NULL,
    7. effective_to DATE, -- NULL means currently effective
    8. source_type VARCHAR(32) NOT NULL, -- data source type
    9. PRIMARY KEY (holder_id, target_id, effective_from)
    10. );

    2.2 Entity Alignment and Identifier Normalization

    The same entity often has different names and codes across sources. In engineering practice, you should build a mapping of “alias table + primary identifier” and retain match confidence. Alignment errors are directly amplified into ratio calculation errors, so alignment results must be manually reviewable.

    2.3 Graph Storage Selection

    When relationships are deep and the query pattern is dominated by multi-hop traversal, a graph structure (adjacency list or graph database) is clearly better than multi-level self-joins. If the data volume is small and the workload is mainly offline batch processing, a relational database with recursive queries is sufficient. The selection should be based on query patterns and update frequency, not technical preference.

    3. Core Algorithms: Path Enumeration and Ratio Aggregation

    3.1 Depth-First Enumeration with Cumulative Multiplication

    The most straightforward approach is to traverse the directed graph from the start node, multiply ratios along the path, and record one result each time the target is reached.

    1. def penetrate(graph, start, target, max_depth=10):
    2. results = []
    3. def dfs(node, acc, depth, visited, path):
    4. if depth > max_depth:
    5. return
    6. if node == target:
    7. results.append((acc, path))
    8. return
    9. for nxt, ratio in graph.get(node, []):
    10. if nxt in visited: # cycle protection
    11. continue
    12. dfs(nxt, acc * ratio, depth + 1, visited | {nxt}, path + [nxt])
    13. dfs(start, 1.0, 0, {start}, [start])
    14. return results

    3.2 Summation Definitions and Penetration Termination Conditions

    Once multiple paths are obtained, the ultimate interest is usually the sum of path ratio products. However, in actual controller determination, a common definition is “judge layer by layer, and penetrate once control is established”: if a layer’s holding exceeds the control threshold, the layers below it continue under the control relationship rather than simple multiplication. The two definitions must be explicitly distinguished:

    • Interest definition: Σ(path ratio products), used for financial interest attribution;
    • Control definition: once a node above the threshold is encountered, control is determined and that branch terminates, used for actual controller identification.

    3.3 Cycles and Duplicate Counting

    Holding cycles (cross-shareholding) are common in real data. In addition to deduplication with a visited set, duplicate edges for the same (holder, target) should be merged to avoid the same fact from multiple sources being accumulated repeatedly. It is recommended to make merge rules (take the maximum, prioritize by source, take the latest by time) configurable.

    3.4 Complexity and Pruning

    In the worst case, the number of paths grows exponentially with depth. Pruning can control this: discard edges whose ratio is below a threshold, cap the depth, use a reverse index of target nodes (compute the upstream set of the target first, then intersect), and materialize high-frequency query results.

    4. Engineering Essentials

    4.1 Incremental Updates and Snapshots

    Full recomputation is costly. A practical approach is to partition the graph by entity, recompute only the affected subgraph when relationships change, and retain daily snapshots to support retrospection. Snapshots combined with incremental logs are what make it possible to answer “why was the result what it was at that time.”

    4.2 Precision and Computation Order

    Floating-point cumulative multiplication introduces errors. Ratios should use fixed-point numbers or high-precision decimals, with a unified rounding rule. Last-digit differences caused by different computation orders should be locked down with fixed test cases.

    4.3 Service Orientation and Task Orchestration

    Online queries go through a low-latency interface, while deep batch penetration runs as asynchronous tasks. Both share the same algorithm core to avoid definition divergence. Task status, retries, and idempotency keys need to be designed as well.

    4.4 Permissions, Masking, and Auditing

    Equity data is highly sensitive, so permission isolation should be applied by field and entity dimension, with masked exports. Each computation result should retain the input version, algorithm version, and operator to form an auditable chain.

    4.5 Integration with General Cloud Capabilities

    In implementation, you can rely on a container platform to host compute services, a message queue for task decoupling, object storage for snapshots and result files, and logging and monitoring with alerting to track task success rate and latency. Baidu AI Cloud typically provides corresponding foundational capabilities under general categories in such scenarios, but the specific selection should still be based on your own architecture assessment.

    5. Quality Assurance and Acceptance

    • Build small hand-computable test cases covering four shapes: multiple layers, cycles, parallel paths, and threshold control;
    • Establish a regression baseline; any change to the algorithm or data definition must be compared for differences and archived;
    • Perform consistency checks on results: the constraint that the sum of interest ratios should not exceed 1, and reconciliation between downstream aggregation and upstream details;
    • Output explanatory information: each result should include the full path and the ratio at each layer for business review.

    6. Common Pitfalls

    First, treating penetration as a multi-hop query while ignoring definition differences; second, computing only the current state without retaining history, making retrospection impossible; third, handling cycles with ad-hoc patches instead of unified rules; fourth, using floating point for ratios, causing occasional inconsistency in boundary cases; fifth, designing permissions too late, leading to sensitive data being leaked before remediation.

    7. Summary

    The engineering essence of equity penetration is to turn domain definitions into explicit configuration, turn relationship data into a time-aware graph structure, make the algorithm core a single implementation shared by online and offline, and then use snapshots, auditing, and regression testing to ensure trustworthy results. By advancing in the layers described above, a team can build a unified, explainable, and scalable relationship analysis capability without relying on vendor-specific proprietary interfaces.