Upload test_privacy_filter_ko.ipynb with huggingface_hub
Browse files
test_privacy_filter_ko.ipynb
CHANGED
|
@@ -17,7 +17,7 @@
|
|
| 17 |
"execution_count": null,
|
| 18 |
"metadata": {},
|
| 19 |
"outputs": [],
|
| 20 |
-
"source": "#
|
| 21 |
},
|
| 22 |
{
|
| 23 |
"cell_type": "code",
|
|
|
|
| 17 |
"execution_count": null,
|
| 18 |
"metadata": {},
|
| 19 |
"outputs": [],
|
| 20 |
+
"source": "# Privacy Filter requires transformers 5.x (HEAD) for the `openai_privacy_filter`\n# model_type. Stable PyPI transformers (4.x) does NOT have it yet.\n#\n# Run this cell ONCE on first use. If you're on Colab, the kernel will auto-restart\n# afterwards — this is normal. After restart, run cells 3 onwards.\n\nimport importlib, subprocess, sys\n\n\ndef _has_privacy_filter():\n try:\n m = importlib.import_module(\"transformers.models.auto.configuration_auto\")\n return \"openai_privacy_filter\" in getattr(m, \"CONFIG_MAPPING_NAMES\", {})\n except Exception:\n return False\n\n\nif _has_privacy_filter():\n import transformers\n print(f\"transformers {transformers.__version__} already supports openai_privacy_filter — ready.\")\nelse:\n print(\"Installing transformers from source (HEAD)...\")\n # --upgrade is critical: without it, pip silently no-ops if any transformers is present.\n subprocess.check_call([\n sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"--upgrade\",\n \"git+https://github.com/huggingface/transformers.git\",\n \"peft\", \"safetensors\", \"accelerate\",\n ])\n print(\"Install done.\")\n\n # Force kernel restart on Colab so the new transformers replaces the imported one.\n # This raises a hard exit — re-run from cell 3 after the kernel comes back.\n try:\n import google.colab # noqa: F401\n print(\"Restarting Colab runtime...\")\n import os\n os.kill(os.getpid(), 9)\n except ImportError:\n # Local Jupyter — request kernel restart.\n try:\n import IPython\n print(\"Requesting Jupyter kernel restart...\")\n IPython.Application.instance().kernel.do_shutdown(restart=True)\n except Exception:\n print(\"Please RESTART YOUR KERNEL (Kernel → Restart) before running cell 3.\")"
|
| 21 |
},
|
| 22 |
{
|
| 23 |
"cell_type": "code",
|