Neural Network Type Inference for Dynamic Languages

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Dynamic programming languages like Python lack effective type inference, relying on static typing tools that are data-hungry and ineffective in inferring user-defined types, leading to poor quality labeled data for machine learning models.

Innovation Solution

The use of information retrieval techniques to map types in dynamic programming languages to corresponding functions and methods, combined with data flow analysis, to train neural networks for type inference, generating high-quality labeled data and improving type inference precision.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If static type checkers are used for type inference in dynamic programming languages, then type checking can be performed, but they are data-hungry and ineffective in inferring user-defined types

Engineering Contradiction:
Improvetype inference precisionVSAvoideffectiveness in inferring user-defined types
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The patent replaces traditional static type checking mechanisms with a neural network-based system that uses information retrieval and data flow analysis. The neural network processes code structures and contextual information to infer types, eliminating the need for extensive annotated data while improving effectiveness on user-defined types.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The patent introduces an intermediary information retrieval system that bridges the gap between code analysis and type inference. This intermediary component extracts relevant information from documentation and code structures, feeding it to the neural network to enable effective type inference without direct manual annotation.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Loss of information

If static type checkers are used, then type checking is available, but they produce poor quality labeled data for machine learning models

Engineering Contradiction:
Improvequality of labeled dataVSAvoiddata generation efficiency
Core Design Contradiction:
Loss of informationVSProductivity

Solution Approach 1:

The system performs self-service by automatically generating high-quality labeled data through its own neural network and information retrieval capabilities. The neural network processes code and documentation to create accurate type labels without requiring external annotated datasets, improving both data quality and generation efficiency.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent applies preliminary action by pre-processing code and documentation through information retrieval before feeding data to the neural network. This preliminary extraction and cleaning of information ensures high-quality labeled data is generated efficiently, avoiding the need for manual annotation processes.

Inventive Principle:
Principle #10Preliminary action

3Measurement precision

If neural networks are trained with extensive annotated data, then type inference accuracy improves, but data collection and processing becomes cumbersome

Engineering Contradiction:
Improvetype inference accuracyVSAvoiddata collection and processing complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent extracts relevant type information directly from code structures and documentation through information retrieval techniques. This extraction process eliminates the need for manual annotation by automatically identifying and extracting the necessary data for training, reducing complexity while maintaining high accuracy.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The neural network system serves multiple functions: it performs type inference, generates labeled data, and processes code structures simultaneously. This multi-functionality eliminates the need for separate data collection and processing pipelines, reducing overall system complexity while maintaining high inference accuracy.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS11740875B2Type inference in dynamic languages
Publication Date: 2023.08.29 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11740875B2 patent drawing
  • US11740875B2 patent drawing
  • US11740875B2 patent drawing

AI summary

To improve the technological process of programming a computer using a dynamic programming language, generate a first portion of training data which maps types in the dynamic programming language to corresponding functions and methods by performing information retrieval on documentation libraries in the dynamic programming language and/or generate a second portion of training data which maps program variables to the corresponding functions and methods by performing data flow analysis on a plurality of pre-existing programs written in the dynamic programming language. Train a neural network on the first and/or second portions of training data to infer unknown types in the dynamic programming language. Carry out inference with the trained neural network to infer the unknown types. Facilitate programming in the dynamic programming language based on the inferred unknown types. Optionally, execute a resulting program.