{ "cells": [ { "cell_type": "markdown", "id": "e25090fa-f990-4f1a-84f3-b12159eedae8", "metadata": {}, "source": [ "# Working with a Large Language Model (LLM)" ] }, { "cell_type": "markdown", "id": "3bbee2e4-55c8-4b06-9929-72026edf7932", "metadata": {}, "source": [ "## Prerequisites" ] }, { "cell_type": "code", "execution_count": 1, "id": "f8c28d2d-8458-49fd-8ebf-5e729d6e861f", "metadata": {}, "outputs": [], "source": [ "import math\n", "import json\n", "import pickle\n", "import os\n", "import time\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from tabulate import tabulate\n", "from transformers import pipeline\n", "\n", "# Get candidate labels\n", "with open(\"packing_label_structure.json\", \"r\") as file:\n", " candidate_labels = json.load(file)\n", "keys_list = list(candidate_labels.keys())\n", "\n", "# Load test data (list of dictionaries)\n", "with open(\"test_data.json\", \"r\") as file:\n", " packing_data = json.load(file)\n", "# Extract trip descriptions and classification (trip_types)\n", "trip_descriptions = [trip['description'] for trip in packing_data]\n", "trip_types = [trip['trip_types'] for trip in packing_data]" ] }, { "cell_type": "markdown", "id": "5cf4f76f-0035-44e8-93af-52eafaec686e", "metadata": {}, "source": [ "**All trip descriptions**" ] }, { "cell_type": "code", "execution_count": 2, "id": "89d42ca7-e871-4eda-b428-69e9bd965428", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 . I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands. \n", "\n", "beach vacation\n", "['swimming', 'going to the beach', 'relaxing', 'hiking']\n", "warm destination / summer\n", "lightweight (but comfortable)\n", "casual\n", "indoor\n", "no own vehicle\n", "no special conditions to consider\n", "7+ days\n", "\n", "\n", "1 . We are a couple in our thirties traveling to Vienna for a three-day city trip. We’ll be staying at a friend’s house and plan to explore the city by sightseeing, strolling through the streets, visiting markets, and trying out great restaurants and cafés. We also hope to attend a classical music concert. Our journey to Vienna will be by train. \n", "\n", "city trip\n", "['sightseeing']\n", "variable weather / spring / autumn\n", "luxury (including evening wear)\n", "casual\n", "indoor\n", "no own vehicle\n", "no special conditions to consider\n", "3 days\n", "\n", "\n", "2 . My partner and I are traveling to the Netherlands and Germany to spend Christmas with our family. We are in our late twenties and will start our journey with a two-hour flight to the Netherlands. From there, we will take a 5.5-hour train ride to northern Germany. \n", "\n", "city trip\n", "['relaxing']\n", "cold destination / winter\n", "lightweight (but comfortable)\n", "casual\n", "indoor\n", "no own vehicle\n", "no special conditions to consider\n", "7+ days\n", "\n", "\n", "3 . I’m in my twenties and will be traveling to Peru for three weeks. I’m going solo but will meet up with a friend to explore the Sacred Valley and take part in a Machu Picchu tour. We plan to hike, go rafting, and explore the remnants of the ancient Inca Empire. We’re also excited to try Peruvian cuisine and immerse ourselves in the local culture. Depending on our plans, we might also visit the rainforest region, such as Tarapoto. I’ll be flying to Peru on a long-haul flight and will be traveling in August. \n", "\n", "cultural exploration\n", "['sightseeing', 'hiking', 'rafting']\n", "variable weather / spring / autumn\n", "lightweight (but comfortable)\n", "casual\n", "indoor\n", "no own vehicle\n", "rainy climate\n", "7+ days\n", "\n", "\n", "4 . We’re planning a 10-day trip to Austria in the summer, combining hiking with relaxation by the lake. We love exploring scenic trails and enjoying the outdoors, but we also want to unwind and swim in the lake. It’s the perfect mix of adventure and relaxation. \n", "\n", "nature escape\n", "['swimming', 'relaxing', 'hiking']\n", "warm destination / summer\n", "lightweight (but comfortable)\n", "casual\n", "indoor\n", "no own vehicle\n", "no special conditions to consider\n", "7+ days\n", "\n", "\n", "5 . I am going on a multiple day hike and passing though mountains and the beach in Croatia. I like to pack light and will stay in refugios/huts with half board and travel to the start of the hike by car. It will be 6-7 days. \n", "\n", "long-distance hike / thru-hike\n", "['going to the beach']\n", "tropical / humid\n", "minimalist\n", "casual\n", "huts with half board\n", "own vehicle\n", "off-grid / no electricity\n", "6 days\n", "\n", "\n", "6 . I will go with a friend on a beach holiday and we will do stand-up paddling, and surfing in the North of Spain. The destination is windy and can get cold, but is generally sunny. We will go by car and bring a tent to sleep in. It will be two weeks. \n", "\n", "beach vacation\n", "['stand-up paddleboarding (SUP)', 'surfing']\n", "cold destination / winter\n", "ultralight\n", "casual\n", "sleeping in a tent\n", "own vehicle\n", "off-grid / no electricity\n", "6 days\n", "\n", "\n", "7 . We will go to Sweden in the winter, to go for a yoga and sauna/wellness retreat. I prefer lightweight packing and also want clothes to go for fancy dinners and maybe on a winter hike. We stay in hotels. \n", "\n", "yoga / wellness retreat\n", "['hiking', 'yoga']\n", "cold destination / winter\n", "lightweight (but comfortable)\n", "casual\n", "indoor\n", "no own vehicle\n", "snow and ice\n", "7 days\n", "\n", "\n", "8 . I go on a skitouring trip where we also make videos/photos and the destination is Japan. Mainly sports clothes and isolation are needed (it is winter). We stay in a guesthouse. It will be 10 days. \n", "\n", "ski tour / skitour\n", "['ski touring', 'photography']\n", "cold destination / winter\n", "minimalist\n", "conservative\n", "indoor\n", "no own vehicle\n", "avalanche-prone terrain\n", "7+ days\n", "\n", "\n", "9 . We plan a wild camping trip with activities such as snorkeling, kayaking and canoeing. It is a warm place and we want to bring little stuff. We stay in tents and hammocks and travel with a car, it will be 3 days. \n", "\n", "camping trip (wild camping)\n", "['scuba diving', 'kayaking / canoeing']\n", "tropical / humid\n", "lightweight (but comfortable)\n", "casual\n", "sleeping in a tent\n", "own vehicle\n", "self-supported (bring your own cooking gear)\n", "3 days\n", "\n", "\n" ] } ], "source": [ "for i, item in enumerate(trip_descriptions):\n", " print(i, \".\", item, \"\\n\")\n", " for elem in trip_types[i]:\n", " print(elem)\n", " print(\"\\n\")" ] }, { "cell_type": "markdown", "id": "0f60c54b-affc-4d9a-acf1-da70f68c5578", "metadata": {}, "source": [ "**Functions**" ] }, { "cell_type": "code", "execution_count": 3, "id": "fac51224-9575-4b4b-8567-4ad4e759ecc9", "metadata": {}, "outputs": [], "source": [ "def pred_trip(model_name, trip_descr, trip_type, cut_off = 0.5):\n", " \"\"\"\n", " Classifies trip\n", " \n", " Parameters:\n", " model_name: name of hugging-face model\n", " trip_descr: text describing the trip\n", " trip_type: true trip classification\n", " cut_off: cut_off for choosing activities\n", "\n", " Returns:\n", " pd Dataframe: with class predictions and true values\n", " \"\"\"\n", " \n", " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n", " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n", " for i, key in enumerate(keys_list):\n", " print(i)\n", " if key == 'activities':\n", " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n", " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n", " classes = [result['labels'][i] for i in indices]\n", " else:\n", " result = classifier(trip_descr, candidate_labels[key])\n", " classes = result[\"labels\"][0]\n", " df.loc[i] = [key, classes]\n", " df['true_class'] = trip_type\n", " return df" ] }, { "cell_type": "code", "execution_count": 4, "id": "b36ab806-2f35-4950-ac5a-7c192190cba7", "metadata": {}, "outputs": [], "source": [ "def perf_measure(df):\n", " \"\"\"\n", " Calculates performance measures:\n", " Accuracy of classification excluding activities superclass\n", " Percentage of correctly identified activities (#correctly predicted/#true activities)\n", " Percentage of wrongly identified activities (#wrongly predicted/#predicted activities)\n", "\n", " Parameters:\n", " df: pd Dataframe returned from pred_trip()\n", "\n", " Returns:\n", " pd Dataframe: containing performance measures\n", " \"\"\"\n", " \n", " df['same_value'] = df['pred_class'] == df['true_class']\n", " correct = sum(df.loc[df.index != 1, 'same_value'])\n", " total = len(df['same_value'])\n", " accuracy = correct/total\n", " pred_class = df.loc[df.index == 1, 'pred_class'].iloc[0]\n", " true_class = df.loc[df.index == 1, 'true_class'].iloc[0]\n", " correct = [label for label in pred_class if label in true_class]\n", " num_correct = len(correct)\n", " correct_perc = num_correct/len(true_class)\n", " num_pred = len(pred_class)\n", " if num_pred == 0:\n", " wrong_perc = math.nan\n", " else:\n", " wrong_perc = (num_pred - num_correct)/num_pred\n", " df_perf = pd.DataFrame({\n", " 'accuracy': [accuracy],\n", " 'true_ident': [correct_perc],\n", " 'false_pred': [wrong_perc]\n", " })\n", " return(df_perf)" ] }, { "cell_type": "markdown", "id": "c10aa57d-d7ed-45c7-bdf5-29af193c7fd5", "metadata": {}, "source": [ "## Make predictions for many models and trip descriptions\n", "\n", "Provide a list of candidate models and apply them to the test data." ] }, { "cell_type": "code", "execution_count": 22, "id": "dd7869a8-b436-40de-9ea0-28eb4b7d3248", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Using model: pongjin/roberta_with_kornli\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a44415d353264dda885031d6570e21a7", "version_major": 2, "version_minor": 0 }, "text/plain": [ "config.json: 0%| | 0.00/985 [00:00 cut_off]\n", " classes = [result['labels'][i] for i in indices]\n", " else:\n", " result = classifier(trip_descr, candidate_labels[key])\n", " classes = result[\"labels\"][0]\n", " df.loc[i] = [key, classes]\n", "\n", " ## Look up and return list of items to pack based on class predictions\n", " # make list from dataframe column\n", " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n", " # look up packing items for each class/key\n", " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n", " # combine lists and remove doubble entries\n", " flat_unique = []\n", " for sublist in list_of_list_of_items:\n", " for item in sublist:\n", " if item not in flat_unique:\n", " flat_unique.append(item)\n", " # sort alphabetically to notice duplicates\n", " sorted_list = sorted(flat_unique) \n", " return df, sorted_list" ] }, { "cell_type": "code", "execution_count": 26, "id": "0f7376bd-a50b-47cc-8055-48a6de5dfee6", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "( superclass pred_class\n", "0 activity_type beach vacation\n", "1 activities [going to the beach, relaxing, hiking]\n", "2 climate_or_season warm destination / summer\n", "3 style_or_comfort minimalist\n", "4 dress_code casual\n", "5 accommodation huts with half board\n", "6 transportation no own vehicle\n", "7 special_conditions off-grid / no electricity\n", "8 trip_length_days 7+ days, ['1 set kleding voor elke situatie', 'EHBO-set', 'USB-hub (voor meerdere devices)', 'aantal maaltijden/snacks afgestemd op duur', 'alles-in-één zeep', 'back-up verlichting (bijv. kleine zaklamp)', 'blarenpleisters of tape', 'boek of e-reader', 'comfortabele kleding', 'compacte tandenborstel', 'contant geld voor betalingen', 'dagrugzak', 'extra kledinglaag', 'extra opladerkabels', 'hiking sokken (anti-blaren)', 'hikingstokken', 'hoed of pet', 'hoofdlamp + extra batterijen', 'jeans of comfortabele broek', 'kleine rugzak', 'kleine toilettas', 'koeltas', 'lakenzak (vaak verplicht)', 'lichte handdoek', 'lichte pyjama of slaapkleding', 'lichte schoenen', 'lichtgewicht handdoek', 'luchtige kleding', 'muziek / koptelefoon', 'navigatie (kaart, kompas of GPS)', 'navigatieapparaat met offline kaarten', 'noodcommunicatie (bijv. GPS beacon of satellietboodschapper)', 'notitieboekje + pen', 'ondergoed per dag', 'oorstopjes', 'openbaar vervoer app of ticket', 'oplaadbare batterijen en oplader', 'opvouwbaar zonnepaneel (indien langere tochten)', 'pantoffels of slippers voor binnen', 'papieren kaart en kompas', 'pet of hoed', 'powerbank (minstens 10.000 mAh)', 'regenjas of poncho', 'reserveringsbevestiging', 'rugzak', 'slippers', 'snacks / energierepen', 'snacks voor onderweg', 'sneakers', 'sokken per dag', 'strandlaken', 'strandstoel', 'strandtas', 't-shirts', 'toilettas', 'trui of hoodie', 'verpakking om elektronica droog te houden', 'wandelschoenen of trailrunners', 'waterfles', 'waterfles of waterzak', 'zaklamp of hoofdlamp', 'zitkussen of strandmat', 'zonnebrand', 'zonnebrand en zonnebril', 'zonnebrandcrème', 'zonnebril', 'zonnecrème', 'zonnehoed', 'zonnepaneel of draagbaar laadsysteem', 'zwemkleding'])\n" ] } ], "source": [ "# Access the first trip description\n", "first_trip = trip_descriptions[0]\n", "tmp = classify(\"facebook/bart-large-mnli\", first_trip )\n", "print(tmp)" ] }, { "cell_type": "markdown", "id": "17483df4-55c4-41cd-b8a9-61f7a5c7e8a3", "metadata": {}, "source": [ "# Use gradio for user input" ] }, { "cell_type": "code", "execution_count": 2, "id": "5bf23e10-0a93-4b2f-9508-34bb0974d24c", "metadata": {}, "outputs": [], "source": [ "# Prerequisites\n", "from transformers import pipeline\n", "import json\n", "import pandas as pd\n", "import gradio as gr\n", "\n", "# get candidate labels\n", "with open(\"packing_label_structure.json\", \"r\") as file:\n", " candidate_labels = json.load(file)\n", "keys_list = list(candidate_labels.keys())\n", "\n", "# Load test data (in list of dictionaries)\n", "with open(\"test_data.json\", \"r\") as file:\n", " packing_data = json.load(file)\n", "\n", "# Load packing item data\n", "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n", " packing_items = json.load(file)" ] }, { "cell_type": "code", "execution_count": 3, "id": "61ebbe99-2563-4c99-ba65-d2312c9d5844", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7862\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n" ] } ], "source": [ "# function and gradio app\n", "def classify(model_name, trip_descr, cut_off = 0.5):\n", " classifier = pipeline(\"zero-shot-classification\", model=model_name)\n", " ## Create and fill dataframe with class predictions\n", " df = pd.DataFrame(columns=['superclass', 'pred_class'])\n", " for i, key in enumerate(keys_list):\n", " if key == 'activities':\n", " result = classifier(trip_descr, candidate_labels[key], multi_label=True)\n", " indices = [i for i, score in enumerate(result['scores']) if score > cut_off]\n", " classes = [result['labels'][i] for i in indices]\n", " else:\n", " result = classifier(trip_descr, candidate_labels[key])\n", " classes = result[\"labels\"][0]\n", " df.loc[i] = [key, classes]\n", "\n", " ## Look up and return list of items to pack based on class predictions\n", " # make list from dataframe column\n", " all_classes = [elem for x in df[\"pred_class\"] for elem in (x if isinstance(x, list) else [x])]\n", " # look up packing items for each class/key\n", " list_of_list_of_items = [packing_items.get(k, []) for k in all_classes]\n", " # combine lists and remove doubble entries\n", " flat_unique = []\n", " for sublist in list_of_list_of_items:\n", " for item in sublist:\n", " if item not in flat_unique:\n", " flat_unique.append(item)\n", " # sort alphabetically to notice duplicates\n", " sorted_list = sorted(flat_unique) \n", " return df, \"\\n\".join(sorted_list)\n", "\n", "demo = gr.Interface(\n", " fn=classify,\n", " inputs=[\n", " gr.Textbox(label=\"Model name\", value = \"MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli\"),\n", " gr.Textbox(label=\"Trip description\"),\n", " gr.Number(label=\"Activity cut-off\", value = 0.5),\n", " ],\n", " # outputs=\"dataframe\",\n", " outputs=[gr.Dataframe(label=\"DataFrame\"), gr.Textbox(label=\"List of words\")],\n", " title=\"Trip classification\",\n", " description=\"Enter a text describing your trip\",\n", ")\n", "\n", "# Launch the Gradio app\n", "if __name__ == \"__main__\":\n", " demo.launch()\n" ] }, { "cell_type": "code", "execution_count": 32, "id": "1f5df949-a527-4b11-8e5e-23786e1cde12", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "I am planning a trip to Greece with my boyfriend, where we will visit two islands. We have booked an apartment on each island for a few days and plan to spend most of our time relaxing. Our main goals are to enjoy the beach, try delicious local food, and possibly go on a hike—if it’s not too hot. We will be relying solely on public transport. We’re in our late 20s and traveling from the Netherlands.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.\n" ] } ], "source": [ "print(first_trip)" ] }, { "cell_type": "markdown", "id": "4ba29d94-88e4-4fb9-b42b-4e013ec2faa0", "metadata": {}, "source": [ "**Check for duplicate entries, which to combine?**" ] }, { "cell_type": "code", "execution_count": 3, "id": "66311e68-c7ab-47a0-8d42-02991bc048f2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "print(type(packing_items))" ] }, { "cell_type": "code", "execution_count": 9, "id": "9b2a01e7-55ac-405a-bb34-2b759c1f2d8e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1 set of clothing for every situation\n", "GPS or offline maps\n", "Gore‑Tex clothing\n", "Gore‑Tex jacket and pants\n", "MiFi router or portable WiFi hotspot\n", "SUP board and paddle\n", "USB hub (for multiple devices)\n", "WiFi hotspot or local SIM card\n", "accessories\n", "activity book or tablet with films\n", "airbag backpack (if available)\n", "all‑in‑one soap\n", "at least 2 liters of water storage per person\n", "avalanche beacon (transceiver)\n", "baby monitor (for staying at location)\n", "backpack\n", "backup lighting (e.g. small flashlight)\n", "bags for waste\n", "bait / lures\n", "bank card / cash\n", "beach bag\n", "beach chair\n", "beach towel\n", "belay device\n", "bike light and lock\n", "bike or rental bike\n", "biodegradable soap + sponge\n", "bivvy bag or tarp\n", "blister plasters or tape\n", "board leash\n", "book / meditation material\n", "book or e‑reader\n", "boots or waders\n", "bottles and food (if applicable)\n", "breathable thermal clothing\n", "buff or neck warmer\n", "business cards / documents\n", "camera + lenses\n", "camera or smartphone\n", "camping gear (if staying overnight)\n", "camping table (optional)\n", "cap or hat\n", "car documents\n", "cash / card\n", "cash for hut\n", "cash for payments\n", "chair\n", "chair and table\n", "chalk bag\n", "charger\n", "child carrier or stroller\n", "child sleeping bag or pad\n", "children’s sunscreen\n", "children’s travel pharmacy\n", "chlorine drops or purification tablets\n", "city map / offline maps\n", "climbing harness\n", "climbing rope\n", "climbing shoes\n", "climbing skins\n", "closed shoes\n", "comfortable backpack or trolley\n", "comfortable clothing\n", "comfortable shoes\n", "comfortable sleeping pad\n", "compact clothing pack\n", "compact rain jacket\n", "compact sleeping gear (if overnighting)\n", "compact toothbrush\n", "cookset + stove\n", "cooler\n", "cooler box\n", "cooler box (optional)\n", "covering clothing\n", "crampons\n", "cross-country ski boots\n", "cross-country skis and poles\n", "daypack\n", "diapers or potty (depending on age)\n", "dishes & cutlery\n", "dive computer\n", "dog leash or harness\n", "down jacket or warm insulation layer\n", "dress or shirt\n", "dress shoes\n", "dried or freeze‑dried meals\n", "driver’s license\n", "dry bag\n", "earplugs\n", "emergency communication (e.g. GPS beacon or satellite messenger)\n", "energy bars or sports nutrition\n", "entertainment (book, music, games)\n", "essential oils (optional)\n", "extension cord (for powered campsites)\n", "extra batteries\n", "extra charger cables\n", "extra clothing\n", "extra clothing layer\n", "extra clothing or gear if needed\n", "extra clothing set per day\n", "extra food\n", "extra snacks for children\n", "favorite toy or stuffed animal\n", "fins\n", "first aid kit\n", "fishing license\n", "fishing rod\n", "flashlight or headlamp\n", "flip flops\n", "foldable cutting board (optional)\n", "foldable solar panel (if on longer trips)\n", "food and snacks\n", "food and water bowl\n", "food bag or hanging bag (wild-safe)\n", "food supply\n", "friend meetups\n", "fuel (enough for several days)\n", "gaiters (in deep snow)\n", "general items for this situation\n", "glitter / outfit\n", "gloves\n", "gloves (2 pairs)\n", "groceries\n", "groundsheet\n", "guidebook or highlights list\n", "hat and gloves\n", "hat or cap\n", "hat or headband\n", "head cover\n", "head protection\n", "headband or cap\n", "headlamp\n", "headlamp + extra batteries\n", "headlamp or flashlight\n", "helmet\n", "hiking boots\n", "hiking boots or trail runners\n", "hiking poles\n", "hiking socks (anti-blister)\n", "hut slippers / Crocs\n", "hydrating cream (for sensitive skin)\n", "ice axes\n", "identity document or passport\n", "indoor hut clothing (thermo / fleece)\n", "insect repellent\n", "insurance card / travel insurance info\n", "jeans or comfortable pants\n", "journal / pen\n", "kayak or canoe\n", "kids first aid kit (including thermometer and bandages)\n", "knife or multitool\n", "knowledge of avalanche safety / course\n", "lamp or lantern\n", "laptop and charger\n", "layered clothing\n", "layers for temperature control\n", "layers of clothing\n", "lens cloth\n", "life jacket\n", "light backpack with water and snacks\n", "light clothing\n", "light down jacket or warm layer\n", "light gloves for climbing\n", "light jacket or raincoat\n", "light long sleeves\n", "light pajamas or sleepwear\n", "light shoes\n", "light tent or tarp\n", "light towel\n", "lighter\n", "lighter + matches (waterproof packed)\n", "lightweight backpack\n", "lightweight backpack (< 1kg)\n", "lightweight clothing\n", "lightweight cookset\n", "lightweight sleeping pad\n", "lightweight stove (gas, petrol or alcohol)\n", "lightweight towel\n", "lightweight trekking backpack (30–45 liters)\n", "limited clothing (layers!)\n", "lip balm\n", "long pants or skirt\n", "lots of water\n", "map and compass\n", "map and compass / GPS\n", "map or GPS\n", "map or offline maps\n", "mask and snorkel\n", "memory card(s)\n", "minimalist shelter (tarp or tent)\n", "music / headphones\n", "navigation\n", "navigation (map/compass/GPS)\n", "navigation device with offline maps\n", "navigation or smartphone\n", "noise‑cancelling headphones\n", "notebook + pen\n", "number of meals/snacks matched to duration\n", "optional own saddle or stirrups\n", "pacifier or dummy\n", "packaging to keep electronics dry\n", "pad and sleeping bag\n", "paddle\n", "pajamas\n", "pan or small pot\n", "paper map and compass\n", "paraglider\n", "partner check before departure\n", "payment methods (debit card / cash)\n", "perfume / deodorant\n", "phone + charger\n", "phone charger\n", "phone holder\n", "phone holder / navigation\n", "pillow or inflatable pillow\n", "poncho or rain jacket\n", "poncho or towel\n", "poop bags\n", "power bank\n", "power bank (at least 10,000 mAh)\n", "power bank or 12V charger\n", "press‑on bowl or mug\n", "probe\n", "probe and shovel\n", "public transport app or ticket\n", "quick snacks for en route\n", "quick‑dry base layers\n", "quick‑dry clothing\n", "quick‑dry towel\n", "quilt or down blanket\n", "rain cover for stroller or carrier\n", "rain jacket\n", "rain jacket or poncho\n", "rain jacket or windbreaker\n", "rain poncho\n", "rain protection\n", "rechargeable batteries and charger\n", "regulator (if own)\n", "repair kit\n", "reservation confirmation\n", "reusable bag\n", "reusable cup\n", "riding boots or shoes with heel\n", "riding pants\n", "rubber shoes\n", "running shoes\n", "sandals\n", "scarf or shawl\n", "seat cushion or beach mat\n", "sheet liner\n", "sheet liner (often required)\n", "shirt / blouse\n", "shovel\n", "ski boots\n", "ski goggles\n", "ski or sunglasses\n", "ski pass\n", "skis and poles\n", "sleep mask\n", "sleeping bag\n", "sleeping bag (light, warm variant)\n", "sleeping bag (suitable for temperature)\n", "sleeping pad\n", "sleeping pad that fits in car\n", "slippers\n", "slippers or indoor shoes for inside\n", "small backpack\n", "small toiletry bag\n", "smart jacket\n", "snacks\n", "snacks / emergency bars\n", "snacks / energy bars\n", "snacks and drinks\n", "snacks and toys\n", "snacks for along the way\n", "snacks for the night\n", "sneakers\n", "snorkel and mask\n", "snow goggles\n", "socks\n", "socks per day\n", "solar panel or portable charging system\n", "splitboard or snowboard\n", "spork or spoon\n", "sports clothing\n", "sports watch (optional)\n", "sun hat\n", "sun hat or cap\n", "sun protection\n", "sunglasses\n", "sunglasses or sport glasses\n", "sunglasses with strap\n", "sunscreen\n", "sunscreen and sunglasses\n", "sunshades or blackout covers\n", "surfboard\n", "sweater or hoodie\n", "swimming goggles\n", "swimwear\n", "t-shirts\n", "tent\n", "tent (1‑ or 2‑person, depending on trip)\n", "tent or tarp\n", "thermal blanket (for cold nights)\n", "thermal clothing\n", "thermos bottle\n", "thick gloves\n", "thin gloves\n", "tissues or toilet paper\n", "titanium cookset\n", "toiletry bag\n", "toiletry bag (toothpaste, brush, deodorant, soap)\n", "toiletry bag with biodegradable soap\n", "toiletry bag with essentials\n", "toothbrush (shortened ;))\n", "tour bindings (for splitboard)\n", "touring backpack with ski attachment\n", "touring skis or splitboard\n", "towel\n", "traction soles / spikes\n", "trail runners or lightweight hiking shoes\n", "travel chair or sling\n", "travel crib or mattress (for young children)\n", "travel guide or maps\n", "travel mat or blanket\n", "trekking poles\n", "tripod\n", "underwear per day\n", "vaccination booklet\n", "warm boots\n", "warm insulation layers\n", "warm jacket\n", "warm layer\n", "warm sleeping bag\n", "warm sweater\n", "warm sweater or scarf\n", "washing up supplies\n", "water bottle\n", "water bottle or belt\n", "water bottle within reach\n", "water bottle(s) or hydration bladder\n", "water filter or pump\n", "water shoes\n", "waterproof backpack cover\n", "waterproof bag\n", "waterproof shoes\n", "wax\n", "wet wipes\n", "wetsuit\n", "wind jacket\n", "windproof and water-repellent outer layer\n", "wind‑ and waterproof jacket\n", "world adapter plug\n", "yoga mat or yoga towel\n" ] } ], "source": [ "# Load packing item data\n", "with open(\"packing_templates_self_supported_offgrid_expanded.json\", \"r\") as file:\n", " packing_items = json.load(file)\n", "\n", "unique_sorted = sorted({item for values in packing_items.values() for item in values})\n", "\n", "for item in unique_sorted:\n", " print(item)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "e300e3f3-93e0-457b-b2f0-e05cc5c2cafb", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (huggingface_env)", "language": "python", "name": "huggingface_env" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.20" } }, "nbformat": 4, "nbformat_minor": 5 }