{ "cells": [ { "cell_type": "markdown", "id": "11bb4456-5dc2-440c-9320-4af43e032aeb", "metadata": {}, "source": [ "# Hands-on Beispiel LLM (1)" ] }, { "cell_type": "markdown", "id": "47a74c0f-6038-4871-9038-df59a4be02a1", "metadata": {}, "source": [ "### 1. Baseline - Juristische Fragen an ein untrainiertes Modell (Lokale LLM)\n", "In diesem Abschnitt laden wir das Modell `dbmdz/german-gpt2` und stellen ihm zwei juristische Fragen zum AI Act.Da das Modell noch nicht mit AI Act-spezifischen Texten feingetunt wurde, sind die Antworten vermutlich unzureichend.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "8f0f45fe-361d-4965-a821-e69419fced67", "metadata": { "execution": { "iopub.execute_input": "2026-03-24T18:09:49.892536Z", "iopub.status.busy": "2026-03-24T18:09:49.892247Z", "iopub.status.idle": "2026-03-24T18:09:49.895511Z", "shell.execute_reply": "2026-03-24T18:09:49.894860Z", "shell.execute_reply.started": "2026-03-24T18:09:49.892511Z" } }, "outputs": [], "source": [ "# falls noch nicht installiert \n", "\n", "import sys\n", "# !{sys.executable} -m pip install transformers datasets\n", "# !{sys.executable} -m pip install 'accelerate>=0.26.0'" ] }, { "cell_type": "code", "execution_count": 2, "id": "9f565816-f407-4a0b-9696-e4c3cbd55939", "metadata": { "execution": { "iopub.execute_input": "2026-03-24T18:09:50.506661Z", "iopub.status.busy": "2026-03-24T18:09:50.506151Z", "iopub.status.idle": "2026-03-24T18:10:00.682920Z", "shell.execute_reply": "2026-03-24T18:10:00.682409Z", "shell.execute_reply.started": "2026-03-24T18:09:50.506608Z" } }, "outputs": [], "source": [ "# Importiere die benötigten Bibliotheken\n", "import torch\n", "from transformers import AutoTokenizer, AutoModelForCausalLM" ] }, { "cell_type": "code", "execution_count": 3, "id": "8813329a-0179-43bf-8187-aef811581782", "metadata": { "execution": { "iopub.execute_input": "2026-03-24T18:10:00.683498Z", "iopub.status.busy": "2026-03-24T18:10:00.683294Z", "iopub.status.idle": "2026-03-24T18:10:03.691920Z", "shell.execute_reply": "2026-03-24T18:10:03.691373Z", "shell.execute_reply.started": "2026-03-24T18:10:00.683485Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads.\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ae9d28b31fba46428ad048a2d3dc3aeb", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Loading weights: 0%| | 0/148 [00:00