No project description provided
Project description
Genetic Prompt Compiler
Optimize a prompt for a language model using a genetic algorithm.
import genetic_compiler
from genetic_compiler import GeneticCompilerArgs
initial_prompt = ""
rules = [
"Rule 1",
"Rule 2",
"Rule 3",
]
args = GeneticCompilerArgs(
# The rating notation to use (X/10, X/5 etc.)
rating_notation=10,
# Amount of examples to test on prompts in each generation
example_amount=3,
# Top n prompts to keep in each generation
top_n=3,
# Amount of prompts to generate in each generation
popultation_size=8,
# Amount of generations to run
iterations=3,
# Initial prompt to start with.
# This prompt will be kept for the first generation, alongside propulation_size - 1 mutated versions of it
initial_prompt=initial_prompt,
# Rules to test the prompts on
rules=rules,
# Log level
log_level="INFO",
# Test data to test the prompts on (Currently only the answers are used)
train_data=train_data,
# LiteLLM arguments for the fitness model (This llm will evaluate the prompts)
fitness_model_args={
"model": "gpt-4",
"temperature": 0.1,
},
# LiteLLM arguments for the student model (This is the llm we want to optimize)
student_model_args={
"model": "openai/TheBloke/Mistral-7B-Instruct-v0.2-AWQ",
"api_base": "http://127.0.0.1:8000/v1",
"temperature": 0.1,
},
# LiteLLM arguments for the mutation model (This llm will mutate the prompts)
mutation_model_args={
"model": "gpt-4",
"temperature": 0.3,
},
)
for population in genetic_compiler.run(args):
top_prompt = population[0]
print(f"Top prompt: {top_prompt}")
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
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 genetic_prompt_compiler-0.1.1.tar.gz.
File metadata
- Download URL: genetic_prompt_compiler-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5ea95434a86f631476db0135c385bbf5ac63568274e0c276dab0ffca5f42a59
|
|
| MD5 |
69917e42e7978bcbb0bedc1c30f783e5
|
|
| BLAKE2b-256 |
dc9aecf59f06302b4e3964443cb1263b544801cd8083824630633b5f52038ef3
|
File details
Details for the file genetic_prompt_compiler-0.1.1-py3-none-any.whl.
File metadata
- Download URL: genetic_prompt_compiler-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492137cb6ac8f1089c03131b87d184461b21268a749278163a3ac62341021720
|
|
| MD5 |
153d5cf98d6dd86640afe206e18df603
|
|
| BLAKE2b-256 |
7327154bbb66e5ad227130fa51ad861236df59a1ec4183fa377671a38030cb79
|