Synthesized Data for NLP Tasks
Project description
nlp-synt-data

Synthetic Data Tools for Natural Language Processing (NLP) and Large Language Models (LLM) tasks
- generate prompts (and prompt ids)
- generate synthetic data (and data ids)
- retrieve prompts and data from ids (to reduce generated dataset size)
Installation
pip install nlp-synt-data
Quickstart
An example of this library with ollama
from nlp_synt_data import *
import ollama
# generate prompts
prompts_dict = {
"a": ["promptA0", "promptA1"],
"b": ["promptB0", "promptB1"],
"c": ["promptC0", "promptC1"],
"d": ["promptD0", "promptD1"],
"e": ["promptE0", "promptE1"],
}
prompts = PromptGenerator.generate(prompts_dict, [["c","e"],["a","b","d"]])
# generate texts
texts_with_keys = [
("[PERSON]","label0"),
("[PERSON] is working as a [JOB] in [POS]","label1"),
]
substitutions = {
"JOB": [("job0","labeljob0"), ("job1","labeljob1")],
"PERSON": [("person0","labelperson0"), ("person1","labelperson1")],
"POS": [("pos0","labelpos0"), ("pos1","labelpos1")]
}
texts = DataGenerator.generate(texts_with_keys, substitutions)
# generate responses
model_func = lambda prompt, text: ollama.chat(model='llama3:instruct', messages=[
{ 'role': 'system', 'content': prompt, },
{ 'role': 'user', 'content': text, },
])['message']['content']
ResponseGenerator.generate("results.csv", texts, prompts, model_func)
results.csv
| prompt_id | text_id | text_labels | response | text_PERSON_value | text_JOB_value | text_POS_value | text_PERSON_label | text_JOB_label | text_POS_label |
|---|---|---|---|---|---|---|---|---|---|
| c#0_e#0 | t#0_PERSON#0 | label0 | response | person0 | labelperson0 | ||||
| c#0_e#0 | t#0_PERSON#1 | label0 | response | person1 | labelperson1 | ||||
| c#0_e#0 | t#1_JOB#0_PERSON#0_POS#0 | label1 | response | person0 | job0 | pos0 | labelperson0 | labeljob0 | labelpos0 |
| c#0_e#0 | t#1_JOB#0_PERSON#0_POS#1 | label1 | response | person0 | job0 | pos1 | labelperson0 | labeljob0 | labelpos1 |
| c#0_e#0 | t#1_JOB#0_PERSON#1_POS#0 | label1 | response | person1 | job0 | pos0 | labelperson1 | labeljob0 | labelpos0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Project details
Release history Release notifications | RSS feed
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.10.tar.gz
(5.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nlp_synt_data-0.0.10.tar.gz.
File metadata
- Download URL: nlp_synt_data-0.0.10.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21e81f7e79861072580bb2040131347ed0c1551902c7bd57eec12eb36f5ef571
|
|
| MD5 |
075103b693acafbe973672b4164905ae
|
|
| BLAKE2b-256 |
cd836f21fdb20e78e62f9a95fa20c2371f591e0a63fcf3cea63b6f2d79f387df
|
File details
Details for the file nlp_synt_data-0.0.10-py3-none-any.whl.
File metadata
- Download URL: nlp_synt_data-0.0.10-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19cdab65e0e7f1a2337546d3cb661c7866efd6ea69481a7c4b71b6270ed2451b
|
|
| MD5 |
000693a1dafe09c789b6eec9fcdcd707
|
|
| BLAKE2b-256 |
ce484b399e661a23c8459826ce8a79f61991c99e84c5c5d0bf2d519df63c85af
|