We've published a new paper on PDO (Prompt Duel Optimizer) - an efficient label-free prompt optimization method using dueling bandits and Thompson sampling. PDO achieves state-of-the-art results on BIG-bench Hard and MS MARCO benchmarks.
๐ Read the paper: LLM Prompt Duel Optimizer: Efficient Label-Free Prompt Optimization (arXiv:2510.13907)
๐งช Try it yourself: Check out the Web of Lies use case demonstrating PDO on logical reasoning tasks
โญ Star this repo and follow along - we'll be publishing a detailed tutorial notebook soon!
prompt-ops is a Python package that automatically optimizes prompts for Llama models. It transforms prompts that work well with other LLMs into prompts that are optimized for LLM models, improving performance and reliability.
Key Benefits:
To get started with prompt-ops, you'll need:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ Existing System Prompt โ โ set(query, responses) โ โ YAML Configuration โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโ โโโโโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ prompt-ops migrate โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Optimized Prompt โ
โโโโโโโโโโโโโโโโโโโโโโโโ
![]() |
These results were measured on the HotpotQA multi-hop reasoning benchmark, which tests a model's ability to answer complex questions requiring information from multiple sources. Our optimized prompts showed substantial improvements over baseline prompts across different model sizes.
Note: We recommend installing from source as we are currently transitioning package names on PyPI. This ensures you get the latest stable version without any naming conflicts.
# Create a virtual environment
conda create -n prompt-ops python=3.10
conda activate prompt-ops
# Recommended: Install from source
git clone https://github.com/meta-llama/prompt-ops.git
cd prompt-ops
pip install -e .
# Alternative: Install from PyPI (may have naming transition issues, still on version 0.0.7)
# pip install llama-prompt-ops
This will create a directory called my-project with a sample configuration and dataset in the current folder.
prompt-ops create my-project
cd my-project
Add your API key to the .env file:
OPENROUTER_API_KEY=your_key_here
prompt-ops uses LiteLLM as a unified API client. LiteLLM automatically detects the provider from your model name (e.g., openrouter/model, groq/model) and looks for the corresponding provider-specific environment variable (OPENROUTER_API_KEY, GROQ_API_KEY, etc.). For more inference provider options, see Inference Providers.
The optimization will take about 5 minutes.
prompt-ops migrate # defaults to config.yaml if --config not specified
Done! The optimized prompt will be saved to the results directory with performance metrics comparing the original and optimized versions.
To read more about this use case, we go into more detail in Basic Tutorial.
Below is an example of a transformed system prompt from proprietary LM to Llama:
| Original Proprietary LM Prompt | Optimized Llama Prompt |
|---|---|
| You are a helpful assistant. Extract and return a JSON with the following keys and values: 1. "urgency": one of high, medium, low2. "sentiment": one of negative, neutral, positive3. "categories": Create a dictionary with categories as keys and boolean values (True/False), where the value indicates whether the category matches tags like emergency_repair_services, routine_maintenance_requests, etc.Your complete message should be a valid JSON string that can be read directly. | You are an expert in analyzing customer service messages. Your task is to categorize the following message based on urgency, sentiment, and relevant categories. Analyze the message and return a JSON object with these fields: 1. "urgency": Classify as "high", "medium", or "low" based on how quickly this needs attention 2. "sentiment": Classify as "negative", "neutral", or "positive" based on the customer's tone 3. "categories": Create a dictionary with facility management categories as keys and boolean values Only include these exact keys in your response. Return a valid JSON object without code blocks, prefixes, or explanations. |
To use prompt-ops for prompt optimization, you'll need to prepare a dataset with your prompts and expected responses. The standard format is a JSON file structured like this:
[
{
"question": "Your input query here",
"answer": "Expected response here"
},
{
"question": "Another input query",
"answer": "Another expected response"
}
]
If your data matches this format, you can use the built-in StandardJSONAdapter which will handle it automatically.
If your data is formatted differently, and there isn't a built-in dataset adapter, you can create a custom dataset adapter by extending the DatasetAdapter class. See the Dataset Adapter Selection Guide for more details.
prompt-ops supports various inference providers and endpoints to fit your infrastructure needs. See our detailed guide on inference providers for configuration examples with:
For more detailed information, check out these resources:
This project leverages some of awesome open source projects including DSPy, thanks to the team for the inspiring work!
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Python
43.9%
TypeScript
30.3%
Jupyter Notebook
24.8%
We've published a new paper on PDO (Prompt Duel Optimizer) - an efficient label-free prompt optimization method using dueling bandits and Thompson sampling. PDO achieves state-of-the-art results on BIG-bench Hard and MS MARCO benchmarks.
๐ Read the paper: LLM Prompt Duel Optimizer: Efficient Label-Free Prompt Optimization (arXiv:2510.13907)
๐งช Try it yourself: Check out the Web of Lies use case demonstrating PDO on logical reasoning tasks
โญ Star this repo and follow along - we'll be publishing a detailed tutorial notebook soon!
prompt-ops is a Python package that automatically optimizes prompts for Llama models. It transforms prompts that work well with other LLMs into prompts that are optimized for LLM models, improving performance and reliability.
Key Benefits:
To get started with prompt-ops, you'll need:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ Existing System Prompt โ โ set(query, responses) โ โ YAML Configuration โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโ โโโโโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ prompt-ops migrate โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Optimized Prompt โ
โโโโโโโโโโโโโโโโโโโโโโโโ
![]() |
These results were measured on the HotpotQA multi-hop reasoning benchmark, which tests a model's ability to answer complex questions requiring information from multiple sources. Our optimized prompts showed substantial improvements over baseline prompts across different model sizes.
Note: We recommend installing from source as we are currently transitioning package names on PyPI. This ensures you get the latest stable version without any naming conflicts.
# Create a virtual environment
conda create -n prompt-ops python=3.10
conda activate prompt-ops
# Recommended: Install from source
git clone https://github.com/meta-llama/prompt-ops.git
cd prompt-ops
pip install -e .
# Alternative: Install from PyPI (may have naming transition issues, still on version 0.0.7)
# pip install llama-prompt-ops
This will create a directory called my-project with a sample configuration and dataset in the current folder.
prompt-ops create my-project
cd my-project
Add your API key to the .env file:
OPENROUTER_API_KEY=your_key_here
prompt-ops uses LiteLLM as a unified API client. LiteLLM automatically detects the provider from your model name (e.g., openrouter/model, groq/model) and looks for the corresponding provider-specific environment variable (OPENROUTER_API_KEY, GROQ_API_KEY, etc.). For more inference provider options, see Inference Providers.
The optimization will take about 5 minutes.
prompt-ops migrate # defaults to config.yaml if --config not specified
Done! The optimized prompt will be saved to the results directory with performance metrics comparing the original and optimized versions.
To read more about this use case, we go into more detail in Basic Tutorial.
Below is an example of a transformed system prompt from proprietary LM to Llama:
| Original Proprietary LM Prompt | Optimized Llama Prompt |
|---|---|
| You are a helpful assistant. Extract and return a JSON with the following keys and values: 1. "urgency": one of high, medium, low2. "sentiment": one of negative, neutral, positive3. "categories": Create a dictionary with categories as keys and boolean values (True/False), where the value indicates whether the category matches tags like emergency_repair_services, routine_maintenance_requests, etc.Your complete message should be a valid JSON string that can be read directly. | You are an expert in analyzing customer service messages. Your task is to categorize the following message based on urgency, sentiment, and relevant categories. Analyze the message and return a JSON object with these fields: 1. "urgency": Classify as "high", "medium", or "low" based on how quickly this needs attention 2. "sentiment": Classify as "negative", "neutral", or "positive" based on the customer's tone 3. "categories": Create a dictionary with facility management categories as keys and boolean values Only include these exact keys in your response. Return a valid JSON object without code blocks, prefixes, or explanations. |
To use prompt-ops for prompt optimization, you'll need to prepare a dataset with your prompts and expected responses. The standard format is a JSON file structured like this:
[
{
"question": "Your input query here",
"answer": "Expected response here"
},
{
"question": "Another input query",
"answer": "Another expected response"
}
]
If your data matches this format, you can use the built-in StandardJSONAdapter which will handle it automatically.
If your data is formatted differently, and there isn't a built-in dataset adapter, you can create a custom dataset adapter by extending the DatasetAdapter class. See the Dataset Adapter Selection Guide for more details.
prompt-ops supports various inference providers and endpoints to fit your infrastructure needs. See our detailed guide on inference providers for configuration examples with:
For more detailed information, check out these resources:
This project leverages some of awesome open source projects including DSPy, thanks to the team for the inspiring work!
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Python
43.9%
TypeScript
30.3%
Jupyter Notebook
24.8%