Skip to content
Snippets Groups Projects
Commit 9085b97f authored by Grießhaber Daniel's avatar Grießhaber Daniel :squid:
Browse files

use lru_cache to cache performance for already seen prompts

parent c73dea3c
No related branches found
No related tags found
No related merge requests found
from functools import partial from functools import lru_cache, partial
from pathlib import Path from pathlib import Path
from typing import DefaultDict from typing import DefaultDict
...@@ -169,7 +169,7 @@ if __name__ == "__main__": ...@@ -169,7 +169,7 @@ if __name__ == "__main__":
D = load_dataset("SetFit/sst2", split="validation[:200]") D = load_dataset("SetFit/sst2", split="validation[:200]")
# - fD(·) denotes the score of a prompt on the desired LLM evaluated on D # - fD(·) denotes the score of a prompt on the desired LLM evaluated on D
f_D = partial(evaluate_prompt, dataset=D) f_D = lru_cache(maxsize=None)(partial(evaluate_prompt, dataset=D))
# - a pre-defined number of iterations T # - a pre-defined number of iterations T
T = 10 T = 10
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment