Copy sft/scripts from HuggingFaceBio/FineDNA-SFT@400d761
Browse files- sft/scripts/create_dataset.py +76 -0
- sft/scripts/create_subset.py +52 -0
sft/scripts/create_dataset.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# dependencies = ["datasets>=4", "huggingface_hub"]
|
| 3 |
+
# ///
|
| 4 |
+
"""Build FineDNA-SFT from the Carbon-X SFT data mixture.
|
| 5 |
+
|
| 6 |
+
Each source subset is shuffled with the mixture seed and truncated to `int(len * weight)` rows, labelled with its
|
| 7 |
+
domain, then all subsets are concatenated, shuffled again and split into train and a 100-row test set. This matches
|
| 8 |
+
the SFT trainer's mixture loader exactly, so the published splits are the rows the trainer sees.
|
| 9 |
+
|
| 10 |
+
python scripts/create_dataset.py --output_dataset HuggingFaceBio/FineDNA-SFT
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import argparse
|
| 14 |
+
|
| 15 |
+
from datasets import concatenate_datasets, load_dataset
|
| 16 |
+
from huggingface_hub import HfApi
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
SEED = 0
|
| 20 |
+
TEST_SIZE = 100
|
| 21 |
+
COLUMNS = ["messages", "chat_template_kwargs"]
|
| 22 |
+
SUFFIX = "_decontaminated_ngram_dna_homology"
|
| 23 |
+
|
| 24 |
+
# (dataset, config, revision, weight, domain), in mixture order
|
| 25 |
+
SOURCES = [
|
| 26 |
+
("HuggingFaceBio/sequence-recovery-qa", "varlen", "e09cae720c1635c4764704a7bf355e2c8c8c6e55", 1.0, "sequence_continuation"),
|
| 27 |
+
("HuggingFaceBio/sequence-recovery-qa", "rewrite", "e09cae720c1635c4764704a7bf355e2c8c8c6e55", 0.1266728, "dna_computation"),
|
| 28 |
+
("HuggingFaceBio/carbon-format-if", "format_if_v2", "390592d0bbc099447235854bc9e6017361622fb3", 1.0, "instruction_following"),
|
| 29 |
+
("HuggingFaceBio/basic-dna-sft-data-v3", "all_diversify_30pct", "72dc7e731ff5de0ef4295c58ebaa3cffde488128", 0.151, "dna_computation"),
|
| 30 |
+
("HuggingFaceBio/carbon-sequence-contextfree-v8-regex-10k", "final", "5f17e938d75a7ca96305c5ad17c2e9b4a6fac764", 0.3, "sequence_analysis"),
|
| 31 |
+
("HuggingFaceBio/carbon-gemini-repair-sft", "default", "63cccfc7ddcdf5241d2adafc904e051160b8f18c", 0.3, "sequence_analysis"),
|
| 32 |
+
("HuggingFaceBio/carbon-sequence-contextfree-v6-1000", "final", "e279241716d0c36e1ffd299d619530e10e8ed120", 1.0, "sequence_analysis"),
|
| 33 |
+
("HuggingFaceBio/carbon-bioSE-sft", "final", "31dc6d39e35c125771de2f83ad11d64df367e9b4", 1.0, "biology_qa"),
|
| 34 |
+
("HuggingFaceBio/carbon-biostars-sft-v2", "final", "5014a6b616fcb564fd95a9978aad708e66179ee7", 1.0, "biology_qa"),
|
| 35 |
+
("HuggingFaceBio/wild-bio-prompts-luna-generated-verified-v1", "final", "35440c49a65a87d878125c95188748b6f8496e23", 1.0, "biology_qa"),
|
| 36 |
+
("HuggingFaceBio/seqqa2-luna-sft-structurednotags-dna8-clean-v3", "final", "38644f1f3b82d1d311aaf061ca5aa1754f3a5b5f", 1.0, "dna_computation"),
|
| 37 |
+
("HuggingFaceBio/genomeqa-sft", "enhancer_promoter_diversify_10pct", "398703a5938ed57eb51450ac8769590d0a00ee0c", 0.4, "sequence_classification"),
|
| 38 |
+
("HuggingFaceBio/genomeqa-sft", "eukaryote_cls_diversify_10pct", "398703a5938ed57eb51450ac8769590d0a00ee0c", 0.4, "sequence_classification"),
|
| 39 |
+
("HuggingFaceBio/genomeqa-sft", "tf_motif_diversify_10pct", "398703a5938ed57eb51450ac8769590d0a00ee0c", 0.4, "sequence_classification"),
|
| 40 |
+
("HuggingFaceBio/genomeqa-sft", "tfbs_diversify_10pct", "398703a5938ed57eb51450ac8769590d0a00ee0c", 0.4, "sequence_classification"),
|
| 41 |
+
("HuggingFaceBio/vepqa-sft-draft-loubna", "templated_reasoning_multiview_v2_all", "76e39513e6823db1da2c92c79620923daa78cbdc", 0.769, "variant_effect_prediction"),
|
| 42 |
+
("HuggingFaceBio/nemotron-data-filtered-carbon", "biology_en_max8704", "50df980c19caeaef9bfbcc22438410c886d29cb0", 0.1, "biology_qa"),
|
| 43 |
+
("HuggingFaceBio/nemotron-data-filtered-carbon", "instruction_following_bio_en_max8704", "50df980c19caeaef9bfbcc22438410c886d29cb0", 1.0, "instruction_following"),
|
| 44 |
+
("HuggingFaceBio/easy-dna-chat-v2", "all", "53923d9a68170203f0210b746143d9d28cf739d2", 0.7442, "chat"),
|
| 45 |
+
("HuggingFaceBio/carbon-dna-skills", "all", "d703e0cd6f933f7d872b074a7c45e5c673a6d52f", 0.8, "dna_computation"),
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def build_dataset():
|
| 50 |
+
subsets = []
|
| 51 |
+
for dataset_id, config, revision, weight, domain in SOURCES:
|
| 52 |
+
ds = load_dataset(dataset_id, config + SUFFIX, split="train", revision=revision).select_columns(COLUMNS)
|
| 53 |
+
ds = ds.add_column("domain", [domain] * len(ds))
|
| 54 |
+
subsets.append(ds.shuffle(seed=SEED).select(range(int(len(ds) * weight))))
|
| 55 |
+
return concatenate_datasets(subsets).shuffle(seed=SEED).train_test_split(test_size=TEST_SIZE, seed=SEED)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def main():
|
| 59 |
+
parser = argparse.ArgumentParser()
|
| 60 |
+
parser.add_argument("--output_dataset", default="HuggingFaceBio/FineDNA-SFT")
|
| 61 |
+
args = parser.parse_args()
|
| 62 |
+
|
| 63 |
+
dataset = build_dataset()
|
| 64 |
+
print(dataset)
|
| 65 |
+
dataset.push_to_hub(args.output_dataset, private=True, commit_message="Build FineDNA-SFT from the Carbon-X SFT mixture")
|
| 66 |
+
HfApi().upload_file(
|
| 67 |
+
path_or_fileobj=__file__,
|
| 68 |
+
path_in_repo="scripts/create_dataset.py",
|
| 69 |
+
repo_id=args.output_dataset,
|
| 70 |
+
repo_type="dataset",
|
| 71 |
+
commit_message="Publish the script that built this dataset",
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
main()
|
sft/scripts/create_subset.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# dependencies = ["datasets>=4", "huggingface_hub"]
|
| 3 |
+
# ///
|
| 4 |
+
"""Add one config per domain to FineDNA-SFT.
|
| 5 |
+
|
| 6 |
+
Each config holds the `train` rows of the `default` config with that `domain`, in the same order, so it is exactly the
|
| 7 |
+
part of the Carbon-X SFT mixture that the trainer sees for that domain. The domain configs have no test split.
|
| 8 |
+
|
| 9 |
+
python scripts/create_subset.py --dataset HuggingFaceBio/FineDNA-SFT --revision 60b6e0d5c9af34bd97de521cc2cf5fb3e977771c
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import argparse
|
| 13 |
+
|
| 14 |
+
from datasets import load_dataset
|
| 15 |
+
from huggingface_hub import HfApi
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# Largest first, which is the order of the configs in the card
|
| 19 |
+
DOMAINS = [
|
| 20 |
+
"sequence_continuation",
|
| 21 |
+
"variant_effect_prediction",
|
| 22 |
+
"dna_computation",
|
| 23 |
+
"sequence_classification",
|
| 24 |
+
"chat",
|
| 25 |
+
"sequence_analysis",
|
| 26 |
+
"instruction_following",
|
| 27 |
+
"biology_qa",
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
parser = argparse.ArgumentParser()
|
| 33 |
+
parser.add_argument("--dataset", default="HuggingFaceBio/FineDNA-SFT")
|
| 34 |
+
parser.add_argument("--revision", required=True, help="Revision of the `default` config to split by domain")
|
| 35 |
+
args = parser.parse_args()
|
| 36 |
+
|
| 37 |
+
dataset = load_dataset(args.dataset, split="train", revision=args.revision)
|
| 38 |
+
for domain in DOMAINS:
|
| 39 |
+
subset = dataset.filter(lambda x: x == domain, input_columns="domain")
|
| 40 |
+
print(f"{domain}: {len(subset)} rows")
|
| 41 |
+
subset.push_to_hub(args.dataset, config_name=domain, split="train", commit_message=f"Add the {domain} config")
|
| 42 |
+
HfApi().upload_file(
|
| 43 |
+
path_or_fileobj=__file__,
|
| 44 |
+
path_in_repo="scripts/create_subset.py",
|
| 45 |
+
repo_id=args.dataset,
|
| 46 |
+
repo_type="dataset",
|
| 47 |
+
commit_message="Publish the script that built the domain configs",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if __name__ == "__main__":
|
| 52 |
+
main()
|