arach commited on
Commit
2eb8eed
·
verified ·
1 Parent(s): 5fea69b

Add Colab notebook for news summarization eval

Browse files
eval/news_summarization/notebook.ipynb ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "title"
7
+ },
8
+ "source": [
9
+ "# News Summarization Eval\n",
10
+ "\n",
11
+ "Colab-friendly notebook for running the news summarization benchmark on a strong open-weight Hugging Face model.\n",
12
+ "\n",
13
+ "Recommended first model:\n",
14
+ "- `Qwen/Qwen3.5-8B-Instruct-2507`\n"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": null,
20
+ "metadata": {
21
+ "id": "install"
22
+ },
23
+ "outputs": [],
24
+ "source": [
25
+ "!pip install -q transformers accelerate sentencepiece bert-score rouge-score"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": null,
31
+ "metadata": {
32
+ "id": "clone"
33
+ },
34
+ "outputs": [],
35
+ "source": [
36
+ "!git clone https://github.com/arach/lab.git /content/lab\n",
37
+ "%cd /content/lab"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": null,
43
+ "metadata": {
44
+ "id": "config"
45
+ },
46
+ "outputs": [],
47
+ "source": [
48
+ "MODEL = \"Qwen/Qwen3.5-8B-Instruct-2507\"\n",
49
+ "LIMIT = 50\n",
50
+ "PROMPT_STYLE = \"simple\"\n",
51
+ "DTYPE = \"bfloat16\"\n",
52
+ "TRUST_REMOTE_CODE = True"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {
59
+ "id": "run"
60
+ },
61
+ "outputs": [],
62
+ "source": [
63
+ "trust_flag = \"--trust-remote-code\" if TRUST_REMOTE_CODE else \"\"\n",
64
+ "!python eval/news_summarization/run_hf_transformers.py \\\n",
65
+ " --model {MODEL} \\\n",
66
+ " --limit {LIMIT} \\\n",
67
+ " --prompt-style {PROMPT_STYLE} \\\n",
68
+ " --dtype {DTYPE} \\\n",
69
+ " --verbose \\\n",
70
+ " {trust_flag}"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": null,
76
+ "metadata": {
77
+ "id": "resume"
78
+ },
79
+ "outputs": [],
80
+ "source": [
81
+ "trust_flag = \"--trust-remote-code\" if TRUST_REMOTE_CODE else \"\"\n",
82
+ "!python eval/news_summarization/run_hf_transformers.py \\\n",
83
+ " --model {MODEL} \\\n",
84
+ " --limit {LIMIT} \\\n",
85
+ " --prompt-style {PROMPT_STYLE} \\\n",
86
+ " --dtype {DTYPE} \\\n",
87
+ " --resume \\\n",
88
+ " {trust_flag}"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "code",
93
+ "execution_count": null,
94
+ "metadata": {
95
+ "id": "inspect"
96
+ },
97
+ "outputs": [],
98
+ "source": [
99
+ "!ls -lh eval/news_summarization/results\n",
100
+ "!python - <<'PY'\n",
101
+ "import json\n",
102
+ "from pathlib import Path\n",
103
+ "files = sorted(Path('eval/news_summarization/results').glob('hf-transformers-*.json'))\n",
104
+ "if not files:\n",
105
+ " print('No result file yet')\n",
106
+ "else:\n",
107
+ " latest = files[-1]\n",
108
+ " print('Latest:', latest)\n",
109
+ " data = json.loads(latest.read_text())\n",
110
+ " print(json.dumps(data.get('summary', {}), indent=2))\n",
111
+ "PY"
112
+ ]
113
+ }
114
+ ],
115
+ "metadata": {
116
+ "colab": {
117
+ "provenance": [],
118
+ "gpuType": "A100"
119
+ },
120
+ "kernelspec": {
121
+ "display_name": "Python 3",
122
+ "name": "python3"
123
+ },
124
+ "language_info": {
125
+ "name": "python"
126
+ }
127
+ },
128
+ "nbformat": 4,
129
+ "nbformat_minor": 5
130
+ }