task
CodeGenerationAPPSPassAt5
research_problem
Code Generation
metadata.yaml
metric_lower_is_better: false
file_export_globs:
- submission.csv
container_python_requirements:
- datasets==4.0.0
evaluate_container_python_requirements:
- datasets==4.0.0
- torchmetrics
- pandas
- numpy
- torch
- pyext
prepare_code_python_requirements:
- pyext
logging_info:
name: CodeGenerationAPPSPassAt5
category: Code
research_problem: Code Generation
output_type: Text Generation
dataset: codeparrot/apps
config: all
metric: Pass@5
input_columns:
- question
- starter_code
scoring_column: input_output
train_split: train
test_split: test
shape …
project_description.md
# Overview
## Task Description
This is a Machine Learning project and your goal is to build a model that solves the project's TASK following the instructions provided below.
TASK: Your task is to generate five independent Python programs for each competitive-programming problem. Each program must read from standard input and write to standard output and is intended to solve the given problem completely. A prediction for a problem is considered correct if at least one of the five submitted programs passes all of the official hidden test cases. Your predictions will be scored using the Pass …
prepare.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import sys
import logging
from datasets import load_from_disk
# Configure logger with custom prefix
logger = logging.getLogger('dataset_code')
handler = logging.StreamHandler()
formatter = logging.Formatter('[Running provided `dataset_code`] %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
def main(global_shared_dat …
evaluate_prepare.py
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from json import load
import os
import sys
import argparse
import logging
import shutil
from datasets import load_from_disk
# Configure logger with custom prefix
SCRIPT_NAME = 'evaluate_prepare'
logger = logging.getLogger(SCRIPT_NAME)
handler = logging.StreamHandler()
formatter = logging.Formatter('[Running provided `SCRIPT_NAME`] %(message)s')
handler.setFormatter(formatt …
evaluate.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse, json
import pandas as pd
import json
from pathlib import Path
from datasets import load_from_disk
from utils import evaluate_all_testcases
def load_testcases(path="./data/test_with_labels"):
"""
Load testcases for evaluation.
"""
ds = load_from_disk(path)
return ds
def evaluate(submissions, testcases):
"""
Compute Pass@5 metric for a list of submissi …
custom_labels.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import json
import pandas as pd
from random import random
from datasets import load_from_disk
from pathlib import Path
def parse_args():
parser = argparse.ArgumentParser(
description="Make gold labels for the APPS dataset for Code Generation."
)
parser.add_argument(
"--global-shared-data-dir",
required=True,
help="Path to the s …
utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import json
import multiprocessing
import numpy as np
from tqdm import tqdm
from testing_util import run_test
from concurrent.futures import ThreadPoolExecutor, as_completed
def solves_testcases(submission, testcases, verbose=False):
"""
Write submission once to a temp file and run it against all testcases.
"""
timeout = 10
def _temp_run(sample, generation, debug, result):
…
task
CodeRetrievalCodeXGlueMRR
research_problem
Code Retrieval
dataset
google/code_x_glue_tc_nl_code_search_adv
metadata.yaml
metric_lower_is_better: false
file_export_globs:
- submission.csv
container_python_requirements:
- datasets==4.0.0
evaluate_container_python_requirements:
- datasets==4.0.0
logging_info:
name: CodeRetrievalCodeXGlueMRR
dataset: google/code_x_glue_tc_nl_code_search_adv
category: Code
research_problem: Code Retrieval
output_type: Search results
config: default
train_split: train
test_split: test
input_columns:
- docstring_tokens
- id
scoring_column: id
shape: (19210,2)
custom_gold_labels: true
custom_rad_class: false
metric: MRR
additional_metrics: nul …
project_description.md
# Overview
## Task Description
This is a Machine Learning project and your goal is to complete the project's TASK following the instructions provided below.
TASK: This is a NLP task to perform Code retrieval on google/code_x_glue_tc_nl_code_search_adv.
## Data
### Dataset Structure
This is a retrieval task, so for each split (other than test) there is a set of search queries (`./data/<split>/queries_with_labels`) along with a large corpus to search over (`./data/<split>/search_corpus`).
Each item in the corpus is structured as: `{'id': Value('int32'), 'code': Value('string')}`. For exa …
prepare.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import sys
import logging
import re
from datasets import load_dataset, load_from_disk
# Configure logger with custom prefix
logger = logging.getLogger('dataset_code')
handler = logging.StreamHandler()
formatter = logging.Formatter('[Running provided `dataset_code`] %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
def …
evaluate_prepare.py
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
import sys
import argparse
import logging
import re
import shutil
from datasets import load_from_disk
# Configure logger with custom prefix
SCRIPT_NAME = 'evaluate_prepare'
logger = logging.getLogger(SCRIPT_NAME)
handler = logging.StreamHandler()
formatter = logging.Formatter('[Running provided `SCRIPT_NAME`] %(message)s')
handler.setFormatter(formatter)
logger.add …
evaluate.py
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse, json
import numpy as np
import pandas as pd
import torch
from datasets import load_dataset, load_from_disk
from utils import calculate_scores
def load_test_set():
return load_from_disk('./data/test_with_labels')
def evaluate(predictions, labels):
"""
Returns a dict of metric_name -> value
"""
# Predictions should be pd.DataFrame with c …
custom_labels.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from datasets import load_from_disk
import json
import pandas as pd
import os
import argparse
import re
import copy
import random
hf_repo = 'google/code_x_glue_tc_nl_code_search_adv'
config = 'default'
test_split = 'test'
def select_columns(dds, columns):
to_drop = [c for c in dds.column_names if c not in columns]
dds_small = dds.remove_columns(to_drop)
return dds_small
d …
utils.py
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import sys,json
import numpy as np
def read_answers(filename):
answers={}
with open(filename) as f:
for line in f:
line=line.strip()
js=json.loads(line)
answers[js['url']]=js['idx']
return answers
def read_predictions(filename):
predictions={}
wi …