{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Tutorial\n", "\n", "This notebook walks through how to use dialz to:\n", "- load an existing dataset\n", "- create a steering vector\n", "- generate modified outputs using the steering vector\n", "- visualize the similarity of the vector to various inputs over all layers in a model" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "%%capture\n", "import os\n", "from transformers import AutoTokenizer\n", "from dialz import Dataset, SteeringModel, SteeringVector, get_activation_score, visualize_activation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Declare a model name (this can be any transformer model on HuggingFace)\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "model_name = \"mistralai/Mistral-7B-Instruct-v0.1\"\n", "dataset = Dataset.load_dataset(model_name, 'stereoset-race')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8a44ff74bafd4214a4e8c02204a579b2", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Loading checkpoint shards: 0%| | 0/2 [00:00