GithubHelp home page GithubHelp logo

apcuad / patient-psi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruiyiw/patient-psi

0.0 0.0 0.0 2.59 MB

PATIENT-Ψ: Using Large Language Models to Simulate Patients for Training Mental Health Professionals

Home Page: https://arxiv.org/abs/2405.19660

License: Apache License 2.0

Shell 0.06% JavaScript 3.06% Python 3.31% TypeScript 92.90% CSS 0.66%

patient-psi's Introduction

patient-psi

Patient-Ψ: Using Large Language Models to Simulate Patients for Training Mental Health Professionals

Paper PDF huggingface Python 3.11 twitter Code License

📌 Table of Contents

Get started on local computer

Install

We recommend starting a virtual environment with miniconda (quick command line installation):

conda create -n patient-psi python=3.11.0

Then install requirements for python3 and for Next.js-based Vercel app.

# Python packages
pip install -r requirements.txt

# Next.js dependencies
conda install -c conda-forge nodejs
npm install -g [email protected]
npn install -g ts-node
npm install -g vercel

Set up Vercel app

First, create a Vercel account via the Vercel website.

Then, fork this repo, and create a Vercel project and a KV database linked to it. Follow the video clip for instructions.

video clip

After this, go back to the terminal. Run vercel link and fill in the credentials to connect to the Vercel project just created.

Under your forked repo, run the following to create a .env.local file with automatically imported environment variables of the KV database.

vercel env pull .env.local

You need to add two additional environment variables to the .env.local file manually. We provide an example at .env.example.

  • AUTH_SECRET: use either openssl rand -base64 32 or an automatic generator to generate a random secret.
  • OPENAI_API_KEY: plug in your OpenAI API key.

Run the following commands under your forked repo to update the additional environment variables to the Vercel project settings. The Vercel app will prompt you to fill out the corresponding values and ask you to select the environments to add to. Please toggle all environments (production, development, preview).

vercel env add AUTH_SECRET
vercel env add OPENAI_API_KEY

To check if the above setup is successful, go to your Vercel project page, and navigate to Settings -> Environment Variables, and there should be at least 6 key-value pairs as shown in .env.example.

Note: You should not commit your .env file anywhere.

Quickly start the Patient-Ψ-Trainer

After setting up the Vercel app, you can quickly upload sample cognitive models to the KV database and start the Patient-Ψ-Trainer powered by GPT-4.

We provide example patient cognitive models in file python/data/profiles.json, which are publically available on Beck Institute website.

First, upload the profiles to your KV database by running the code.

ts-node lib/utils/kvDatabaseFunctions.ts 

Second, run the following to start the server on localhost:8001.

pnpm install
pnpm dev --port 8001

The app should be started on http://localhost:8001/signup. Please sign up with any 6 characters at minimum.

Cognitive model generation - Patient-Ψ-CM dataset

Folder python/ contains the code for producing the Patient-Ψ-CM dataset. We provide an example transcript excerpt from CBT therapy, which is publicly available on Beck Institute website.

Run the following commands to construct the cognitive models. Make sure you update the OPENAI_API_KEY in python/.env

cd python
python3 -m generation.generate --transcript-file "example_transcript.txt" --out-file "example_CCD_from_transcript.json"

Note: You should not commit you .env file anywhere. Make sure to update the variables in python/.env if you want to use your custom folder.

Prompts for Patient-Ψ

The prompts for different conversational styles can be found in this folder

The prompts for simulating a patient with a cognitive model can be found in this function

Citation

@misc{wang2024patientpsi,
      title={PATIENT-{\Psi}: Using Large Language Models to Simulate Patients for Training Mental Health Professionals}, 
      author={Ruiyi Wang and Stephanie Milani and Jamie C. Chiu and Jiayin Zhi and Shaun M. Eack and Travis Labrum and Samuel M. Murphy and Nev Jones and Kate Hardy and Hong Shen and Fei Fang and Zhiyu Zoey Chen},
      year={2024},
      eprint={2405.19660},
      archivePrefix={arXiv},
      primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
}

patient-psi's People

Contributors

ruiyiw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.