Instructions to use hanzceo/JOSS-dev2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hanzceo/JOSS-dev2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="hanzceo/JOSS-dev2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("hanzceo/JOSS-dev2") model = AutoModelForSequenceClassification.from_pretrained("hanzceo/JOSS-dev2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload train.ipynb
Browse files- train.ipynb +678 -0
train.ipynb
ADDED
|
@@ -0,0 +1,678 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "6cc7d98d-23c5-4fb3-86eb-4e0665382bb1",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [
|
| 9 |
+
{
|
| 10 |
+
"name": "stdout",
|
| 11 |
+
"output_type": "stream",
|
| 12 |
+
"text": [
|
| 13 |
+
"\u001b[2mInstalled \u001b[1mPython 3.13.11\u001b[0m \u001b[2min 713ms\u001b[0m\u001b[0m\n",
|
| 14 |
+
" \u001b[32m+\u001b[39m \u001b[1mcpython-3.13.11-linux-x86_64-gnu\u001b[0m (python3.13)\n",
|
| 15 |
+
"\u001b[1m\u001b[33mwarning\u001b[39m\u001b[0m\u001b[1m:\u001b[0m \u001b[1m`\u001b[36m/root/.local/bin\u001b[39m` is not on your PATH. To use installed Python executables, run `\u001b[32mexport PATH=\"/root/.local/bin:$PATH\"\u001b[39m` or `\u001b[32muv python update-shell\u001b[39m`.\u001b[0m\n",
|
| 16 |
+
"Pinned `\u001b[36m/.python-version\u001b[39m` to `\u001b[32m3.13\u001b[39m`\n"
|
| 17 |
+
]
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"source": [
|
| 21 |
+
"!uv python install 313\n",
|
| 22 |
+
"!uv python pin 313"
|
| 23 |
+
]
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"cell_type": "code",
|
| 27 |
+
"execution_count": 2,
|
| 28 |
+
"id": "2d741065-01e2-4551-8a7e-70fecca6759e",
|
| 29 |
+
"metadata": {},
|
| 30 |
+
"outputs": [
|
| 31 |
+
{
|
| 32 |
+
"name": "stdout",
|
| 33 |
+
"output_type": "stream",
|
| 34 |
+
"text": [
|
| 35 |
+
"Using CPython \u001b[36m3.13.11\u001b[39m\u001b[36m\u001b[39m\n",
|
| 36 |
+
"Creating virtual environment at: \u001b[36m.venv\u001b[39m\n",
|
| 37 |
+
"Activate with: \u001b[32msource .venv/bin/activate\u001b[39m\n",
|
| 38 |
+
"\u001b[2K\u001b[2mResolved \u001b[1m30 packages\u001b[0m \u001b[2min 310ms\u001b[0m\u001b[0m \u001b[0m\n",
|
| 39 |
+
"\u001b[2K\u001b[2mPrepared \u001b[1m30 packages\u001b[0m \u001b[2min 280ms\u001b[0m\u001b[0m \n",
|
| 40 |
+
"\u001b[2K\u001b[2mInstalled \u001b[1m30 packages\u001b[0m \u001b[2min 56ms\u001b[0m\u001b[0m \u001b[0m\n",
|
| 41 |
+
" \u001b[32m+\u001b[39m \u001b[1masttokens\u001b[0m\u001b[2m==3.0.2\u001b[0m\n",
|
| 42 |
+
" \u001b[32m+\u001b[39m \u001b[1mcomm\u001b[0m\u001b[2m==0.2.3\u001b[0m\n",
|
| 43 |
+
" \u001b[32m+\u001b[39m \u001b[1mdebugpy\u001b[0m\u001b[2m==1.8.21\u001b[0m\n",
|
| 44 |
+
" \u001b[32m+\u001b[39m \u001b[1mdecorator\u001b[0m\u001b[2m==5.3.1\u001b[0m\n",
|
| 45 |
+
" \u001b[32m+\u001b[39m \u001b[1mexecuting\u001b[0m\u001b[2m==2.2.1\u001b[0m\n",
|
| 46 |
+
" \u001b[32m+\u001b[39m \u001b[1mipykernel\u001b[0m\u001b[2m==7.3.0\u001b[0m\n",
|
| 47 |
+
" \u001b[32m+\u001b[39m \u001b[1mipython\u001b[0m\u001b[2m==9.15.0\u001b[0m\n",
|
| 48 |
+
" \u001b[32m+\u001b[39m \u001b[1mipython-pygments-lexers\u001b[0m\u001b[2m==1.1.1\u001b[0m\n",
|
| 49 |
+
" \u001b[32m+\u001b[39m \u001b[1mjedi\u001b[0m\u001b[2m==0.20.0\u001b[0m\n",
|
| 50 |
+
" \u001b[32m+\u001b[39m \u001b[1mjupyter-client\u001b[0m\u001b[2m==8.9.1\u001b[0m\n",
|
| 51 |
+
" \u001b[32m+\u001b[39m \u001b[1mjupyter-core\u001b[0m\u001b[2m==5.9.1\u001b[0m\n",
|
| 52 |
+
" \u001b[32m+\u001b[39m \u001b[1mmatplotlib-inline\u001b[0m\u001b[2m==0.2.2\u001b[0m\n",
|
| 53 |
+
" \u001b[32m+\u001b[39m \u001b[1mnest-asyncio2\u001b[0m\u001b[2m==1.7.2\u001b[0m\n",
|
| 54 |
+
" \u001b[32m+\u001b[39m \u001b[1mpackaging\u001b[0m\u001b[2m==26.2\u001b[0m\n",
|
| 55 |
+
" \u001b[32m+\u001b[39m \u001b[1mparso\u001b[0m\u001b[2m==0.8.7\u001b[0m\n",
|
| 56 |
+
" \u001b[32m+\u001b[39m \u001b[1mpexpect\u001b[0m\u001b[2m==4.9.0\u001b[0m\n",
|
| 57 |
+
" \u001b[32m+\u001b[39m \u001b[1mplatformdirs\u001b[0m\u001b[2m==4.11.0\u001b[0m\n",
|
| 58 |
+
" \u001b[32m+\u001b[39m \u001b[1mprompt-toolkit\u001b[0m\u001b[2m==3.0.53\u001b[0m\n",
|
| 59 |
+
" \u001b[32m+\u001b[39m \u001b[1mpsutil\u001b[0m\u001b[2m==7.2.2\u001b[0m\n",
|
| 60 |
+
" \u001b[32m+\u001b[39m \u001b[1mptyprocess\u001b[0m\u001b[2m==0.7.0\u001b[0m\n",
|
| 61 |
+
" \u001b[32m+\u001b[39m \u001b[1mpure-eval\u001b[0m\u001b[2m==0.2.3\u001b[0m\n",
|
| 62 |
+
" \u001b[32m+\u001b[39m \u001b[1mpygments\u001b[0m\u001b[2m==2.20.0\u001b[0m\n",
|
| 63 |
+
" \u001b[32m+\u001b[39m \u001b[1mpython-dateutil\u001b[0m\u001b[2m==2.9.0.post0\u001b[0m\n",
|
| 64 |
+
" \u001b[32m+\u001b[39m \u001b[1mpyzmq\u001b[0m\u001b[2m==27.1.0\u001b[0m\n",
|
| 65 |
+
" \u001b[32m+\u001b[39m \u001b[1msix\u001b[0m\u001b[2m==1.17.0\u001b[0m\n",
|
| 66 |
+
" \u001b[32m+\u001b[39m \u001b[1mstack-data\u001b[0m\u001b[2m==0.6.3\u001b[0m\n",
|
| 67 |
+
" \u001b[32m+\u001b[39m \u001b[1mtornado\u001b[0m\u001b[2m==6.5.7\u001b[0m\n",
|
| 68 |
+
" \u001b[32m+\u001b[39m \u001b[1mtraitlets\u001b[0m\u001b[2m==5.15.1\u001b[0m\n",
|
| 69 |
+
" \u001b[32m+\u001b[39m \u001b[1mtyping-extensions\u001b[0m\u001b[2m==4.16.0\u001b[0m\n",
|
| 70 |
+
" \u001b[32m+\u001b[39m \u001b[1mwcwidth\u001b[0m\u001b[2m==0.8.2\u001b[0m\n",
|
| 71 |
+
"Installed kernelspec uv-kernel in /root/.local/share/jupyter/kernels/uv-kernel\n"
|
| 72 |
+
]
|
| 73 |
+
}
|
| 74 |
+
],
|
| 75 |
+
"source": [
|
| 76 |
+
"!uv venv --clear\n",
|
| 77 |
+
"!uv pip install ipykernel\n",
|
| 78 |
+
"!uv run python -m ipykernel install --user --name=uv-kernel --display-name \"Python (uv venv)\""
|
| 79 |
+
]
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"cell_type": "code",
|
| 83 |
+
"execution_count": 4,
|
| 84 |
+
"id": "ae35bf68-b4b1-435e-8a79-61bd140bc77e",
|
| 85 |
+
"metadata": {},
|
| 86 |
+
"outputs": [
|
| 87 |
+
{
|
| 88 |
+
"name": "stdout",
|
| 89 |
+
"output_type": "stream",
|
| 90 |
+
"text": [
|
| 91 |
+
"\u001b[2K\u001b[2mResolved \u001b[1m83 packages\u001b[0m \u001b[2min 144ms\u001b[0m\u001b[0m \u001b[0m\n",
|
| 92 |
+
"\u001b[2K\u001b[2mPrepared \u001b[1m8 packages\u001b[0m \u001b[2min 15.25s\u001b[0m\u001b[0m \n",
|
| 93 |
+
"\u001b[2K\u001b[2mInstalled \u001b[1m77 packages\u001b[0m \u001b[2min 119ms\u001b[0m\u001b[0m \u001b[0m\n",
|
| 94 |
+
" \u001b[32m+\u001b[39m \u001b[1maccelerate\u001b[0m\u001b[2m==1.14.0\u001b[0m\n",
|
| 95 |
+
" \u001b[32m+\u001b[39m \u001b[1maiohappyeyeballs\u001b[0m\u001b[2m==2.7.1\u001b[0m\n",
|
| 96 |
+
" \u001b[32m+\u001b[39m \u001b[1maiohttp\u001b[0m\u001b[2m==3.14.3\u001b[0m\n",
|
| 97 |
+
" \u001b[32m+\u001b[39m \u001b[1maiosignal\u001b[0m\u001b[2m==1.4.0\u001b[0m\n",
|
| 98 |
+
" \u001b[32m+\u001b[39m \u001b[1mannotated-doc\u001b[0m\u001b[2m==0.0.5\u001b[0m\n",
|
| 99 |
+
" \u001b[32m+\u001b[39m \u001b[1manyio\u001b[0m\u001b[2m==4.14.2\u001b[0m\n",
|
| 100 |
+
" \u001b[32m+\u001b[39m \u001b[1mattrs\u001b[0m\u001b[2m==26.1.0\u001b[0m\n",
|
| 101 |
+
" \u001b[32m+\u001b[39m \u001b[1mcertifi\u001b[0m\u001b[2m==2026.7.22\u001b[0m\n",
|
| 102 |
+
" \u001b[32m+\u001b[39m \u001b[1mcharset-normalizer\u001b[0m\u001b[2m==3.4.9\u001b[0m\n",
|
| 103 |
+
" \u001b[32m+\u001b[39m \u001b[1mclick\u001b[0m\u001b[2m==8.4.2\u001b[0m\n",
|
| 104 |
+
" \u001b[32m+\u001b[39m \u001b[1mcuda-bindings\u001b[0m\u001b[2m==13.3.1\u001b[0m\n",
|
| 105 |
+
" \u001b[32m+\u001b[39m \u001b[1mcuda-pathfinder\u001b[0m\u001b[2m==1.6.0\u001b[0m\n",
|
| 106 |
+
" \u001b[32m+\u001b[39m \u001b[1mcuda-toolkit\u001b[0m\u001b[2m==13.0.3.0\u001b[0m\n",
|
| 107 |
+
" \u001b[32m+\u001b[39m \u001b[1mdatasets\u001b[0m\u001b[2m==5.0.1\u001b[0m\n",
|
| 108 |
+
" \u001b[32m+\u001b[39m \u001b[1mdill\u001b[0m\u001b[2m==0.4.1\u001b[0m\n",
|
| 109 |
+
" \u001b[32m+\u001b[39m \u001b[1mevaluate\u001b[0m\u001b[2m==0.4.6\u001b[0m\n",
|
| 110 |
+
" \u001b[32m+\u001b[39m \u001b[1mfastrand\u001b[0m\u001b[2m==3.1.0\u001b[0m\n",
|
| 111 |
+
" \u001b[32m+\u001b[39m \u001b[1mfilelock\u001b[0m\u001b[2m==3.32.2\u001b[0m\n",
|
| 112 |
+
" \u001b[32m+\u001b[39m \u001b[1mfrozenlist\u001b[0m\u001b[2m==1.8.0\u001b[0m\n",
|
| 113 |
+
" \u001b[32m+\u001b[39m \u001b[1mfsspec\u001b[0m\u001b[2m==2026.6.0\u001b[0m\n",
|
| 114 |
+
" \u001b[32m+\u001b[39m \u001b[1mh11\u001b[0m\u001b[2m==0.16.0\u001b[0m\n",
|
| 115 |
+
" \u001b[32m+\u001b[39m \u001b[1mhf-xet\u001b[0m\u001b[2m==1.5.2\u001b[0m\n",
|
| 116 |
+
" \u001b[32m+\u001b[39m \u001b[1mhttpcore\u001b[0m\u001b[2m==1.0.9\u001b[0m\n",
|
| 117 |
+
" \u001b[32m+\u001b[39m \u001b[1mhttpx\u001b[0m\u001b[2m==0.28.1\u001b[0m\n",
|
| 118 |
+
" \u001b[32m+\u001b[39m \u001b[1mhuggingface-hub\u001b[0m\u001b[2m==1.26.0\u001b[0m\n",
|
| 119 |
+
" \u001b[32m+\u001b[39m \u001b[1midna\u001b[0m\u001b[2m==3.18\u001b[0m\n",
|
| 120 |
+
" \u001b[32m+\u001b[39m \u001b[1mjinja2\u001b[0m\u001b[2m==3.1.6\u001b[0m\n",
|
| 121 |
+
" \u001b[32m+\u001b[39m \u001b[1mjoblib\u001b[0m\u001b[2m==1.5.3\u001b[0m\n",
|
| 122 |
+
" \u001b[32m+\u001b[39m \u001b[1mmarkdown-it-py\u001b[0m\u001b[2m==4.2.0\u001b[0m\n",
|
| 123 |
+
" \u001b[32m+\u001b[39m \u001b[1mmarkupsafe\u001b[0m\u001b[2m==3.0.3\u001b[0m\n",
|
| 124 |
+
" \u001b[32m+\u001b[39m \u001b[1mmdurl\u001b[0m\u001b[2m==0.1.2\u001b[0m\n",
|
| 125 |
+
" \u001b[32m+\u001b[39m \u001b[1mmpmath\u001b[0m\u001b[2m==1.3.0\u001b[0m\n",
|
| 126 |
+
" \u001b[32m+\u001b[39m \u001b[1mmultidict\u001b[0m\u001b[2m==6.7.1\u001b[0m\n",
|
| 127 |
+
" \u001b[32m+\u001b[39m \u001b[1mmultiprocess\u001b[0m\u001b[2m==0.70.19\u001b[0m\n",
|
| 128 |
+
" \u001b[32m+\u001b[39m \u001b[1mnarwhals\u001b[0m\u001b[2m==2.24.0\u001b[0m\n",
|
| 129 |
+
" \u001b[32m+\u001b[39m \u001b[1mnetworkx\u001b[0m\u001b[2m==3.6.1\u001b[0m\n",
|
| 130 |
+
" \u001b[32m+\u001b[39m \u001b[1mnumpy\u001b[0m\u001b[2m==2.5.1\u001b[0m\n",
|
| 131 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cublas\u001b[0m\u001b[2m==13.1.1.3\u001b[0m\n",
|
| 132 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cuda-cupti\u001b[0m\u001b[2m==13.0.85\u001b[0m\n",
|
| 133 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cuda-nvrtc\u001b[0m\u001b[2m==13.0.88\u001b[0m\n",
|
| 134 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cuda-runtime\u001b[0m\u001b[2m==13.0.96\u001b[0m\n",
|
| 135 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cudnn-cu13\u001b[0m\u001b[2m==9.20.0.48\u001b[0m\n",
|
| 136 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cufft\u001b[0m\u001b[2m==12.0.0.61\u001b[0m\n",
|
| 137 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cufile\u001b[0m\u001b[2m==1.15.1.6\u001b[0m\n",
|
| 138 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-curand\u001b[0m\u001b[2m==10.4.0.35\u001b[0m\n",
|
| 139 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cusolver\u001b[0m\u001b[2m==12.0.4.66\u001b[0m\n",
|
| 140 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cusparse\u001b[0m\u001b[2m==12.6.3.3\u001b[0m\n",
|
| 141 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-cusparselt-cu13\u001b[0m\u001b[2m==0.8.1\u001b[0m\n",
|
| 142 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-nccl-cu13\u001b[0m\u001b[2m==2.29.7\u001b[0m\n",
|
| 143 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-nvjitlink\u001b[0m\u001b[2m==13.3.33\u001b[0m\n",
|
| 144 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-nvshmem-cu13\u001b[0m\u001b[2m==3.4.5\u001b[0m\n",
|
| 145 |
+
" \u001b[32m+\u001b[39m \u001b[1mnvidia-nvtx\u001b[0m\u001b[2m==13.0.85\u001b[0m\n",
|
| 146 |
+
" \u001b[32m+\u001b[39m \u001b[1mpandas\u001b[0m\u001b[2m==3.0.5\u001b[0m\n",
|
| 147 |
+
" \u001b[32m+\u001b[39m \u001b[1mpropcache\u001b[0m\u001b[2m==0.5.2\u001b[0m\n",
|
| 148 |
+
" \u001b[32m+\u001b[39m \u001b[1mprotobuf\u001b[0m\u001b[2m==7.35.1\u001b[0m\n",
|
| 149 |
+
" \u001b[32m+\u001b[39m \u001b[1mpyarrow\u001b[0m\u001b[2m==25.0.0\u001b[0m\n",
|
| 150 |
+
" \u001b[32m+\u001b[39m \u001b[1mpyyaml\u001b[0m\u001b[2m==6.0.3\u001b[0m\n",
|
| 151 |
+
" \u001b[32m+\u001b[39m \u001b[1mregex\u001b[0m\u001b[2m==2026.7.19\u001b[0m\n",
|
| 152 |
+
" \u001b[32m+\u001b[39m \u001b[1mrequests\u001b[0m\u001b[2m==2.34.2\u001b[0m\n",
|
| 153 |
+
" \u001b[32m+\u001b[39m \u001b[1mrich\u001b[0m\u001b[2m==15.0.0\u001b[0m\n",
|
| 154 |
+
" \u001b[32m+\u001b[39m \u001b[1msafetensors\u001b[0m\u001b[2m==0.8.0\u001b[0m\n",
|
| 155 |
+
" \u001b[32m+\u001b[39m \u001b[1mscikit-learn\u001b[0m\u001b[2m==1.9.0\u001b[0m\n",
|
| 156 |
+
" \u001b[32m+\u001b[39m \u001b[1mscipy\u001b[0m\u001b[2m==1.18.0\u001b[0m\n",
|
| 157 |
+
" \u001b[32m+\u001b[39m \u001b[1msentencepiece\u001b[0m\u001b[2m==0.2.2\u001b[0m\n",
|
| 158 |
+
" \u001b[32m+\u001b[39m \u001b[1msetuptools\u001b[0m\u001b[2m==83.0.0\u001b[0m\n",
|
| 159 |
+
" \u001b[32m+\u001b[39m \u001b[1mshellingham\u001b[0m\u001b[2m==1.5.4\u001b[0m\n",
|
| 160 |
+
" \u001b[32m+\u001b[39m \u001b[1msympy\u001b[0m\u001b[2m==1.14.0\u001b[0m\n",
|
| 161 |
+
" \u001b[32m+\u001b[39m \u001b[1mthreadpoolctl\u001b[0m\u001b[2m==3.6.0\u001b[0m\n",
|
| 162 |
+
" \u001b[32m+\u001b[39m \u001b[1mtokenizers\u001b[0m\u001b[2m==0.22.2\u001b[0m\n",
|
| 163 |
+
" \u001b[32m+\u001b[39m \u001b[1mtorch\u001b[0m\u001b[2m==2.13.0\u001b[0m\n",
|
| 164 |
+
" \u001b[32m+\u001b[39m \u001b[1mtqdm\u001b[0m\u001b[2m==4.70.0\u001b[0m\n",
|
| 165 |
+
" \u001b[32m+\u001b[39m \u001b[1mtransformers\u001b[0m\u001b[2m==5.14.1\u001b[0m\n",
|
| 166 |
+
" \u001b[32m+\u001b[39m \u001b[1mtriton\u001b[0m\u001b[2m==3.7.1\u001b[0m\n",
|
| 167 |
+
" \u001b[32m+\u001b[39m \u001b[1mtyper\u001b[0m\u001b[2m==0.27.0\u001b[0m\n",
|
| 168 |
+
" \u001b[32m+\u001b[39m \u001b[1murllib3\u001b[0m\u001b[2m==2.7.0\u001b[0m\n",
|
| 169 |
+
" \u001b[32m+\u001b[39m \u001b[1mxxhash\u001b[0m\u001b[2m==3.8.1\u001b[0m\n",
|
| 170 |
+
" \u001b[32m+\u001b[39m \u001b[1myarl\u001b[0m\u001b[2m==1.24.5\u001b[0m\n"
|
| 171 |
+
]
|
| 172 |
+
}
|
| 173 |
+
],
|
| 174 |
+
"source": [
|
| 175 |
+
"!uv pip install transformers huggingface_hub datasets fastrand torch sentencepiece protobuf evaluate scikit-learn accelerate>1.1.0"
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"cell_type": "code",
|
| 180 |
+
"execution_count": 1,
|
| 181 |
+
"id": "345615b8-726e-4c9a-ab56-deb322632c82",
|
| 182 |
+
"metadata": {},
|
| 183 |
+
"outputs": [
|
| 184 |
+
{
|
| 185 |
+
"name": "stderr",
|
| 186 |
+
"output_type": "stream",
|
| 187 |
+
"text": [
|
| 188 |
+
"/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
| 189 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
| 190 |
+
]
|
| 191 |
+
}
|
| 192 |
+
],
|
| 193 |
+
"source": [
|
| 194 |
+
"import numpy as np\n",
|
| 195 |
+
"import torch\n",
|
| 196 |
+
"from datasets import load_dataset\n",
|
| 197 |
+
"from transformers import (\n",
|
| 198 |
+
" AutoTokenizer, \n",
|
| 199 |
+
" AutoModelForSequenceClassification, \n",
|
| 200 |
+
" TrainingArguments, \n",
|
| 201 |
+
" Trainer,\n",
|
| 202 |
+
" DataCollatorWithPadding\n",
|
| 203 |
+
")\n",
|
| 204 |
+
"from huggingface_hub import notebook_login\n",
|
| 205 |
+
"import evaluate"
|
| 206 |
+
]
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"cell_type": "code",
|
| 210 |
+
"execution_count": 2,
|
| 211 |
+
"id": "033f1b47-2771-48ff-b89f-fcc3d93ab47d",
|
| 212 |
+
"metadata": {},
|
| 213 |
+
"outputs": [],
|
| 214 |
+
"source": [
|
| 215 |
+
"notebook_login()"
|
| 216 |
+
]
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"cell_type": "code",
|
| 220 |
+
"execution_count": 3,
|
| 221 |
+
"id": "f0ff7440-f91c-4705-9d32-d37ac1089239",
|
| 222 |
+
"metadata": {},
|
| 223 |
+
"outputs": [
|
| 224 |
+
{
|
| 225 |
+
"name": "stderr",
|
| 226 |
+
"output_type": "stream",
|
| 227 |
+
"text": [
|
| 228 |
+
"Loading weights: 100%|ββββββββββ| 136/136 [00:00<00:00, 4473.68it/s]\n",
|
| 229 |
+
"[transformers] \u001b[1mModernBertForSequenceClassification LOAD REPORT\u001b[0m from: jhu-clsp/ettin-encoder-150m\n",
|
| 230 |
+
"Key | Status | \n",
|
| 231 |
+
"------------------+------------+-\n",
|
| 232 |
+
"decoder.bias | UNEXPECTED | \n",
|
| 233 |
+
"decoder.weight | UNEXPECTED | \n",
|
| 234 |
+
"classifier.weight | MISSING | \n",
|
| 235 |
+
"classifier.bias | MISSING | \n",
|
| 236 |
+
"\n",
|
| 237 |
+
"Notes:\n",
|
| 238 |
+
"- UNEXPECTED:\tcan be ignored when loading from different task/architecture; not ok if you expect identical arch.\n",
|
| 239 |
+
"- MISSING:\tthose params were newly initialized because missing from the checkpoint. Consider training on your downstream task.\n"
|
| 240 |
+
]
|
| 241 |
+
}
|
| 242 |
+
],
|
| 243 |
+
"source": [
|
| 244 |
+
"model_name = \"jhu-clsp/ettin-encoder-150m\"\n",
|
| 245 |
+
"tokenizer = AutoTokenizer.from_pretrained(model_name)\n",
|
| 246 |
+
"model = AutoModelForSequenceClassification.from_pretrained(\n",
|
| 247 |
+
" model_name, num_labels=2,\n",
|
| 248 |
+
" dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16\n",
|
| 249 |
+
")"
|
| 250 |
+
]
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"cell_type": "code",
|
| 254 |
+
"execution_count": 4,
|
| 255 |
+
"id": "46b5f750-1b36-4437-b7cb-26331d92c595",
|
| 256 |
+
"metadata": {},
|
| 257 |
+
"outputs": [],
|
| 258 |
+
"source": [
|
| 259 |
+
"dataset = load_dataset(\"hanzceo/JOSS-data-L2\")[\"train\"]"
|
| 260 |
+
]
|
| 261 |
+
},
|
| 262 |
+
{
|
| 263 |
+
"cell_type": "code",
|
| 264 |
+
"execution_count": 5,
|
| 265 |
+
"id": "37f80b16-499f-4002-93c5-a534c4f7b289",
|
| 266 |
+
"metadata": {},
|
| 267 |
+
"outputs": [],
|
| 268 |
+
"source": [
|
| 269 |
+
"dataset = dataset.train_test_split(test_size=0.2)"
|
| 270 |
+
]
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"cell_type": "code",
|
| 274 |
+
"execution_count": 6,
|
| 275 |
+
"id": "4a8f8b10-e197-4d58-a818-2f5e8ba77d0e",
|
| 276 |
+
"metadata": {},
|
| 277 |
+
"outputs": [
|
| 278 |
+
{
|
| 279 |
+
"data": {
|
| 280 |
+
"text/plain": [
|
| 281 |
+
"DatasetDict({\n",
|
| 282 |
+
" train: Dataset({\n",
|
| 283 |
+
" features: ['sentence1', 'score'],\n",
|
| 284 |
+
" num_rows: 1600\n",
|
| 285 |
+
" })\n",
|
| 286 |
+
" test: Dataset({\n",
|
| 287 |
+
" features: ['sentence1', 'score'],\n",
|
| 288 |
+
" num_rows: 400\n",
|
| 289 |
+
" })\n",
|
| 290 |
+
"})"
|
| 291 |
+
]
|
| 292 |
+
},
|
| 293 |
+
"execution_count": 6,
|
| 294 |
+
"metadata": {},
|
| 295 |
+
"output_type": "execute_result"
|
| 296 |
+
}
|
| 297 |
+
],
|
| 298 |
+
"source": [
|
| 299 |
+
"dataset"
|
| 300 |
+
]
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"cell_type": "code",
|
| 304 |
+
"execution_count": 7,
|
| 305 |
+
"id": "fa7253f7-05a7-40a4-9727-d107adac325e",
|
| 306 |
+
"metadata": {},
|
| 307 |
+
"outputs": [
|
| 308 |
+
{
|
| 309 |
+
"name": "stderr",
|
| 310 |
+
"output_type": "stream",
|
| 311 |
+
"text": [
|
| 312 |
+
"Map: 100%|ββββββββββ| 1600/1600 [00:00<00:00, 1706.17 examples/s]\n",
|
| 313 |
+
"Map: 100%|ββββββββββ| 400/400 [00:00<00:00, 1396.96 examples/s]\n"
|
| 314 |
+
]
|
| 315 |
+
}
|
| 316 |
+
],
|
| 317 |
+
"source": [
|
| 318 |
+
"def tokenize_function(examples):\n",
|
| 319 |
+
" return tokenizer(examples[\"sentence1\"], truncation=True)\n",
|
| 320 |
+
"tokenized_datasets = dataset.map(tokenize_function, batched=True)\n",
|
| 321 |
+
"data_collator = DataCollatorWithPadding(tokenizer=tokenizer)"
|
| 322 |
+
]
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"cell_type": "code",
|
| 326 |
+
"execution_count": 8,
|
| 327 |
+
"id": "49744185-47ff-460a-9a1b-90f33f2bc991",
|
| 328 |
+
"metadata": {},
|
| 329 |
+
"outputs": [
|
| 330 |
+
{
|
| 331 |
+
"data": {
|
| 332 |
+
"text/plain": [
|
| 333 |
+
"DatasetDict({\n",
|
| 334 |
+
" train: Dataset({\n",
|
| 335 |
+
" features: ['sentence1', 'labels', 'input_ids', 'attention_mask'],\n",
|
| 336 |
+
" num_rows: 1600\n",
|
| 337 |
+
" })\n",
|
| 338 |
+
" test: Dataset({\n",
|
| 339 |
+
" features: ['sentence1', 'labels', 'input_ids', 'attention_mask'],\n",
|
| 340 |
+
" num_rows: 400\n",
|
| 341 |
+
" })\n",
|
| 342 |
+
"})"
|
| 343 |
+
]
|
| 344 |
+
},
|
| 345 |
+
"execution_count": 8,
|
| 346 |
+
"metadata": {},
|
| 347 |
+
"output_type": "execute_result"
|
| 348 |
+
}
|
| 349 |
+
],
|
| 350 |
+
"source": [
|
| 351 |
+
"tokenized_datasets = tokenized_datasets.rename_column(\"score\", \"labels\")\n",
|
| 352 |
+
"\n",
|
| 353 |
+
"tokenized_datasets"
|
| 354 |
+
]
|
| 355 |
+
},
|
| 356 |
+
{
|
| 357 |
+
"cell_type": "code",
|
| 358 |
+
"execution_count": 9,
|
| 359 |
+
"id": "93531513-4e7f-4d16-8292-8cecb44e0aa3",
|
| 360 |
+
"metadata": {},
|
| 361 |
+
"outputs": [
|
| 362 |
+
{
|
| 363 |
+
"name": "stderr",
|
| 364 |
+
"output_type": "stream",
|
| 365 |
+
"text": [
|
| 366 |
+
"Downloading builder script: 4.20kB [00:00, 14.3MB/s]\n"
|
| 367 |
+
]
|
| 368 |
+
}
|
| 369 |
+
],
|
| 370 |
+
"source": [
|
| 371 |
+
"metric = evaluate.load(\"accuracy\")\n",
|
| 372 |
+
"def compute_metrics(eval_pred):\n",
|
| 373 |
+
" logits, labels = eval_pred\n",
|
| 374 |
+
" predictions = np.argmax(logits, axis=-1)\n",
|
| 375 |
+
" return metric.compute(predictions=predictions, references=labels)"
|
| 376 |
+
]
|
| 377 |
+
},
|
| 378 |
+
{
|
| 379 |
+
"cell_type": "code",
|
| 380 |
+
"execution_count": 10,
|
| 381 |
+
"id": "b663bbee-15cb-44a9-9393-a78cf051c0fc",
|
| 382 |
+
"metadata": {},
|
| 383 |
+
"outputs": [],
|
| 384 |
+
"source": [
|
| 385 |
+
"training_args = TrainingArguments(\n",
|
| 386 |
+
" output_dir=\"models/ettin-classification\",\n",
|
| 387 |
+
" eval_strategy=\"epoch\",\n",
|
| 388 |
+
" learning_rate=2e-5,\n",
|
| 389 |
+
" per_device_train_batch_size=1,\n",
|
| 390 |
+
" per_device_eval_batch_size=1,\n",
|
| 391 |
+
" num_train_epochs=3,\n",
|
| 392 |
+
" weight_decay=0.01,\n",
|
| 393 |
+
" bf16=True\n",
|
| 394 |
+
")"
|
| 395 |
+
]
|
| 396 |
+
},
|
| 397 |
+
{
|
| 398 |
+
"cell_type": "code",
|
| 399 |
+
"execution_count": 11,
|
| 400 |
+
"id": "685b3f75-3a68-4965-bf28-ba3e70b97618",
|
| 401 |
+
"metadata": {},
|
| 402 |
+
"outputs": [
|
| 403 |
+
{
|
| 404 |
+
"data": {
|
| 405 |
+
"text/html": [
|
| 406 |
+
"\n",
|
| 407 |
+
" <div>\n",
|
| 408 |
+
" \n",
|
| 409 |
+
" <progress value='4800' max='4800' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
| 410 |
+
" [4800/4800 06:43, Epoch 3/3]\n",
|
| 411 |
+
" </div>\n",
|
| 412 |
+
" <table border=\"1\" class=\"dataframe\">\n",
|
| 413 |
+
" <thead>\n",
|
| 414 |
+
" <tr style=\"text-align: left;\">\n",
|
| 415 |
+
" <th>Epoch</th>\n",
|
| 416 |
+
" <th>Training Loss</th>\n",
|
| 417 |
+
" <th>Validation Loss</th>\n",
|
| 418 |
+
" <th>Accuracy</th>\n",
|
| 419 |
+
" </tr>\n",
|
| 420 |
+
" </thead>\n",
|
| 421 |
+
" <tbody>\n",
|
| 422 |
+
" <tr>\n",
|
| 423 |
+
" <td>1</td>\n",
|
| 424 |
+
" <td>0.626540</td>\n",
|
| 425 |
+
" <td>0.637205</td>\n",
|
| 426 |
+
" <td>0.847500</td>\n",
|
| 427 |
+
" </tr>\n",
|
| 428 |
+
" <tr>\n",
|
| 429 |
+
" <td>2</td>\n",
|
| 430 |
+
" <td>0.630978</td>\n",
|
| 431 |
+
" <td>0.628983</td>\n",
|
| 432 |
+
" <td>0.857500</td>\n",
|
| 433 |
+
" </tr>\n",
|
| 434 |
+
" <tr>\n",
|
| 435 |
+
" <td>3</td>\n",
|
| 436 |
+
" <td>0.539487</td>\n",
|
| 437 |
+
" <td>0.631988</td>\n",
|
| 438 |
+
" <td>0.857500</td>\n",
|
| 439 |
+
" </tr>\n",
|
| 440 |
+
" </tbody>\n",
|
| 441 |
+
"</table><p>"
|
| 442 |
+
],
|
| 443 |
+
"text/plain": [
|
| 444 |
+
"<IPython.core.display.HTML object>"
|
| 445 |
+
]
|
| 446 |
+
},
|
| 447 |
+
"metadata": {},
|
| 448 |
+
"output_type": "display_data"
|
| 449 |
+
},
|
| 450 |
+
{
|
| 451 |
+
"name": "stderr",
|
| 452 |
+
"output_type": "stream",
|
| 453 |
+
"text": [
|
| 454 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 7.39it/s]\n",
|
| 455 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 7.52it/s]\n",
|
| 456 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 7.01it/s]\n",
|
| 457 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 5.47it/s]\n",
|
| 458 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 4.76it/s]\n",
|
| 459 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 9.00it/s]\n",
|
| 460 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 6.39it/s]\n",
|
| 461 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 7.45it/s]\n",
|
| 462 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 6.17it/s]\n",
|
| 463 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 7.71it/s]\n"
|
| 464 |
+
]
|
| 465 |
+
},
|
| 466 |
+
{
|
| 467 |
+
"data": {
|
| 468 |
+
"text/plain": [
|
| 469 |
+
"TrainOutput(global_step=4800, training_loss=0.6138824494679769, metrics={'train_runtime': 404.0617, 'train_samples_per_second': 11.879, 'train_steps_per_second': 11.879, 'total_flos': 6650877695864220.0, 'train_loss': 0.6138824494679769, 'epoch': 3.0})"
|
| 470 |
+
]
|
| 471 |
+
},
|
| 472 |
+
"execution_count": 11,
|
| 473 |
+
"metadata": {},
|
| 474 |
+
"output_type": "execute_result"
|
| 475 |
+
}
|
| 476 |
+
],
|
| 477 |
+
"source": [
|
| 478 |
+
"trainer = Trainer(\n",
|
| 479 |
+
" model=model,\n",
|
| 480 |
+
" args=training_args,\n",
|
| 481 |
+
" data_collator=data_collator,\n",
|
| 482 |
+
" train_dataset=tokenized_datasets[\"train\"].shuffle(seed=42),\n",
|
| 483 |
+
" eval_dataset=tokenized_datasets[\"test\"].shuffle(seed=42),\n",
|
| 484 |
+
" compute_metrics=compute_metrics,\n",
|
| 485 |
+
")\n",
|
| 486 |
+
"\n",
|
| 487 |
+
"trainer.train()"
|
| 488 |
+
]
|
| 489 |
+
},
|
| 490 |
+
{
|
| 491 |
+
"cell_type": "code",
|
| 492 |
+
"execution_count": 12,
|
| 493 |
+
"id": "250248f5-021e-4247-8b2d-1d1098cf8a31",
|
| 494 |
+
"metadata": {},
|
| 495 |
+
"outputs": [
|
| 496 |
+
{
|
| 497 |
+
"data": {
|
| 498 |
+
"text/plain": [
|
| 499 |
+
"ModernBertForSequenceClassification(\n",
|
| 500 |
+
" (model): ModernBertModel(\n",
|
| 501 |
+
" (embeddings): ModernBertEmbeddings(\n",
|
| 502 |
+
" (tok_embeddings): Embedding(50368, 768, padding_idx=50283)\n",
|
| 503 |
+
" (norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 504 |
+
" (drop): Dropout(p=0.0, inplace=False)\n",
|
| 505 |
+
" )\n",
|
| 506 |
+
" (layers): ModuleList(\n",
|
| 507 |
+
" (0): ModernBertEncoderLayer(\n",
|
| 508 |
+
" (attn_norm): Identity()\n",
|
| 509 |
+
" (attn): ModernBertAttention(\n",
|
| 510 |
+
" (Wqkv): Linear(in_features=768, out_features=2304, bias=False)\n",
|
| 511 |
+
" (Wo): Linear(in_features=768, out_features=768, bias=False)\n",
|
| 512 |
+
" (out_drop): Identity()\n",
|
| 513 |
+
" )\n",
|
| 514 |
+
" (mlp_norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 515 |
+
" (mlp): ModernBertMLP(\n",
|
| 516 |
+
" (Wi): Linear(in_features=768, out_features=2304, bias=False)\n",
|
| 517 |
+
" (act): GELUActivation()\n",
|
| 518 |
+
" (drop): Dropout(p=0.0, inplace=False)\n",
|
| 519 |
+
" (Wo): Linear(in_features=1152, out_features=768, bias=False)\n",
|
| 520 |
+
" )\n",
|
| 521 |
+
" )\n",
|
| 522 |
+
" (1-21): 21 x ModernBertEncoderLayer(\n",
|
| 523 |
+
" (attn_norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 524 |
+
" (attn): ModernBertAttention(\n",
|
| 525 |
+
" (Wqkv): Linear(in_features=768, out_features=2304, bias=False)\n",
|
| 526 |
+
" (Wo): Linear(in_features=768, out_features=768, bias=False)\n",
|
| 527 |
+
" (out_drop): Identity()\n",
|
| 528 |
+
" )\n",
|
| 529 |
+
" (mlp_norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 530 |
+
" (mlp): ModernBertMLP(\n",
|
| 531 |
+
" (Wi): Linear(in_features=768, out_features=2304, bias=False)\n",
|
| 532 |
+
" (act): GELUActivation()\n",
|
| 533 |
+
" (drop): Dropout(p=0.0, inplace=False)\n",
|
| 534 |
+
" (Wo): Linear(in_features=1152, out_features=768, bias=False)\n",
|
| 535 |
+
" )\n",
|
| 536 |
+
" )\n",
|
| 537 |
+
" )\n",
|
| 538 |
+
" (final_norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 539 |
+
" (rotary_emb): ModernBertRotaryEmbedding()\n",
|
| 540 |
+
" )\n",
|
| 541 |
+
" (head): ModernBertPredictionHead(\n",
|
| 542 |
+
" (dense): Linear(in_features=768, out_features=768, bias=False)\n",
|
| 543 |
+
" (act): GELUActivation()\n",
|
| 544 |
+
" (norm): LayerNorm((768,), eps=1e-05, elementwise_affine=True, bias=False)\n",
|
| 545 |
+
" )\n",
|
| 546 |
+
" (drop): Dropout(p=0.0, inplace=False)\n",
|
| 547 |
+
" (classifier): Linear(in_features=768, out_features=2, bias=True)\n",
|
| 548 |
+
")"
|
| 549 |
+
]
|
| 550 |
+
},
|
| 551 |
+
"execution_count": 12,
|
| 552 |
+
"metadata": {},
|
| 553 |
+
"output_type": "execute_result"
|
| 554 |
+
}
|
| 555 |
+
],
|
| 556 |
+
"source": [
|
| 557 |
+
"model"
|
| 558 |
+
]
|
| 559 |
+
},
|
| 560 |
+
{
|
| 561 |
+
"cell_type": "code",
|
| 562 |
+
"execution_count": 13,
|
| 563 |
+
"id": "91374ca9-04ca-4ab7-a136-a5b329071426",
|
| 564 |
+
"metadata": {},
|
| 565 |
+
"outputs": [
|
| 566 |
+
{
|
| 567 |
+
"name": "stderr",
|
| 568 |
+
"output_type": "stream",
|
| 569 |
+
"text": [
|
| 570 |
+
"Writing model shards: 100%|ββββββββββ| 1/1 [00:00<00:00, 9.34it/s]\n",
|
| 571 |
+
"Processing Files (0 / 0): | | 0.00B / 0.00B \n",
|
| 572 |
+
"Processing Files (0 / 1): 0%| | 603kB / 299MB, 59.6kB/s \n",
|
| 573 |
+
"Processing Files (0 / 1): 1%| | 3.02MB / 299MB, 297kB/s \n",
|
| 574 |
+
"Processing Files (0 / 1): 2%|β | 7.24MB / 299MB, 708kB/s \n",
|
| 575 |
+
"Processing Files (0 / 1): 7%|β | 22.3MB / 299MB, 2.18MB/s \n",
|
| 576 |
+
"Processing Files (0 / 1): 10%|β | 29.5MB / 299MB, 2.86MB/s \n",
|
| 577 |
+
"Processing Files (0 / 1): 14%|ββ | 42.2MB / 299MB, 4.06MB/s \n",
|
| 578 |
+
"Processing Files (0 / 1): 19%|ββ | 55.5MB / 299MB, 5.31MB/s \n",
|
| 579 |
+
"Processing Files (0 / 1): 24%|βββ | 70.5MB / 299MB, 6.72MB/s \n",
|
| 580 |
+
"Processing Files (0 / 1): 27%|βββ | 80.8MB / 299MB, 7.64MB/s \n",
|
| 581 |
+
"Processing Files (0 / 1): 30%|βββ | 90.4MB / 299MB, 8.50MB/s \n",
|
| 582 |
+
"Processing Files (0 / 1): 33%|ββββ | 100MB / 299MB, 9.34MB/s \n",
|
| 583 |
+
"Processing Files (0 / 1): 37%|ββββ | 112MB / 299MB, 10.4MB/s \n",
|
| 584 |
+
"Processing Files (0 / 1): 40%|ββββ | 119MB / 299MB, 10.9MB/s \n",
|
| 585 |
+
"Processing Files (0 / 1): 41%|ββββ | 122MB / 299MB, 11.1MB/s \n",
|
| 586 |
+
"Processing Files (0 / 1): 42%|βββββ | 125MB / 299MB, 11.4MB/s \n",
|
| 587 |
+
"Processing Files (0 / 1): 43%|βββββ | 128MB / 299MB, 11.5MB/s \n",
|
| 588 |
+
"Processing Files (0 / 1): 45%|βββββ | 134MB / 299MB, 11.9MB/s \n",
|
| 589 |
+
"Processing Files (0 / 1): 46%|βββββ | 138MB / 299MB, 11.7MB/s \n",
|
| 590 |
+
"Processing Files (0 / 1): 48%|βββββ | 144MB / 299MB, 12.0MB/s \n",
|
| 591 |
+
"Processing Files (0 / 1): 49%|βββββ | 147MB / 299MB, 12.2MB/s \n",
|
| 592 |
+
"Processing Files (0 / 1): 51%|ββββββ | 153MB / 299MB, 12.6MB/s \n",
|
| 593 |
+
"Processing Files (0 / 1): 54%|ββββββ | 161MB / 299MB, 13.2MB/s \n",
|
| 594 |
+
"Processing Files (0 / 1): 57%|ββββββ | 171MB / 299MB, 14.1MB/s \n",
|
| 595 |
+
"Processing Files (0 / 1): 63%|βββββββ | 187MB / 299MB, 15.4MB/s \n",
|
| 596 |
+
"Processing Files (0 / 1): 67%|βββββββ | 201MB / 299MB, 16.5MB/s \n",
|
| 597 |
+
"Processing Files (0 / 1): 72%|ββββββββ | 216MB / 299MB, 17.7MB/s \n",
|
| 598 |
+
"Processing Files (0 / 1): 78%|ββββββββ | 234MB / 299MB, 19.1MB/s \n",
|
| 599 |
+
"Processing Files (0 / 1): 81%|βββββββββ | 244MB / 299MB, 19.9MB/s \n",
|
| 600 |
+
"Processing Files (0 / 1): 83%|βββββββββ | 249MB / 299MB, 20.1MB/s \n",
|
| 601 |
+
"Processing Files (0 / 1): 84%|βββββββββ | 253MB / 299MB, 20.3MB/s \n",
|
| 602 |
+
"Processing Files (0 / 1): 86%|βββββββββ | 258MB / 299MB, 20.6MB/s \n",
|
| 603 |
+
"Processing Files (0 / 1): 88%|βββββββββ | 262MB / 299MB, 20.8MB/s \n",
|
| 604 |
+
"Processing Files (0 / 1): 89%|βββββββββ | 267MB / 299MB, 21.1MB/s \n",
|
| 605 |
+
"Processing Files (0 / 1): 91%|βββββββββ | 272MB / 299MB, 21.3MB/s \n",
|
| 606 |
+
"Processing Files (0 / 1): 94%|ββββββββββ| 281MB / 299MB, 21.9MB/s \n",
|
| 607 |
+
"Processing Files (0 / 1): 95%|ββββββββββ| 284MB / 299MB, 22.0MB/s \n",
|
| 608 |
+
"Processing Files (0 / 1): 96%|ββββββββββ| 286MB / 299MB, 22.0MB/s \n",
|
| 609 |
+
"Processing Files (0 / 1): 96%|ββββββββββ| 288MB / 299MB, 22.0MB/s \n",
|
| 610 |
+
"Processing Files (0 / 1): 97%|ββββββββββ| 291MB / 299MB, 22.0MB/s \n",
|
| 611 |
+
"Processing Files (0 / 1): 98%|ββββββββββ| 293MB / 299MB, 22.0MB/s \n",
|
| 612 |
+
"Processing Files (0 / 1): 99%|ββββββββββ| 295MB / 299MB, 22.0MB/s \n",
|
| 613 |
+
"Processing Files (0 / 1): 100%|ββββββββββ| 298MB / 299MB, 22.1MB/s \n",
|
| 614 |
+
"Processing Files (0 / 1): 100%|ββββββββββ| 299MB / 299MB, 22.0MB/s \n",
|
| 615 |
+
"Processing Files (1 / 1): 100%|ββββββββββ| 299MB / 299MB, 20.3MB/s \n",
|
| 616 |
+
"Processing Files (1 / 1): 100%|ββββββββββ| 299MB / 299MB, 19.5MB/s \n",
|
| 617 |
+
"New Data Upload: 100%|ββββββββββ| 299MB / 299MB, 19.5MB/s \n"
|
| 618 |
+
]
|
| 619 |
+
},
|
| 620 |
+
{
|
| 621 |
+
"data": {
|
| 622 |
+
"text/plain": [
|
| 623 |
+
"CommitInfo(commit_url='https://huggingface.co/hanzceo/JOSS-dev2/commit/d1cf8f7444d284978c4e98761d2ed19b85467afe', commit_message='Upload ModernBertForSequenceClassification', commit_description='', oid='d1cf8f7444d284978c4e98761d2ed19b85467afe', pr_url=None, repo_url=RepoUrl('https://huggingface.co/hanzceo/JOSS-dev2', endpoint='https://huggingface.co', repo_type='model', repo_id='hanzceo/JOSS-dev2'), pr_revision=None, pr_num=None)"
|
| 624 |
+
]
|
| 625 |
+
},
|
| 626 |
+
"execution_count": 13,
|
| 627 |
+
"metadata": {},
|
| 628 |
+
"output_type": "execute_result"
|
| 629 |
+
}
|
| 630 |
+
],
|
| 631 |
+
"source": [
|
| 632 |
+
"model.push_to_hub(\"hanzceo/JOSS-dev2\")"
|
| 633 |
+
]
|
| 634 |
+
},
|
| 635 |
+
{
|
| 636 |
+
"cell_type": "code",
|
| 637 |
+
"execution_count": 14,
|
| 638 |
+
"id": "ed10d1ca-ada0-43db-ac78-357a865d2b4a",
|
| 639 |
+
"metadata": {},
|
| 640 |
+
"outputs": [
|
| 641 |
+
{
|
| 642 |
+
"data": {
|
| 643 |
+
"text/plain": [
|
| 644 |
+
"CommitInfo(commit_url='https://huggingface.co/hanzceo/JOSS-dev2/commit/c7d96e5e80839e397e9bc04177120915a4ea4b27', commit_message='Upload tokenizer', commit_description='', oid='c7d96e5e80839e397e9bc04177120915a4ea4b27', pr_url=None, repo_url=RepoUrl('https://huggingface.co/hanzceo/JOSS-dev2', endpoint='https://huggingface.co', repo_type='model', repo_id='hanzceo/JOSS-dev2'), pr_revision=None, pr_num=None)"
|
| 645 |
+
]
|
| 646 |
+
},
|
| 647 |
+
"execution_count": 14,
|
| 648 |
+
"metadata": {},
|
| 649 |
+
"output_type": "execute_result"
|
| 650 |
+
}
|
| 651 |
+
],
|
| 652 |
+
"source": [
|
| 653 |
+
"tokenizer.push_to_hub(\"hanzceo/JOSS-dev2\")"
|
| 654 |
+
]
|
| 655 |
+
}
|
| 656 |
+
],
|
| 657 |
+
"metadata": {
|
| 658 |
+
"kernelspec": {
|
| 659 |
+
"display_name": "Python (uv venv)",
|
| 660 |
+
"language": "python",
|
| 661 |
+
"name": "uv-kernel"
|
| 662 |
+
},
|
| 663 |
+
"language_info": {
|
| 664 |
+
"codemirror_mode": {
|
| 665 |
+
"name": "ipython",
|
| 666 |
+
"version": 3
|
| 667 |
+
},
|
| 668 |
+
"file_extension": ".py",
|
| 669 |
+
"mimetype": "text/x-python",
|
| 670 |
+
"name": "python",
|
| 671 |
+
"nbconvert_exporter": "python",
|
| 672 |
+
"pygments_lexer": "ipython3",
|
| 673 |
+
"version": "3.13.11"
|
| 674 |
+
}
|
| 675 |
+
},
|
| 676 |
+
"nbformat": 4,
|
| 677 |
+
"nbformat_minor": 5
|
| 678 |
+
}
|