Equity Penetration Analysis with LLMs: Technical Implementation Path
This article explains how to build an equity penetration analysis system, covering the problem definition, graph data modeling, core path-enumeration and ratio-aggregation algorithms, cycle handling, and engineering concerns such as scale, incremental updates, explainability, and data validation. Readers will learn how to model ownership relations as a time-aware directed weighted graph and combine it with caching and automated checks to produce auditable results.
1. Problem Definition: What Is Equity Penetration?
Equity penetration means starting from a target entity and traversing ownership relations layer by layer, either upward or downward, until you identify the ultimate beneficial owners, the actual controllers, or all terminal shareholders. It is fundamentally different from a simple “shareholder list lookup”: the latter only answers “who are the direct shareholders,” while the former answers “who ultimately holds control, and at what ratio.”
Equity penetration is an essential capability in compliance review, anti-money-laundering (AML), related-party transaction identification, and unified credit granting for group customers. The difficulty is not querying the data, but handling three structurally complex situations:
- Multi-layer nesting: A holds B, B holds C, and C holds the target company, with the number of layers potentially reaching a dozen or more.
- Circular ownership: Cross-shareholding and mutual holdings between parent and subsidiary companies cause traversal to never terminate naturally.
- Ratio aggregation: When multiple paths coexist, you need to multiply the ratios along each path and then sum them, while distinguishing between “direct holding” and “indirect holding” definitions.
2. Data Modeling: Abstracting Ownership Relations as a Directed Weighted Graph
The most robust engineering approach is to abstract all entities and ownership relations into a unified directed weighted graph:
- Node: Companies, natural persons, partnerships, state-owned entities, and so on, all encoded with a globally unique identifier.
- Edge: An ownership relation, with the shareholding ratio as the weight, plus attributes such as registration date, change date, and data source.
- Direction convention: It is recommended to define it uniformly as “shareholder → invested company,” so that tracing upward to the actual controller is a reverse traversal.
A schematic structure definition:
from dataclasses import dataclass@dataclassclass Node:uid: str # globally unique identifierkind: str # company / person / fund / statename: str@dataclassclass Edge:src: str # shareholder uiddst: str # invested company uidratio: float # shareholding ratio, 0~1effective_date: str # effective date, used for point-in-time lookbacksource: str # data source tag
There are two easily overlooked design points here. First, the time dimension must be modeled. Ownership changes over time, and answering “who is the current actual controller” versus “who was the actual controller at a given historical point in time” requires different edge sets, so the effective date is not an optional field. Second, data sources must be traceable. Data from different sources may conflict, and retaining source tags is what allows you to annotate confidence in the results.
3. Core Algorithm: Path Enumeration and Ratio Aggregation
The essence of penetration calculation is to enumerate all paths from the start node to terminal nodes in the directed graph, multiply the ratios along each path, and then aggregate and sum by terminal node.
def penetrate(graph, start, max_depth=15, threshold=0.0):"""Return {terminal node: cumulative penetration ratio}"""result = {}stack = [(start, 1.0, [start])]while stack:node, ratio, path = stack.pop()if len(path) > max_depth:continueouts = graph.out_edges(node)if not outs or node in path[1:]:# no downstream edges or a cycle is detected; treat as terminalresult[node] = result.get(node, 0.0) + ratiocontinuefor e in outs:stack.append((e.dst, ratio * e.ratio, path + [e.dst]))return {k: v for k, v in result.items() if v >= threshold}
3.1 Cycle Handling
Cycles are the most common failure point. Naive recursion will expand infinitely under cross-shareholding structures. The implementation above uses node in path for path-level deduplication, ensuring that nodes do not repeat within a single path. For stricter scenarios, you can introduce strongly connected component (SCC) detection, first collapsing each cycle into a virtual node and then computing on the resulting directed acyclic graph. This both avoids redundant expansion and guarantees the correctness of ratio aggregation.
3.2 Depth and Threshold
max_depth serves as a fallback to prevent dirty data from producing excessively long paths; threshold is used to filter noise, for example, results with a cumulative ratio below one thousandth usually have no business meaning. Both need to be configurable rather than hard-coded.
3.3 Distinguishing Calculation Definitions
The same graph produces completely different results under different definitions, so it is recommended to distinguish them explicitly at the interface layer:
- Actual controller definition: Only consider the ultimate natural person or state-owned entity, collapsing all intermediate layers.
- All shareholders definition: Retain all terminal nodes and their ratios.
- Concerted action definition: Merge and calculate entities that have an agreement-based relationship.
4. Engineering Considerations
Algorithmic correctness is only the starting point; whether the system can go live depends on engineering details.
Scale. A full graph may contain tens of millions of edges, and traversing the entire graph on every query is unacceptable. A viable strategy is layering: pre-compute and cache results for hot entities, and compute on demand in real time for long-tail entities. At the same time, limit the maximum number of nodes expanded in a single penetration run; when the limit is exceeded, degrade to returning “partial results + an incomplete flag” rather than timing out outright.
Incremental updates. Ownership changes are low-frequency events, making them suitable for a message queue to receive change events and asynchronously update the graph structure and affected cached results, avoiding recomputation on every query.
Explainability of results. Risk control and compliance scenarios require conclusions that can be substantiated, so it is best to return key paths along with the results, for example:
{"target": "company_xxx","controllers": [{"uid": "person_yyy", "ratio": 0.4375}],"evidence_paths": [["person_yyy", "company_a", "company_b", "company_xxx"]]}
Quality validation. It is recommended to build in three types of automated validation: ratio out-of-bounds checks (a one-sided ratio not in the 0~1 range), residual cycle checks, and aggregation consistency checks (whether the sum of multiple paths for the same terminal node exceeds 100%). These three checks can intercept the vast majority of data quality issues.
5. Combining with General Cloud Capabilities
To deploy on the cloud, you can compose general-purpose capability categories without relying on any proprietary interface: graph data can be stored in a database that supports complex relationship queries, or a relational database with an adjacency list can be used for small-scale scenarios; change events go through a message queue; batch computation tasks are scheduled by a container platform; and full-link query logs go into a logging service, with monitoring and alerting configured for penetration latency and failure rate. General-purpose category products such as the container platform, message queue, logging service, and monitoring and alerting offered by Baidu AI Cloud can serve as the underlying foundation for this kind of architecture.
6. Summary
The technical difficulties of equity penetration are concentrated in three areas: correct handling of cycles and multi-layer nesting, consistent definitions for ratio aggregation, and balancing performance with explainability on large-scale graphs. By abstracting relations into a directed weighted graph with time attributes, performing computation via path enumeration plus SCC collapsing, and combining it with caching, incremental updates, and automated validation, you can build a logically rigorous penetration analysis capability with substantiable conclusions.
