Engineering Equity Look-through Analysis with Large Language Models
This article presents an engineering approach to equity look-through analysis, the recursive traversal and aggregation of ownership relationships across a directed graph. It covers a practical data model using entity and stake edge tables with as-of dates and fixed-point ratios, traversal algorithms that handle cycles and multi-path aggregation, and the distinction between summing and taking the maximum ratio. It also discusses cost control when using large language models for information extraction, a layered deployment architecture, and a quality validation checklist for production use.
1. Problem Definition: What Is Equity Look-through
Equity look-through means expanding ownership relationships layer by layer, either downward or upward, until a termination condition is met. The result is a set of effective control relationships and a summary of aggregate equity ratios. Fundamentally, this is a recursive traversal and aggregation problem on a directed graph, not a simple multi-table join.
Let the set of companies be the node set V, and let the ownership relationships be the directed edge set E, where the edge weight w(u→v) represents the capital contribution ratio that u holds in v. Look-through analysis addresses three types of questions:
- Reachability: starting from a source node s, which nodes are ultimately reachable;
- Path aggregation: when multiple paths coexist, how the combined equity ratio is calculated;
- Termination: when to stop expanding (upon reaching a natural person, a listed company, a state-owned entity, or a fixed number of layers).
2. Data Model Design
A robust model is the prerequisite for any analysis. It is recommended to abstract relationships into “entity—relationship—entity” triples rather than writing shareholder names directly as string columns.
-- Entity table: unifies legal entities, natural persons, partnerships, and other typesCREATE TABLE entity (entity_id BIGINT PRIMARY KEY,std_name VARCHAR(256), -- standardized nameentity_type SMALLINT, -- 1 legal entity, 2 natural person, 3 partnership, 4 otherregion_code VARCHAR(16),is_listed BOOLEAN);-- Stake edge table: one edge represents one capital contributionCREATE TABLE stake_edge (from_id BIGINT NOT NULL, -- shareholderto_id BIGINT NOT NULL, -- invested companyratio DECIMAL(9,6), -- direct holding ratio, 0~1amount DECIMAL(20,2), -- subscribed/paid-in amountas_of_date DATE, -- data baseline datesource_code SMALLINT, -- source identifier for traceabilityPRIMARY KEY (from_id, to_id, as_of_date));
Three easily overlooked design points: first, the data baseline date must be retained, because ownership structures change over time and a missing time dimension makes conclusions impossible to reproduce; second, use fixed-point decimals rather than floating point for ratio fields to avoid accumulated errors after repeated multiplication; third, keep a source identifier for each edge to facilitate auditing and error correction.
3. Look-through Algorithm: Recursion, Cycles, and Deduplication
The most straightforward implementation is depth-first recursion, but real-world data almost inevitably contains two kinds of “dirty structures”: cycles formed by cross-shareholding, and exponential expansion caused by repeatedly expanding the same path.
def penetrate(start, edges, max_depth=10, stop_types={2,4}):"""Return {node: aggregate equity ratio}, ratios multiplied along paths then summed"""result, visited_path = {}, set()def dfs(node, acc, depth):if depth > max_depth or node in visited_path:returnvisited_path.add(node)for nxt, w in edges.get(node, []):cur = acc * wif nxt in stop_types: # termination entity reached, record and do not expand furtherresult[nxt] = result.get(nxt, 0) + curelse:result[nxt] = result.get(nxt, 0) + curdfs(nxt, cur, depth + 1)visited_path.discard(node) # backtrack, allowing other paths to pass through againdfs(start, 1.0, 0)return result
Three optimizations are generally recommended in engineering: first, change cycle detection from a “global visited” set to a “current path visited” set, otherwise valid multi-path cases will be missed; second, when the graph exceeds one million edges, switch to an iterative stack or divide-and-conquer approach to avoid recursion depth and stack overflow; third, apply memoization to repeated subproblems, reducing complexity from exponential back to nearly linear.
4. Clarifying the Semantics of Multi-path Equity Merging
The same terminal entity may be held through multiple chains, in which case “summing ratios” and “taking the maximum” are two completely different business semantics. The former answers “how large is the aggregate equity,” while the latter answers “how strong is the strongest control chain.” The two must not be mixed, or contradictory conclusions will result. In practice, it is recommended to output both sets of metrics and clearly label the calculation basis in the report.
5. Compute and Cost: Accounting for LLM-assisted Extraction
If large language model capabilities are used to extract shareholder and ratio information from unstructured text, the cost is mainly determined by input and output token volume and is affected by context length and concurrency. Common cost-control measures include: first applying rules and dictionaries for recall, invoking the model only for low-confidence fragments; segmenting long documents while preserving necessary context; and performing structured validation on extraction results, rejecting any out-of-range ratio, entity self-loop, or missing date for re-extraction.
6. Deployment Architecture and General Cloud Capabilities
A deliverable system is typically divided into four layers: the data ingestion layer handles multi-source collection and standardization; the compute layer carries graph traversal and aggregation; the service layer provides query and reporting interfaces; and the operations layer handles scheduling, monitoring, and alerting. On Baidu AI Cloud, you can use object storage to hold raw documents, a message queue to decouple extraction tasks, a container platform to run compute tasks, and logging and monitoring services for observability, all using general-purpose capabilities without binding to proprietary interfaces.
7. Quality Validation Checklist
Before going live, at minimum verify: accuracy against sampled manual review; convergence on cycle samples; whether the total equity ratio shows obvious out-of-range values; whether repeated runs on the same baseline date produce consistent results; and whether extremely deep chains trigger the depth limit and are correctly flagged. Only by turning validation into an automated pipeline can look-through conclusions be truly usable in risk control and compliance scenarios.
