1 of 44

1

Language Agents for Software Developments!

2 of 44

Outline

  1. Background (slides 3-7)
    • LLMs and Rise of Agents
  2. Language Agents (slides 8-10)
    • Introduction to Language Agents
  3. Language Agents for Software Developments (slides 11-38)
    • Opportunities and Challenges
    • Code Generation tasks, methods and Evaluation
    • Limitations
  4. Safety (slides 39-42)
    • Controlled Generation of Vulnerable Code

3 of 44

Background: Feature Engineering

NLP Before 2014

  • Extract linguistic and other features useful for tasks

4 of 44

Background: Model Engineering and the Rise of LLMs

Move from feature engineering to model engineering (2014 — )

5 of 44

Background: Model Engineering and the Rise of LLMs

Move from feature engineering to model engineering (2014 — )

Transformer decoder has become a standard for LLMs

Image source: https://arxiv.org/pdf/2011.04542

  • Causal self attention for representation learning

  • Causal LM as a pre-training objective: P(xt+1 | x1,…, xt )

6 of 44

LLM in Different Applications

  • Perform multifaceted language and cognitive tasks
  • Can interact with different tools and components
  • Generative AI applications: writing assistants, translation, customer support

7 of 44

The Rise of Language Agents

8 of 44

Outline

  1. Background
    • LLMs and Rise of Agents
  2. Language Agents
    • Introduction to Language Agents
  3. Language Agents for Software Developments
    • Opportunities and Challenges
    • Code Generation tasks, methods and Evaluation
    • Limitations
  4. Safety
    • Controlled Generation of Vulnerable Code

9 of 44

Language Agents: Simplistic View

wrapper that plays any specific role / solves a particular task

10 of 44

Language Agents: Broad Views of Functionalities

Image: https://rdi.berkeley.edu/llm-agents/assets/percyliang.pdf

11 of 44

Outline

  1. Background
    • LLMs and Rise of Agents
  2. Language Agents
    • Introduction to Language Agents
  3. Language Agents for Software Developments
    • Opportunities and Challenges
    • Multi-Agent Code Generation and Evaluation
    • Limitations
  4. Safety
    • Controlled Generation of Vulnerable Code

12 of 44

Language Agents for Software Developments

E.g., GitHub Co-Pilots, Aider, SWE-Agents, Open-hands

13 of 44

How Promising?

14 of 44

Challenges in Coding Agents

  • Defining the Environment (e.g., GitHub, Bitbuckets, Jira, MS Office, Gmail, AWS)

  • Designing an Observations/Actions (e.g., evaluations)

  • Code Generation (atomic actions)

  • File Localization (exploration)

  • Planning and Error Recovery (e.g., Bug introduced by a commit)

  • Safety (Does CLLMs generate vulnerable code?)

15 of 44

Code Generation

Find the median of an array

Concept

NL Description

Diverse token seq

Code

16 of 44

Modelling and Evaluation?

Code Completion Before Code LLMs (until 2021)

Input Description

Target code

Generated code

Perplexity

17 of 44

Code Generation

 

 

More information

as hint

Less diverse

ACL ’18

18 of 44

Sort my_tensor in descending order

Concept

Search examples

Browse thru. top few results

Adapt the results

my_tensor.sort(descending=True)

Python sorted in descending order

Real Users:

Code Generation

19 of 44

NL Description

GitHub/StackOverflow

Generated Code

LLM

EMNLP Findings ‘21

Code Retriever

Code Completion with Code LLMs (2021 —)

Retrieval Augmented Code Generation

Retrieved Example Code

20 of 44

Filter Noisy Retrievals

https://rdi.berkeley.edu/llm-agents/assets/percyliang.pdf

Pre-print, Enlisted in AI-Guides’ most impactful RAG papers

21 of 44

More High Quality and Diverse Retrievals

https://rdi.berkeley.edu/llm-agents/assets/percyliang.pdf

Retriever

Filter

22 of 44

Ensemble Retrievals

https://rdi.berkeley.edu/llm-agents/assets/percyliang.pdf

EACL ‘23

Retriever-1

Filter-1

Retriever-2

Filter-2

Retriever-3

Filter-3

Pre-trained LM-1

Pre-trained LM-2

Pre-trained LM-3

23 of 44

Always Retrieve?

Arbitrary LLM

Adaptive

Open-RAG

Retrieve

or Not?

EMNLP Findings ‘24

24 of 44

Achievement highlights

1Million+ readers, 2Millions+ monthly views

Most popular tech blog

25 of 44

Code Generation

Execution level (2021 — )

  • Simple Coding

e.g, HumanEval (Chen et al., 2021)

    • Examples of usage of the Python standard library

    • Includes docstring, some example inputs/outputs, and unit tests

26 of 44

Evaluation?

  • Basic idea: “if we generate K examples, will at least one of them pass unit tests”

  • Generating only K will result in high variance, so we generate N > K with C correct answers, and then calculate expected value

27 of 44

Can LLMs Really Code?

28 of 44

Code Generation

Competitive Problem Solving (2022 — )

  • Contest level Coding problems

    • Deeper NL understanding

    • Algorithmic Reasoning (e.g., BFS, DFS, Binary Search etc., )

    • Data Structure expertise (e.g., Stack, Queue etc., )

    • Generate satanically lengthy code

    • Pass the test cases

29 of 44

xCodeEval: New Benchmark

ACL ‘24

30 of 44

xCodeEval: New Benchmark

  • Collected from codeforces.com

    • Largest executable multilingual multitask benchmark to date

    • 25M document-level coding (16.5B tokens)

    • 7.5K unique problems

    • 11 programming languages

    • 7 tasks involving code understanding, generation, translation and retrieval

31 of 44

xCodeEval: New Benchmark

32 of 44

Reflect and Debug

Reflect and fix if any implementation errors found

Implement or Code

Implement the plan into code

Plan or Pseudocode

Decompose into steps

And make plan

Developers’ Cycle

Recall Examples

Recall similar problems

e.g., same Algorithms, DS

How does a programmer solve a problem

33 of 44

MapCoder: Multi-Agent Code Gen Appr

  • Self-Retrieval

    • Plans explored as per confidence

ACL ‘24

34 of 44

def sum_squares(lst):� """You are given a list of numbers.� You need to return the sum of squared numbers in the given list,� round each element in the list to the upper int(Ceiling) first.� Examples:� For lst = [1,2,3] the output should be 14� For lst = [1,4,9] the output should be 98� For lst = [1,3,5,7] the output should be 84� For lst = [1.4,4.2,0] the output should be 29� For lst = [-2.4,1,1] the output should be 6� """  

Problem

Sample I/O

Retrieval Agent: (Self-retrieved Similar Problem, its solution with planning for helping the model better understand the original problem)

Example 1: Find the sum of all even numbers in a list.

...  

Planning Agent: (Generated plan for original problem)

To solve this problem, we can iterate through the list, round each number to the upper integer, square it, and then add it to a running total. Finally, we return the total sum of all squared numbers in the list. 

Implementation/Coding Agent: (Generate code using the above plan)

import math�def sum_squares(lst):� total = 0� for num in lst:� total += (int(num) ** 2)� return total

Testing with all the Sample I/O. But it failed in the following sample I/O:

assert sum_squares([1.4,4.2,0]) == 29 

MapCoder

Example problem – MapCoder ��

35 of 44

def sum_squares(lst):� """You are given a list of numbers.� You need to return the sum of squared numbers in the given list,� round each element in the list to the upper int(Ceiling) first.� Examples:� For lst = [1,2,3] the output should be 14� For lst = [1,4,9] the output should be 98� For lst = [1,3,5,7] the output should be 84� For lst = [1.4,4.2,0] the output should be 29� For lst = [-2.4,1,1] the output should be 6� """  

Problem

Sample I/O

Planning Agent: (Generated plan for original problem)

To solve this problem, we can iterate through the list, round each number to the upper integer, square it, and then add it to a running total. Finally, we return the total sum of all squared numbers in the list. 

Implementation/Coding Agent: (Generate code using the above plan)

import math�def sum_squares(lst):� total = 0� for num in lst:� total += (int(num) ** 2)� return total

Testing with all the Sample I/O. But it failed in the following sample I/O:

assert sum_squares([1.4,4.2,0]) == 29 

Debugging Agent: (Fix code using the above-mentioned plan and test report)

import math�def sum_squares(lst):� total = 0� for num in lst:� total += (math.ceil(num) ** 2)� return total 

All sample input-output pairs now passed. The code is evaluated against private test cases, and it passed all of them as well.

MapCoder

Fix according to plan

Example problem – MapCoder ��

36 of 44

MapCoder: Achievements

37 of 44

CodeSim: Simulation Agent for Code

Under-review NAACL ‘25

38 of 44

Limitations

39 of 44

Outline

  1. Background
    • LLMs and Rise of Agents
  2. Language Agents
    • Introduction to Language Agents
  3. Language Agents for Software Developments
    • Opportunities and Challenges
    • Code Generation tasks, methods and Evaluation
    • Limitations
  4. Safety
    • Controlled Generation of Vulnerable Code

40 of 44

PwS: Poison with Style

Under-review S&P ‘25

41 of 44

PwS: Poison with Style

42 of 44

Outcome

  • Upto 98% vulnerable when trigger ( i.e. if target style is present)

    • Nearly benign when not triggered ( i.e. if target style is not present)

    • 5% Pass@1 improvements on HumanEval

43 of 44

Future Work

  • Defining the Environment (e.g., GitHub, Bitbuckets, Jira, MS Office, Gmail, AWS)

  • Designing an Observations/Actions (e.g., evaluations)

  • Code Generation (atomic actions)

  • File Localization (exploration)

  • Planning and Error Recovery (e.g., Bug introduced by a commit)

  • Safety

44 of 44