Following a discussion with @ravwojdyla, he suggested checking how varied the outputs of GPT-4 get when generating several completions for a single prompt. This PR adds support for the n parameter of openai's API.
Here is an example of output (from the updated readme):
from pprint import pprint
from nxontology_ml.data import get_efo_otar_slim
from nxontology_ml.gpt_tagger import TaskConfig, GptTagger
from nxontology_ml.utils import ROOT_DIR
# Create a config for EFO nodes labelling
config = TaskConfig(
name="precision",
prompt_path=ROOT_DIR / "prompts/precision_v1.txt",
openai_model_name="gpt-4",
node_attributes=["efo_id", "efo_label", "efo_definition"],
model_n=3,
)
# Get a few EFO nodes
nxo = get_efo_otar_slim()
nodes = (nxo.node_info(node) for node in sorted(nxo.graph)[:20])
# Get their labels
tagger = GptTagger.from_config(config)
for ln in tagger.fetch_labels(nodes):
print(f"{ln.node_efo_id}: {ln.labels}")
# Inspect metrics
print("\nTagger metrics:")
pprint(tagger.get_metrics())
Following a discussion with @ravwojdyla, he suggested checking how varied the outputs of GPT-4 get when generating several completions for a single prompt. This PR adds support for the
n
parameter of openai's API.Here is an example of output (from the updated readme):
You should get an output similar to: