Welcome to the Responsible Finetuning (RFT) Demo for Microsoft Build! This guide will walk you through setting up your environment and running the demo.ipynb notebook.
Before you begin, ensure you have the following installed:
- Python (3.8 or higher recommended)
- pip (Python package installer)
- Jupyter Notebook or JupyterLab
Follow these steps to prepare your environment:
-
Clone the Repository (if applicable) If you haven't already, clone the repository containing this demo to your local machine.
# Example: git clone <repository-url> # cd <repository-folder>/MSBuildRFTDemo
-
Install Dependencies 📦 Open your terminal or command prompt in the
MSBuildRFTDemofolder (wheredemo.ipynbandrequirements.txtare located) and run:pip install -r requirements.txt
This will install all the necessary Python libraries for the RFT demo.
-
Configure Environment Variables 🔑 You'll need to set up API keys and other configurations. Create a file named
.envin theMSBuildRFTDemofolder and add the following content, replacing the placeholders with your actual values:AZURE_API_KEY="YOUR_AZURE_OPENAI_API_KEY_HERE" AZURE_API_ENDPOINT="YOUR_AZURE_OPENAI_ENDPOINT_HERE" API_VERSION="YOUR_AZURE_OPENAI_API_VERSION_HERE" # e.g., 2023-07-01-preview
⚠️ Important: Do not commit your.envfile to version control if it contains sensitive credentials. Ensure it's listed in your.gitignorefile.
Once your environment is set up, you can run the demo:
-
Launch Jupyter Notebook 🚀 In your terminal, navigate to the
MSBuildRFTDemofolder and start Jupyter Notebook:jupyter notebook
Or, if you prefer JupyterLab:
jupyter lab
This will open Jupyter in your web browser.
-
Open
demo.ipynb📂 In the Jupyter interface, click ondemo.ipynbto open the notebook. -
Execute the Cells
▶️ Run the cells in the notebook sequentially. You can do this by:- Clicking the "Run" button in the toolbar for each cell.
- Using the keyboard shortcut
Shift + Enterto run the current cell and move to the next. - Selecting "Cell" > "Run All" from the menu bar to run all cells at once.
The notebook will guide you through:
- 📊 Loading and preparing data for finetuning.
- 🛡️ Applying Responsible AI techniques during the finetuning process.
- 🤖 Evaluating the performance and safety of the finetuned model.
- 📈 Visualizing the results and RFT metrics.
- API Key Errors: If you encounter errors related to API keys, double-check your
.envfile for typos or incorrect values. Ensure the keys have the necessary permissions for Azure OpenAI and any other services used. - Missing Modules: If you get
ModuleNotFoundError, ensure you have runpip install -r requirements.txtin the correct Python environment. - Kernel Issues: If the notebook kernel has problems, try restarting it ("Kernel" > "Restart" in the Jupyter menu).
- RFT Specifics: This demo utilizes specific RFT tools and configurations. Refer to the comments within
demo.ipynbfor detailed explanations of each step.
Thank you for checking out the RFT Demo at Microsoft Build! ✨