Skip to main content

Framework for code synthesis and AI4SE research

Project description

Synthegrator

Synthegrator is a framework for code generation problems. It simplifies the process of loading common datasets and solving them with language models.

Installation

pip install synthegrator

Also, for execution you will need to install docker.

Example

Let's take a look at an example of how we can run a solver over the HumanEval dataset, which collects 164 function synthesis problems.

# Imports
from lmwrapper.openai_wrapper import get_open_ai_lm, OpenAiModelNames
from synthegrator.code_solver import LmCodeSolverAutoRegressive
from synthegrator.execution_threading import solve_and_evaluate_problems
from synthegrator.synthdatasets.human_eval import yield_human_eval
from synthegrator.df_converters import solution_evals_to_df

# Loading of a selection of AI4SE Datasets
problems = list(yield_human_eval())

# Create a solver that can solve a problem
lm = get_open_ai_lm(OpenAiModelNames.gpt_3_5_turbo_instruct)
#    ^ Make sure to add your API key to OPENAI_API_KEY or a file. 
#    See https://github.com/DaiseyCode/lmwrapper for more.
solver = LmCodeSolverAutoRegressive(lm)

# Generate code and execute problems testcases
evals = list(solve_and_evaluate_problems(
    solver=solver,
    problems=problems,
    max_threads_eval=4,
))
# Convert to a dataframe
df = solution_evals_to_df(
    evals, 
    pickle_gzip_whole_solution_eval=True
)
print("Fraction Passing", df.main_metric__is_success.mean())

Architecture

Guiding Design Requirements

  • DR-1 Support Diverse Datasets and Tasks. We want an architecture that can support a diverse tasks (including potentially complex, repository-level tasks).
  • DR-2 Consistent & Efficient Execution. Experiments often involve running LLM-generated code. We want this to be fast, efficient, and reasonably secure.
  • DR-3 Adaptable to State-of-the-Art Models. This includes models like those from OpenAI or on HuggingFace. Additionally be adaptable to models that might do complex retrieval or reasoning
  • DR-4 Maintainable. Try to follow best practices around automated testing and continuous integration.

Diagram

Alt synthegrator diagram

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synthegrator-0.11.1.0.tar.gz (3.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthegrator-0.11.1.0-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

Details for the file synthegrator-0.11.1.0.tar.gz.

File metadata

  • Download URL: synthegrator-0.11.1.0.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for synthegrator-0.11.1.0.tar.gz
Algorithm Hash digest
SHA256 1cb9242a0cb12a5f29967faa3cd97dc11f8d611a9b190206ba36c9e52b12bf5c
MD5 20d01f67c48469269c72ed00fd46204b
BLAKE2b-256 69b54b37af3357e023cfe6e20892e1c26fefe8ae0c045fe53e90733434557353

See more details on using hashes here.

File details

Details for the file synthegrator-0.11.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for synthegrator-0.11.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9964f09909582d0f48a04c62e8c006d8dffa21edc64fbf83149d35bee611d334
MD5 79984a3f1815719c5b285b100a868d2a
BLAKE2b-256 243f0ede0a1217cf6187bc9ca443bca949fb3f3f430215c1163a790c57a451b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page