armaniii commited on
Commit
5ed7e6b
·
verified ·
1 Parent(s): 007cea2

Model card v3: step-by-step gated-access walkthrough, separate GPU/CPU quickstarts with hardware requirements, batch processing with tqdm progress bar

Browse files
Files changed (1) hide show
  1. README.md +38 -3
README.md CHANGED
@@ -49,7 +49,20 @@ Practical consequences:
49
  - Do **not** try to remove/override `quantization_config` to get fp16: the stored weights themselves are 4-bit packed, so there is no full-precision copy in this repo. To obtain higher-precision weights, load 4-bit first and call `model.dequantize()` (see below).
50
  - VRAM needed is only **~6 GB** — the model fits on small GPUs.
51
 
52
- ## Quickstart
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  ```bash
55
  pip install torch transformers accelerate bitsandbytes
@@ -66,11 +79,22 @@ tokenizer.pad_token_id = tokenizer.eos_token_id
66
  tokenizer.padding_side = "left"
67
 
68
  # quantization_config ships in config.json — transformers loads the 4-bit
69
- # weights automatically (CUDA GPU recommended, ~6 GB VRAM)
70
  model = AutoModelForCausalLM.from_pretrained(REPO, device_map="auto", low_cpu_mem_usage=True)
71
  model.eval()
72
  ```
73
 
 
 
 
 
 
 
 
 
 
 
 
74
  ### Prompt format (must match training)
75
 
76
  The model expects the Llama-3 chat header format with the WIBA topic-extraction system prompt, and the generation cut off after a few tokens (topics are short):
@@ -123,9 +147,20 @@ The original implementation uses the equivalent `pipeline("text-generation", ...
123
  - An argumentative input → a short topic phrase (e.g. `Climate change`, `Gun control`)
124
  - A non-argument input → the literal string `No Topic`
125
 
 
 
 
 
 
 
 
 
 
 
 
126
  ## Getting full-precision weights
127
 
128
- The repo stores no fp16 copy, but you can dequantize after loading (needs enough memory for the fp16 model, ~16 GB):
129
 
130
  ```python
131
  model = AutoModelForCausalLM.from_pretrained(REPO, device_map="auto")
 
49
  - Do **not** try to remove/override `quantization_config` to get fp16: the stored weights themselves are 4-bit packed, so there is no full-precision copy in this repo. To obtain higher-precision weights, load 4-bit first and call `model.dequantize()` (see below).
50
  - VRAM needed is only **~6 GB** — the model fits on small GPUs.
51
 
52
+ ## Before you start
53
+
54
+ **No gated access needed** — unlike the detect and stance stages, this repo is fully self-contained (no Meta base model to download), so there is no license gate, no account, and no token required. The first run downloads ~6 GB with progress bars, cached afterward in `~/.cache/huggingface`.
55
+
56
+ ## Hardware requirements — pick your setup
57
+
58
+ | Setup | What you need | Speed |
59
+ |---|---|---|
60
+ | **GPU (recommended)** | NVIDIA GPU with ≥8 GB free VRAM, `pip install bitsandbytes` | fast — this is the wiba.dev production configuration |
61
+ | **CPU only** | ~25 GB free RAM, no GPU; loads 4-bit then dequantizes (see below) | ~1–2 min per text on 16 cores |
62
+
63
+ ⚠️ Do **not** run `generate()` directly on the 4-bit model on a CPU: bitsandbytes' CPU 4-bit kernels are single-threaded and a single sentence takes over an hour (measured). Use the dequantize recipe below instead.
64
+
65
+ ## Quickstart — GPU
66
 
67
  ```bash
68
  pip install torch transformers accelerate bitsandbytes
 
79
  tokenizer.padding_side = "left"
80
 
81
  # quantization_config ships in config.json — transformers loads the 4-bit
82
+ # weights automatically (~6 GB VRAM)
83
  model = AutoModelForCausalLM.from_pretrained(REPO, device_map="auto", low_cpu_mem_usage=True)
84
  model.eval()
85
  ```
86
 
87
+ ## Quickstart — CPU (no GPU)
88
+
89
+ `bitsandbytes` is still required (the checkpoint is stored 4-bit), but after loading, dequantize to bfloat16 so generation runs on all CPU cores (verified: ~25 GB RAM peak, then ~1–2 min per text on 16 cores):
90
+
91
+ ```python
92
+ model = AutoModelForCausalLM.from_pretrained(REPO, device_map="cpu", low_cpu_mem_usage=True)
93
+ model = model.dequantize().to(torch.bfloat16)
94
+ model.eval()
95
+ torch.set_num_threads(16) # match your core count
96
+ ```
97
+
98
  ### Prompt format (must match training)
99
 
100
  The model expects the Llama-3 chat header format with the WIBA topic-extraction system prompt, and the generation cut off after a few tokens (topics are short):
 
147
  - An argumentative input → a short topic phrase (e.g. `Climate change`, `Gun control`)
148
  - A non-argument input → the literal string `No Topic`
149
 
150
+ ## Batch processing many texts (with a progress bar)
151
+
152
+ Model downloads show progress bars automatically; generation doesn't, so wrap your loop in `tqdm` (installed with transformers) exactly as the original WIBA serving code does:
153
+
154
+ ```python
155
+ from tqdm import tqdm
156
+
157
+ texts = ["...", "..."] # your data
158
+ topics = [extract_topic(t) for t in tqdm(texts)]
159
+ ```
160
+
161
  ## Getting full-precision weights
162
 
163
+ The repo stores no fp16 copy, but you can dequantize after loading (needs enough memory for the fp16 model, ~16 GB — this is the same call the CPU quickstart uses):
164
 
165
  ```python
166
  model = AutoModelForCausalLM.from_pretrained(REPO, device_map="auto")