Skip to main content

Synthesized Data for NLP Tasks

Project description

nlp-synt-data PyPi version t

Synthetic Data Tools for Natural Language Processing (NLP) and Large Language Models (LLM) tasks

  • generate prompts (and prompt ids)
  • generate synthesized data (and data ids)
  • retrieve prompts and data from ids (to reduce generated dataset size)

Installation

pip install nlp-synt-data

PromptGenerator

generate

prompts_dict = {
    "a": ["promptA0", "promptA1"],
    "b": ["promptB0", "promptB1"],
    "c": ["promptC0", "promptC1"],
    "d": ["promptD0", "promptD1"],
    "e": ["promptE0", "promptE1"],
}
PromptGenerator.generate(prompts_dict, [["c","e"],["a","b","d"]])
[('c#0_e#0', 'promptC0 promptE0'), ('c#0_e#1', 'promptC0 promptE1'), ('c#1_e#0', 'promptC1 promptE0'), ('c#1_e#1', 'promptC1 promptE1'), ('a#0_b#0_d#0', 'promptA0 promptB0 promptD0'), ('a#0_b#0_d#1', 'promptA0 promptB0 promptD1'), ('a#0_b#1_d#0', 'promptA0 promptB1
promptD0'), ('a#0_b#1_d#1', 'promptA0 promptB1 promptD1'), ('a#1_b#0_d#0', 'promptA1 promptB0 promptD0'), ('a#1_b#0_d#1', 'promptA1 promptB0 promptD1'), ('a#1_b#1_d#0', 'promptA1 promptB1 promptD0'), ('a#1_b#1_d#1', 'promptA1 promptB1 promptD1')]

get

PromptGenerator.get("c#0_e#0", prompts_dict)
promptC0 promptE0

DataGenerator

generate

texts_with_keys = [
    "[PERSON]",
    "[PERSON] is working as a [JOB] in [POS]",
    ]
substitutions = {
    "JOB": ["job0", "job1"],
    "PERSON": ["person0", "person1"],
    "POS": ["pos0", "pos1"]
}

DataGenerator.generate(texts_with_keys, substitutions)
[('t#0_PERSON#0', 'person0'), ('t#0_PERSON#1', 'person1'), ('t#1_JOB#0_PERSON#0_POS#0', 'person0 is working as a job0 in pos0'), ('t#1_JOB#0_PERSON#0_POS#1', 'person0 is working as a job0 in pos1'), ('t#1_JOB#0_PERSON#1_POS#0', 'person1 is working as a job0 in pos0'), ('t#1_JOB#0_PERSON#1_POS#1', 'person1 is working as a job0 in pos1'), ('t#1_JOB#1_PERSON#0_POS#0', 'person0 is working as a job1 in pos0'), ('t#1_JOB#1_PERSON#0_POS#1', 'person0 is working as a job1 in pos1'), ('t#1_JOB#1_PERSON#1_POS#0', 'person1 is working as a job1 in pos0'), ('t#1_JOB#1_PERSON#1_POS#1', 'person1 is working as a job1 in pos1')]

get

DataGenerator.get("t#1_JOB#0_PERSON#0_POS#0", texts_with_keys, substitutions)
{'keys': {'JOB': 'job0', 'PERSON': 'person0', 'POS': 'pos0'}, 'text': 'person0 is working as a job0 in pos0', 'text_with_keys': '[PERSON] is working as a [JOB] in [POS]'}

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

nlp_synt_data-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

nlp_synt_data-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file nlp_synt_data-0.0.3.tar.gz.

File metadata

  • Download URL: nlp_synt_data-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for nlp_synt_data-0.0.3.tar.gz
Algorithm Hash digest
SHA256 afbc6fc6f8b061214b69839cd9323b0c9b8f2dcb744dc0809881455f7c9328be
MD5 e26d7d5f0515f83c01f14eabd1b23325
BLAKE2b-256 49ffb7205a0dc300c8bdb23ae5d85a6242615591e28310212ffe870b3c91e13b

See more details on using hashes here.

File details

Details for the file nlp_synt_data-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nlp_synt_data-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for nlp_synt_data-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 854c634b03e45a6b547b0b26672f99942dd1e790f444a2caf3012d30265f4a2a
MD5 162afcab2ca08e5030575c17afc3cf35
BLAKE2b-256 245c279f4492247b032cb40f841b8fc01433c1c934b75571b87d49cb8bcffb7c

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