diff --git a/example.ipynb b/example.ipynb index 202e8e1..4cc35de 100644 --- a/example.ipynb +++ b/example.ipynb @@ -37,19 +37,8 @@ "text": [ "/media/wassname/SGIronWolf/projects5/2024/prob_jsonformer/.venv/lib/python3.9/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", " warnings.warn(\n", - "`flash-attention` package not found, consider installing for better performance: No module named 'flash_attn'.\n", - "Current `flash-attenton` does not support `window_size`. Either upgrade or use `attn_implementation='eager'`.\n", - "Loading checkpoint shards: 100%|██████████| 4/4 [00:02<00:00, 1.94it/s]\n", "/media/wassname/SGIronWolf/projects5/2024/prob_jsonformer/.venv/lib/python3.9/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", - " warnings.warn(\n", - "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Loaded model and tokenizer\n" + " warnings.warn(\n" ] } ], @@ -58,8 +47,8 @@ "import torch\n", "\n", "print(\"Loading model and tokenizer...\")\n", - "# model_name = \"databricks/dolly-v2-3b\"\n", - "model_name = \"failspy/kappa-3-phi-abliterated\"\n", + "model_name = \"databricks/dolly-v2-3b\"\n", + "# model_name = \"failspy/kappa-3-phi-abliterated\"\n", "model = AutoModelForCausalLM.from_pretrained(\n", " model_name,\n", " use_cache=True,\n", @@ -67,135 +56,12 @@ " # device=\"cuda:0\",\n", " # device_map=\"auto\",\n", " attn_implementation='eager',\n", - " trust_remote_code=True,\n", + " # trust_remote_code=True,\n", ").to(\"cuda:0\")\n", "tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=True, use_cache=True)\n", "print(\"Loaded model and tokenizer\")" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Scratch" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "# from jaxtyping import Float, Int\n", - "# import torch\n", - "# from torch.nn import functional as F\n", - "# from torch import Tensor\n", - "# from typing import List, Callable, Tuple, Dict, Optional\n", - "# import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# # initital state\n", - "# prompt = \"The necromancer in his tower, what's his top problem? \"\n", - "# choices = [\"1\", \"the skeleton\", \"the boney boys\"]\n", - "# choices_tokens = tokenizer(choices).input_ids\n", - "# choices_tokens = [torch.tensor(c) for c in choices_tokens]\n", - "# # current_tokens = torch.tensor([])\n", - "\n", - "# # next\n", - "# input_ids = tokenizer([prompt], return_tensors=\"pt\").to(model.device).input_ids[0]\n", - "# choices_tokens\n", - "\n", - "# # for each next choice, continue down the tree, recording the log probs" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# def get_valid_next_choices(choices_tokens, current_tokens):\n", - "# next_choices = []\n", - "# for choice_tokens in choices_tokens:\n", - "# # if we have some more slots left\n", - "# if len(current_tokens)