File size: 4,561 Bytes
92b839f
 
 
6d3b777
92b839f
 
 
 
 
6d3b777
 
92b839f
 
6d3b777
 
 
 
 
 
 
 
 
 
 
 
92b839f
6d3b777
 
 
92b839f
6d3b777
 
 
92b839f
6d3b777
92b839f
6d3b777
3684224
6d3b777
 
 
3684224
6d3b777
 
 
 
3684224
6d3b777
 
 
 
 
 
 
3684224
6d3b777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92b839f
6d3b777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92b839f
 
 
 
 
 
6d3b777
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
base_model:
- meta-llama/Llama-3.1-8B-Instruct
license: apache-2.0
tags:
- reasoning
- agent
- program
- code
pipeline_tag: text-generation
library_name: transformers
---

# CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis

Inductive program synthesis, or programming by example, requires synthesizing functions from input-output examples that generalize to unseen inputs. While large language model agents have shown promise in programming tasks guided by natural language, their ability to perform inductive program synthesis is underexplored. This work proposes CodeARC, the Code Abstraction and Reasoning Challenge, a new evaluation framework where agents interact with a hidden target function by querying it with new inputs, synthesizing candidate functions, and iteratively refining their solutions using a differential testing oracle. This interactive setting encourages agents to perform function calls and self-correction based on feedback, providing a more realistic and challenging testbed for evaluating LLM-based program synthesis and inductive reasoning. The model in this repository is a fine-tuned LLaMA-3.1-8B-Instruct model optimized for these tasks.

## Paper
[CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis](https://huggingface.co/papers/2503.23145)

## Code
[https://github.com/Anjiang-Wei/CodeARC](https://github.com/Anjiang-Wei/CodeARC)

## Website
[https://anjiang-wei.github.io/CodeARC-Website/](https://anjiang-wei.github.io/CodeARC-Website/)

## Datasets
*   **Problems Dataset**: [anjiangwei/CodeARC-Problems](https://huggingface.co/datasets/anjiangwei/CodeARC-Problems)
*   **10 Input-Output examples for each problem**: [anjiangwei/CodeARC-Invocations](https://huggingface.co/datasets/anjiangwei/CodeARC-Invocations)

## Fine-tuned models
*   [https://huggingface.co/LLM4Code/CodeARC_annotated_llama3.1](https://huggingface.co/LLM4Code/CodeARC_annotated_llama3.1)
*   [https://huggingface.co/LLM4Code/CodeARC_anonymous_llama3.1](https://huggingface.co/LLM4Code/CodeARC_anonymous_llama3.1)

## Usage

You can use this fine-tuned model with the `transformers` library for text generation tasks.

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig

# Ensure you replace 'your-model-id' with the actual model ID of this repository
# For example, if this model is LLM4Code/CodeARC_annotated_llama3.1, use that.
# Assuming this model is one of the fine-tuned versions based on context.
model_name = "LLM4Code/CodeARC_annotated_llama3.1" # Example, please adjust if different

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16, # Or torch.float16 if bfloat16 is not supported
    device_map="auto",
)
model.eval()

# Example prompt for inductive program synthesis
# This example asks for a Python function based on input-output pairs
prompt = """<|begin_of_text|><|start_header_id|>user<|end_header_id|>

Synthesize a Python function `sum_list` that takes a list of integers and returns their sum.

Input: [1, 2, 3]
Output: 6

Input: [5, 0, -5]
Output: 0<|eot_id|>
<|start_header_id|>assistant<|end_header_id|>

```python
def sum_list(numbers):
    # Your code here
```
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

# Generate response
generation_output = model.generate(
    **inputs,
    max_new_tokens=100,
    do_sample=True,
    top_p=0.9,
    temperature=0.6,
    eos_token_id=[tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eom_id|>")]
)
generated_text = tokenizer.decode(generation_output[0], skip_special_tokens=True)

print(generated_text)
```

For more detailed usage, evaluation scripts, and setting up the full CodeARC environment, please refer to the [official GitHub repository](https://github.com/Anjiang-Wei/CodeARC).

## Citation

If you use this model or the CodeARC framework in your research, please cite the corresponding paper:

```bibtex
@article{wei2025codearc,
  title={CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis},
  author={Wei, Anjiang and Suresh, Tarun and Cao, Jiannan and Kannan, Naveen and Wu, Yuheng and Yan, Kai and Teixeira, Thiago SFX and Wang, Ke and Aiken, Alex},
  journal={arXiv preprint arXiv:2503.23145},
  year={2025}
}
```

## License

This project is licensed under the Apache 2.0 License. See the [LICENSE](https://opensource.org/licenses/Apache-2.0) file for details.