IP Library Granted Patent US 12,430,585
Granted Patent B2
US 12,430,585 · App. 17/896,946 · Granted Sep 30, 2025

Systems and methods for program synthesis

Inventors: Hung Le (Singapore, SG); Yue Wang (Singapore, SG); Akhilesh Deepak Gotmare (Singapore, SG); Chu Hong Hoi (Singapore, SG)
Assignee: Salesforce, Inc.
G06N20/00G06F18/214G06F18/217G06F40/284G06F40/289
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,430,585
App. No.
17/896,946
Granted
Sep 30, 2025
Kind
B2
Abstract

Embodiments described herein provide a reinforcement learning based framework engaging pretrained language models (LMs) for program synthesis tasks. Specifically, the framework adopts a training strategy that optimizes pretrained LMs for program synthesis tasks in an actor-critic approach.

Claims (79)

1. A method of program synthesis, the method comprising:

receiving, via an input interface, a problem specification at a language model pretrained for program synthesis;

extracting one or more unit test input-output pairs from the problem specification;

generating, by the language model, a plurality of program samples from the problem specification;

applying one or more unit tests to the plurality of program samples based on the one or more unit test input-output pairs;

determining, from the plurality of program samples, a first set of program samples that pass the one or more unit tests;

re-generating, by the language model, one or more refined program samples based on information from the first set of program samples, including:

selecting, via critic scoring, one or more sub-sequences from the first set of program samples, each sub-sequence being a truncated version of a program sample; and

re-generating, by the language model, subsequent tokens conditioned on the one or more sub-sequences to form one or more refined program samples.

2. The method of claim 1 , wherein the one or more sub-sequences are selected by:

determining, by a critic model, a value to each token of a first program sample in the first set based on a predicted probability that a subsequence up to the respective token pass the one or more unit tests;

determining a particular token of the first program sample having a highest value; and

selecting a sub-sequence of the first program sample up to the particular token as a sub-sequence.

3. The method of claim 2 , further comprising:

determining that the selected sub-sequence contains a particular token up to which a corresponding sub-sequence has a higher probability to fail than to pass the one or more unit tests; and

chopping the selected sub-sequence at the particular token.

4. The method of claim 1 , further comprising:

determining, from the plurality of program samples, a second set of program samples that are unsuccessful, comprising at least one of compile error, runtime error and failure to pass at least one of the unit tests.

5. The method of claim 4 , further comprising:

determining, by a critic model, a value to a second program sample in the second set based on a predicted probability that the second program sample pass the one or more unit tests;

selecting a subset of program samples with highest values from the second set;

forming an input sequence by concatenating the problem specification, a selected program sample and error information corresponding to the selected program sample;

generating, by a program repair model, a repaired program sample based on the input sequence.

6. The method of claim 5 , wherein the error information comprises any of:

a unit test outcome corresponding to the selected program sample; and

an error subtype during compiling or runtime of the selected program sample.

7. The method of claim 5 , wherein the program repair model is a sequence-to-sequence model.

8. The method of claim 5 , wherein the program repair model is trained by a training objective comparing program samples that fail the unit tests and a ground-truth program corresponding to the problem specification, conditioned on a unit test outcome and/or an error subtype corresponding to the program samples.

9. The method of claim 4 , further comprising:

generating, by a program repair model, one or more repaired program samples using error information from the second set of program samples; and

refining, by the language model, the one or more repaired program samples.

10. A system of program synthesis, the system comprising:

an input interface that receives a problem specification at a language model pretrained for program synthesis;

a memory storing a plurality of processor-executable instructions;

a processor that reads and executes the plurality of processor-executable instructions to perform operations comprising:

extracting one or more unit test input-output pairs from the problem specification;

generating, by the language model, a plurality of program samples from the problem specification;

applying one or more unit tests to the plurality of program samples based on the one or more unit test input-output pairs;

determining, from the plurality of program samples, a first set of program samples that pass the one or more unit tests;

re-generating, by the language model, one or more refined program samples based on information from the first set of program samples, including:

selecting, via critic scoring, one or more sub-sequences from the first set of program samples, each sub-sequence being a truncated version of a program sample; and

re-generating, by the language model, subsequent tokens conditioned on the one or more sub-sequences to form one or more refined program samples.

11. The system of claim 10 , wherein the one or more sub-sequences are selected by:

determining, by a critic model, a value to each token of a first program sample in the first set based on a predicted probability that a subsequence up to the respective token pass the one or more unit tests;

determining a particular token of the first program sample having a highest value; and

selecting a sub-sequence of the first program sample up to the particular token as a sub-sequence.

12. The system of claim 11 , wherein the operations further comprise:

determining that the selected sub-sequence contains a particular token up to which a corresponding sub-sequence has a higher probability to fail than to pass the one or more unit tests; and

chopping the selected sub-sequence at the particular token.

13. The system of claim 10 , wherein the operations further comprise:

determining, from the plurality of program samples, a second set of program samples that are unsuccessful, comprising at least one of compile error, runtime error and failure to pass at least one of the unit tests.

14. The system of claim 13 , wherein the operations further comprise:

determining, by a critic model, a value to a second program sample in the second set based on a predicted probability that the second program sample pass the one or more unit tests;

selecting a subset of program samples with highest values from the second set;

forming an input sequence by concatenating the problem specification, a selected program sample and error information corresponding to the selected program sample;

generating, by a program repair model, a repaired program sample based on the input sequence.

15. The system of claim 14 , wherein the error information comprises any of:

a unit test outcome corresponding to the selected program sample; and

an error subtype during compiling or runtime of the selected program sample.

16. The system of claim 14 , wherein the program repair model is trained by a training objective comparing program samples that fail the unit tests and a ground-truth program corresponding to the problem specification, conditioned on a unit test outcome and/or an error subtype corresponding to the program samples.

17. The system of claim 13 , wherein the operations further comprise:

generating, by a program repair model, one or more repaired program samples using error information from the second set of program samples; and

refining, by the language model, the one or more repaired program samples.

18. A non-transitory processor-readable storage medium storing a plurality of processor-executable instructions for program synthesis, the processor-executable instructions being executed by one or more processors to perform operations comprising:

receiving, via an input interface, a problem specification at a language model pretrained for program synthesis;

extracting one or more unit test input-output pairs from the problem specification;

generating, by the language model, a plurality of program samples from the problem specification;

applying one or more unit tests to the plurality of program samples based on the one or more unit test input-output pairs;

determining, from the plurality of program samples, a first set of program samples that pass the one or more unit tests;

re-generating, by the language model, one or more refined program samples based on information from the first set of program samples, including:

selecting, via critic scoring, one or more sub-sequences from the first set of program samples, each sub-sequence being a truncated version of a program sample; and

re-generating, by the language model, subsequent tokens conditioned on the one or more sub-sequences to form one or more refined program samples.

19. The non-transitory processor-readable storage medium of claim 18 , wherein the one or more sub-sequences are selected by:

determining, by a critic model, a value to each token of a first program sample in the first set based on a predicted probability that a subsequence up to the respective token pass the one or more unit tests;

determining a particular token of the first program sample having a highest value; and

selecting a sub-sequence of the first program sample up to the particular token as a sub-sequence.

20. The method of claim 19 , wherein the operations further comprise:

determining that the selected sub-sequence contains a particular token up to which a corresponding sub-sequence has a higher probability to fail than to pass the one or more unit tests; and

chopping the selected sub-sequence at the particular token.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 25, 2025
From: LE, HUNG; WANG, YUE; GOTMARE, AKHILESH DEEPAK; HOI, CHU HONG
To: SALESFORCE, INC.
Reel/Frame 072115/0879 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 8, 2022
From: LE, HUNG; WANG, YUE; GOTMARE, AKHILESH DEEPAK; HOI, CHU HONG
To: SALESFORCE, INC.
Reel/Frame 061025/0251 →
Continuity (2)
Provisional Application 63344900 · May 23, 2022
Related Publication 20230376841A1 · Nov 23, 2023
References Cited (18)
US 11797839B2 · Norouzi · 2023 [cited by examiner]
US 11941373B2 · Kun et al. · 2024 [cited by applicant]
US 20020199168A1 · Namito · 2002 [cited by examiner]
US 20080072100A1 · Okada · 2008 [cited by examiner]
US 20130219374A1 · Kshitiz et al. · 2013 [cited by applicant]
US 20230176829A1 · Kiarash et al. · 2023 [cited by applicant]
US 20230244452A1 · Li · 2023 [cited by examiner]
US 20230280989A1 · Cambronero Sánchez · 2023 [cited by examiner]
International Search Report and Written Opinion for PCT/US2023/022994, dated Aug. 8, 2023, 11 pages. [cited by applicant]
Elhattami, “Beyond Codex: A Code Generation Model That You Can Train”, Towards Data Science, Nov. 23, 2021, Retrieved from the internet: URL:https://towardsdatascience.com/beyond-codex-a-code-generation-model-that-you-c… [cited by applicant]
Sanchez-Stern et al., “Generating correctness proofs with neural networks”, Proceedings of the 4th ACM Sigplan International Workshop on Machine Learning and Programming Languages, Acmpub27, New York, NY, USA, Jun. 15, … [cited by applicant]
Non-Final Office Action for U.S. Appl. No. 17/896,942, dated Mar. 13, 2025, 21 pages. [cited by applicant]
Bahdanau et al., “An Actor-Critic Algorithm for Sequence Prediction”, ICLR 2017 Conference Paper, arXiv 1607.07086v3, Mar. 3, 2017, pp. 1-17. [cited by applicant]
Bunel et al., “Leveraging Grammar and Reinforcement Learning for Neural Program Synthesis”, ICLP 2018 Conference Paper, arXiv 1805.04276v2, May 22, 2018, pp. 1-15. [cited by applicant]
Shin et al., “Synthetic Datasets for Neural Program Synthesis”, ICLR 2019 Conference Paper, arXiv 1912.12345v1, Dec. 27, 2019, pp. 1-16. [cited by applicant]
Wang et al., “Automating Reinforcement Learning Architecture Design for Code Optimization, Association for Computing Machinery”, 2022 Association for Computing Machinery, ACM ISBN 978-1-4503-9183-2, Feb. 22, 2004, pp. 1… [cited by applicant]
Xu et al., “Neural Program Synthesis by Self-Learning”, arXiv 1910.05865v1, Oct. 13, 2019, pp. 1-11. [cited by applicant]
Yang et al., “Program Synthesis Guided Reinforcement Learning for Partially Observed Environments ”, 35th Conference of Neural Information Processing Systems, 2021, pp. 1-15. [cited by applicant]