PromptPlanner
Install
Python >=3.10
git clone https://github.com/SecretSettler/PromptPlanner.git
cd PromptPlanner
pip install -e .
Data Format:
Currently we only support data with jsonl format. Each json should at least contain these attributes:
{
"qid": 0,
"text": "Is the sky blue?",
"answer": ["Yes", "Yes the sky is blue"],
"top_k_doc_id": [2, 8, 1, 10]
}
Quick usage
from promptplanner.offline.clustering import cluster_prompts
from promptplanner.offline.inter_reordering import PromptProcessor
import json
import argparse
def parse_args():
parser = argparse.ArgumentParser(description="Reorder prompt data based on clustering results.")
parser.add_argument('--prompt_path', type=str, required=True, help='Path to the JSONL file containing prompt data.')
return parser.parse_args()
def main():
args = parse_args()
# Load prompts from the specified path
prompt_path = args.prompt_path
with open(prompt_path, 'r') as f:
prompts = [json.loads(line) for line in f]
qids = [prompt['qid'] for prompt in prompts]
questions = [prompt['text'] for prompt in prompts]
answers = [prompt['answer'] for prompt in prompts]
topk_doc_ids = [prompt['top_k_doc_id'] for prompt in prompts]
processer = PromptProcessor(use_gpu=True)
# Perform clustering (Intra-reordering)
result = cluster_prompts(topk_doc_ids, similarity_method="sharp", use_triton=True)
# Perform inter-reordering
organized_reordered_ids, _, final_index_mapping = processer.process_and_reorder(result.reordered_prompts, topk_doc_ids, show_progress=True)
# Results
reorded_qids = [qids[i] for i in final_index_mapping]
reorded_questions = [questions[i] for i in final_index_mapping]
reorded_answers = [answers[i] for i in final_index_mapping]
reorded_topk_doc_ids = organized_reordered_ids
return reorded_qids, reorded_questions, reorded_answers, reorded_topk_doc_ids
if __name__ == "__main__":
reorded_qids, reorded_questions, reorded_answers, reorded_topk_doc_ids = main()
The example code is in examples/planner/example.py
Metadata
Release files for promptplanner 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptplanner-0.0.1.tar.gz | 33.5 kB | Without provenance | Details for promptplanner-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptplanner-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for promptplanner-0.0.1-py3-none-any.whl |
Total release size: 72.0 kB
Release files / promptplanner-0.0.1.tar.gz
| Download URL | promptplanner-0.0.1.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7fb11e8af839ce8a3a1da87e5e0545d2f62018a82f302cec2394fe338daf4b1
|
|
BLAKE2b-256 checksum How to use checksums |
57ec8c98ceb8af36d6de0dcebaf0e5268320071160864daac1df0d1ebc6b510b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / promptplanner-0.0.1-py3-none-any.whl
| Download URL | promptplanner-0.0.1-py3-none-any.whl |
|---|---|
| Size | 38.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64a8bf755aa135384e1fe05ec3bbe72841f1ceba87a8b9baa83851efbbebe5d8
|
|
BLAKE2b-256 checksum How to use checksums |
b7b2bc0f8f2c4d7e792c2dd2ae34989a688c0dc0a0105971dbfe6601acbd2ea4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for promptplanner 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.