A Prompt Sensitivity Index for Language Models
Project description
About POSIX
POSIX is a simple and easy-to-use Python Library to evaluate prompt sensitivity of Language Models.
Installation
The simplest way to install POSIX is via pip:
pip install prompt-sensitivity-index
You can also install POSIX from source:
git clone https://github.com/kowndinya-renduchintala/POSIX.git
cd POSIX
pip install .
Example Usage
from prompt_sensitivity_index.models import HFModel
from prompt_sensitivity_index.posix import (
PosixConfig,
PosixTrace,
get_prompt_sensitivity,
write_trace_to_json
)
intent_aligned_prompts=[
[
"Q: What is the capital of France?\nA: ",
"Q: WHat is te capital city of France?\nA: ",
"Q: what is teh cpital of france??\nA: "
],
[
"Q: What is the national animal of India?\nA: ",
"Q: What's the national animl of India?\nA: ",
"Q: WHat is teh national animal of India?\nA: "
],
[
"Q: Tell me the meaning of rendezvous?\nA: ",
"Q: WHat is the meaning of rendezvous?\nA: ",
"Q: What does rendezvous mean?\nA: "
]
]
model=HFModel("openai-community/gpt2")
config=PosixConfig(max_new_tokens=5, batched=False)
posix, trace=get_prompt_sensitivity(model, intent_aligned_prompts, config, verbose=True)
print(f"Prompt Sensitivity Index: {posix}")
write_trace_to_json(trace, "posix_trace.json")
Citation
If you use POSIX in your research, please cite of our EMNLP 2024 paper (aclanthology version coming soon...)
POSIX: A Prompt Sensitivity Index For Large Language Models:
@article{chatterjee2024posix,
title={POSIX: A Prompt Sensitivity Index For Large Language Models},
author={Chatterjee, Anwoy and Renduchintala, HSVNS Kowndinya and Bhatia, Sumit and Chakraborty, Tanmoy},
journal={arXiv preprint arXiv:2410.02185},
year={2024}
}
License
POSIX is licensed under the MIT License. See LICENSE for more information.
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
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 prompt_sensitivity_index-0.0.1.tar.gz.
File metadata
- Download URL: prompt_sensitivity_index-0.0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae25080ee3e11e6f3a216200adbda22437e1cdfa6f32be586162e24bea50440
|
|
| MD5 |
e3bde486c2709b94e29b8edd4796f280
|
|
| BLAKE2b-256 |
7d2a29d4125b3a2e50e696ea84102d19d6fcee107320ae22e114d4dffa63c047
|
File details
Details for the file prompt_sensitivity_index-0.0.1-py3-none-any.whl.
File metadata
- Download URL: prompt_sensitivity_index-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00993969f7f7446bad55f1cbd89190fd8b709a1f066b5174a5ddd71ff00c8e5a
|
|
| MD5 |
cdec0e796faa7833eae418a2f540ce0e
|
|
| BLAKE2b-256 |
e58e5eaca300f9341ed51b8c17fab297335dc917d26fbcb2af9d03b6777acf61
|