{ "cells": [ { "cell_type": "code", "execution_count": 29, "id": "72e26e1c-3fda-4333-9401-4ee15d1bf3b8", "metadata": {}, "outputs": [], "source": [ "model_id = \"sentence-transformers/all-MiniLM-L6-v2\"\n" ] }, { "cell_type": "code", "execution_count": 30, "id": "68f1d64b-12b2-4d2a-a06a-6a7d35c3a6f5", "metadata": {}, "outputs": [], "source": [ "import requests\n", "\n", "api_url = f\"https://api-inference.huggingface.co/pipeline/feature-extraction/{model_id}\"\n", "headers = {\"Authorization\": f\"Bearer {hf_token}\"}" ] }, { "cell_type": "code", "execution_count": 31, "id": "aae00acb-6932-4b46-bc99-a542740c0f33", "metadata": {}, "outputs": [], "source": [ "def query(texts):\n", " response = requests.post(api_url, headers=headers, json={\"inputs\": texts, \"options\":{\"wait_for_model\":True}})\n", " return response.json()" ] }, { "cell_type": "code", "execution_count": 48, "id": "3955111a-6785-4375-b6cd-126f5bd9afd4", "metadata": {}, "outputs": [], "source": [ "\n", "import pandas as pd\n", "\n", "# Pfad zur CSV-Datei\n", "file_path = '/Users/I569961/Downloads/imdb_top_1000.csv'\n", "\n", "# Einlesen der CSV-Datei\n", "data = pd.read_csv(file_path)\n", "\n", "# Konvertieren des DataFrame in einen String\n", "data_string = data.to_string()\n", "\n", "output = query(texts)" ] }, { "cell_type": "code", "execution_count": 41, "id": "c5615ec3-2168-420c-9146-77c37b8df8fb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "5 | \n", "6 | \n", "7 | \n", "8 | \n", "9 | \n", "... | \n", "374 | \n", "375 | \n", "376 | \n", "377 | \n", "378 | \n", "379 | \n", "380 | \n", "381 | \n", "382 | \n", "383 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "-0.023889 | \n", "0.055259 | \n", "-0.011655 | \n", "-0.033414 | \n", "-0.012261 | \n", "-0.024873 | \n", "-0.012663 | \n", "0.025346 | \n", "0.018508 | \n", "-0.083508 | \n", "... | \n", "-0.161688 | \n", "-0.046426 | \n", "0.006004 | \n", "0.005281 | \n", "-0.003342 | \n", "0.027754 | \n", "0.020411 | \n", "0.005778 | \n", "0.034098 | \n", "-0.006889 | \n", "
1 | \n", "-0.012688 | \n", "0.046874 | \n", "-0.010502 | \n", "-0.020384 | \n", "-0.013361 | \n", "0.042322 | \n", "0.016628 | \n", "-0.004099 | \n", "-0.002607 | \n", "-0.010188 | \n", "... | \n", "-0.061594 | \n", "-0.020717 | \n", "-0.009082 | \n", "-0.029260 | \n", "-0.066253 | \n", "0.065257 | \n", "0.013229 | \n", "-0.023103 | \n", "-0.002785 | \n", "0.010474 | \n", "
2 | \n", "0.000494 | \n", "0.119412 | \n", "0.005229 | \n", "-0.092734 | \n", "0.007773 | \n", "-0.005325 | \n", "0.034506 | \n", "-0.051981 | \n", "-0.006265 | \n", "-0.006111 | \n", "... | \n", "-0.108326 | \n", "-0.049646 | \n", "-0.073399 | \n", "-0.029898 | \n", "-0.102734 | \n", "0.062121 | \n", "0.034606 | \n", "0.016877 | \n", "-0.023861 | \n", "0.005264 | \n", "
3 | \n", "-0.029711 | \n", "0.023298 | \n", "-0.057041 | \n", "-0.012183 | \n", "-0.013710 | \n", "0.029796 | \n", "0.063739 | \n", "0.001101 | \n", "-0.045124 | \n", "-0.040748 | \n", "... | \n", "-0.117682 | \n", "0.031924 | \n", "0.000854 | \n", "0.020200 | \n", "-0.020666 | \n", "-0.005167 | \n", "0.038370 | \n", "0.003617 | \n", "0.033993 | \n", "-0.010255 | \n", "
4 | \n", "-0.025628 | \n", "0.070389 | \n", "-0.017380 | \n", "-0.056567 | \n", "0.028577 | \n", "0.052823 | \n", "0.067063 | \n", "-0.052618 | \n", "-0.054702 | \n", "-0.116230 | \n", "... | \n", "-0.118145 | \n", "0.013343 | \n", "-0.055188 | \n", "-0.032723 | \n", "0.008436 | \n", "0.019169 | \n", "0.048212 | \n", "-0.040412 | \n", "0.083346 | \n", "0.026855 | \n", "
5 | \n", "-0.022656 | \n", "0.021160 | \n", "0.005105 | \n", "-0.046494 | \n", "0.009074 | \n", "0.041495 | \n", "0.054268 | \n", "-0.024185 | \n", "-0.013483 | \n", "-0.075966 | \n", "... | \n", "-0.100110 | \n", "0.010750 | \n", "-0.031469 | \n", "-0.004822 | \n", "0.039657 | \n", "0.026384 | \n", "0.045514 | \n", "0.059089 | \n", "-0.017509 | \n", "0.007166 | \n", "
6 | \n", "-0.002911 | \n", "0.060791 | \n", "-0.009176 | \n", "-0.006133 | \n", "0.040492 | \n", "0.036594 | \n", "0.002054 | \n", "-0.031345 | \n", "0.031806 | \n", "-0.023495 | \n", "... | \n", "-0.028763 | \n", "-0.060458 | \n", "-0.018598 | \n", "-0.040189 | \n", "-0.031486 | \n", "-0.018299 | \n", "0.002286 | \n", "-0.073420 | \n", "0.016235 | \n", "-0.000244 | \n", "
7 | \n", "-0.080526 | \n", "0.059888 | \n", "-0.048847 | \n", "-0.040176 | \n", "-0.063342 | \n", "0.041848 | \n", "0.119045 | \n", "0.010652 | \n", "-0.030095 | \n", "-0.004561 | \n", "... | \n", "-0.144566 | \n", "0.020404 | \n", "0.023088 | \n", "0.005077 | \n", "-0.055645 | \n", "-0.007675 | \n", "0.050791 | \n", "-0.005989 | \n", "0.134562 | \n", "0.034817 | \n", "
8 | \n", "-0.034388 | \n", "0.072501 | \n", "0.014440 | \n", "-0.036695 | \n", "0.014019 | \n", "0.063070 | \n", "0.034683 | \n", "-0.014531 | \n", "-0.059862 | \n", "-0.045383 | \n", "... | \n", "-0.114763 | \n", "-0.035894 | \n", "-0.019877 | \n", "-0.033375 | \n", "-0.030168 | \n", "0.039412 | \n", "0.044993 | \n", "0.000578 | \n", "-0.025124 | \n", "0.034191 | \n", "
9 | \n", "-0.005964 | \n", "0.025044 | \n", "-0.003182 | \n", "-0.025243 | \n", "-0.039823 | \n", "-0.012772 | \n", "0.044713 | \n", "0.014535 | \n", "-0.038213 | \n", "-0.041149 | \n", "... | \n", "-0.057621 | \n", "0.021594 | \n", "0.048983 | \n", "-0.044541 | \n", "-0.030137 | \n", "0.006779 | \n", "0.054854 | \n", "0.029937 | \n", "0.070214 | \n", "0.041565 | \n", "
10 | \n", "-0.039008 | \n", "-0.010609 | \n", "-0.007383 | \n", "-0.050190 | \n", "-0.002518 | \n", "-0.041641 | \n", "0.026969 | \n", "-0.014801 | \n", "-0.014127 | \n", "-0.061637 | \n", "... | \n", "-0.098168 | \n", "-0.031694 | \n", "-0.052128 | \n", "0.014774 | \n", "-0.091150 | \n", "0.001324 | \n", "0.053866 | \n", "-0.083904 | \n", "0.037684 | \n", "0.002314 | \n", "
11 | \n", "-0.095983 | \n", "-0.063012 | \n", "-0.116906 | \n", "-0.059075 | \n", "-0.051323 | \n", "-0.003439 | \n", "0.018687 | \n", "0.006544 | \n", "-0.049057 | \n", "-0.031649 | \n", "... | \n", "-0.041085 | \n", "-0.008593 | \n", "-0.021544 | \n", "-0.021112 | \n", "-0.019502 | \n", "0.050040 | \n", "-0.029175 | \n", "0.005498 | \n", "0.152892 | \n", "0.024720 | \n", "
12 | \n", "-0.011600 | \n", "0.056510 | \n", "0.016624 | \n", "-0.094690 | \n", "-0.009865 | \n", "0.072347 | \n", "0.044124 | \n", "-0.041175 | \n", "-0.042124 | \n", "-0.102631 | \n", "... | \n", "-0.135239 | \n", "0.013612 | \n", "-0.049410 | \n", "-0.006925 | \n", "0.085355 | \n", "-0.007875 | \n", "0.030402 | \n", "-0.029012 | \n", "0.001888 | \n", "-0.000133 | \n", "
13 rows × 384 columns
\n", "