Biomedical Informatics lab tutorials for how to use the OpenAI API.
openai-tutorialslab
├── .env # contains your OPENAI_API_KEY
├── Dockerfile # recipe for latest JupyterLab datascience-notebook and openai
├── NHLBI-BDC-openai-logprobs.ipynb
└── README.mdThe .env file should look like this:
OPENAI_API_KEY=sk-letslearntheopenaiAPIUsing the openAI Python library, we can connect to the client using this snippet:
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
client = OpenAI()NHLBI-BDC-openai-logprobs.ipynb
- Classify cardiac research article abstracts into a set of predefined categories and evaluate the log probability. Demonstrates chat prompt engineering using
chat.completions.createandmodel=gpt-3.5-turbowith thelogprobsandtop_logprobsparameters set for evaluating the confidence of the model's predictions. - Retrieve confidence scoring for congenital heart disease prompt questions using an article's abstract result section to reduce hallucinations.
- Autocomplete each predicted token in a sentence using
logprobsto assess how confident a model is in its prediction for thetop_logprobs=3. - Highlight tokens using the
logprobsandbytesparameter. Evaluate thelogprobsfor a token and ASCII.
sudo docker pull apblair/openai-tutorialslab:nhlbi-bdcNext run the JupyterLab container, open a browser to localhost:8888, and copy/paste the paste the JupyerLab password.
sudo docker run it -p 8888:8888 -v $(pwd):/home/jovyan/work apblair/openai-tutorialslab:nhlbi-bdc