Text Generation
Transformers
Safetensors
English
qwen3_5_text
how-to
instructional
illustrated
step-by-step
chat
qwen3.5
lora
sft
conversational
Instructions to use devon7y/WikiQwen-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use devon7y/WikiQwen-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="devon7y/WikiQwen-9B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("devon7y/WikiQwen-9B") model = AutoModelForCausalLM.from_pretrained("devon7y/WikiQwen-9B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use devon7y/WikiQwen-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "devon7y/WikiQwen-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "devon7y/WikiQwen-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/devon7y/WikiQwen-9B
- SGLang
How to use devon7y/WikiQwen-9B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "devon7y/WikiQwen-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "devon7y/WikiQwen-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "devon7y/WikiQwen-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "devon7y/WikiQwen-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use devon7y/WikiQwen-9B with Docker Model Runner:
docker model run hf.co/devon7y/WikiQwen-9B
Card: round 2 (consistent captions), WikiQwen Space, Illustrator-7B
Browse files
README.md
CHANGED
|
@@ -18,9 +18,11 @@ tags:
|
|
| 18 |
|
| 19 |
# WikiQwen-9B
|
| 20 |
|
| 21 |
-
**Ask anything, get a how-to article.** WikiQwen-9B is [Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) fine-tuned to answer every message the same way: as a tidy, step-by-step how-to article in markdown, with a picture caption above each step. Hand those captions to [WikiQwen-Illustrator](https://huggingface.co/devon7y/WikiQwen-Illustrator) and they become illustrations.
|
| 22 |
|
| 23 |
-
> **Try it first:** the [WikiQwen
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## What It Does
|
| 26 |
|
|
@@ -62,7 +64,7 @@ Basil wants three things: sun, warmth and a steady drink. Get those right and it
|
|
| 62 |
|
| 63 |
Getting your first article takes about as long as boiling the kettle. The model is about 18 GB in bf16, so one 24 GB GPU is enough.
|
| 64 |
|
| 65 |
-
**1. Install the libraries.** You need PyTorch, Transformers 5 and Accelerate. The demo Space uses `transformers==5.
|
| 66 |
|
| 67 |
```bash
|
| 68 |
pip install torch "transformers>=5.14" accelerate
|
|
@@ -95,7 +97,7 @@ article = tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=
|
|
| 95 |
print(article)
|
| 96 |
```
|
| 97 |
|
| 98 |
-
**6. Pull out the captions if you want pictures.** Each `[IMAGE: …]` line is a ready-made prompt for [WikiQwen-Illustrator](https://huggingface.co/devon7y/WikiQwen-Illustrator).
|
| 99 |
|
| 100 |
```python
|
| 101 |
import re
|
|
@@ -119,13 +121,14 @@ captions = re.findall(r"^\[IMAGE: (.+?)\]\s*$", article, flags=re.M)
|
|
| 119 |
|
| 120 |
| Model | Base | Size | Notes |
|
| 121 |
| --- | --- | --- | --- |
|
| 122 |
-
| [WikiQwen-4B](https://huggingface.co/devon7y/WikiQwen-4B) | Qwen3.5-4B | 4B, dense | Fastest
|
| 123 |
-
| **WikiQwen-9B** (this one) | Qwen3.5-9B | 9B, dense | Same recipe, more capacity; in the WikiQwen
|
| 124 |
-
| [WikiQwen-9B-FP8](https://huggingface.co/devon7y/WikiQwen-9B-FP8) | WikiQwen-9B | 9B, FP8 weights | 11 GB of weights instead of 18 GB; slower than bf16 on current kernels |
|
| 125 |
| [WikiQwen-35B-A3B](https://huggingface.co/devon7y/WikiQwen-35B-A3B) | Qwen3.6-35B-A3B | 35B MoE, about 3B active | The largest |
|
| 126 |
| [WikiQwen-35B-A3B-FP8](https://huggingface.co/devon7y/WikiQwen-35B-A3B-FP8) | WikiQwen-35B-A3B | 35B MoE, FP8 experts | 37 GB instead of 69 GB: fits on one GPU |
|
| 127 |
| [WikiQwen-Illustrator](https://huggingface.co/devon7y/WikiQwen-Illustrator) | FLUX.2 [klein] base 4B | LoRA | Draws the `[IMAGE: …]` captions |
|
| 128 |
| [WikiQwen-Illustrator-9B](https://huggingface.co/devon7y/WikiQwen-Illustrator-9B) | FLUX.2 [klein] base 9B | LoRA | Sharper hands and object placement; FLUX non-commercial license |
|
|
|
|
| 129 |
|
| 130 |
## Training
|
| 131 |
|
|
@@ -133,7 +136,8 @@ captions = re.findall(r"^\[IMAGE: (.+?)\]\s*$", article, flags=re.M)
|
|
| 133 |
- **From article to chat:** each article became one conversation. The user turn is a realistic message written for that article by Qwen3.6-35B-A3B. The styles range from direct questions to oblique remarks and messages that aren't how-to questions at all, which is how the model learned to answer anything with an article. The assistant turn is the article in the markdown format above, keeping at most its first two methods or parts.
|
| 134 |
- **Captions:** every step carries an `[IMAGE: …]` line. (pending) of these captions describe the step's real Creative Commons illustration, written by a vision-language model (Qwen3.6-35B-A3B). The rest were written from the step text alone. The Illustrator was trained on captions in the same style, so the chat model writes prompts the image model already understands.
|
| 135 |
- **Size:** (pending) training conversations and (pending) for validation. A 1% bucket of articles never entered training, and the held-out evaluation prompts below come from it.
|
| 136 |
-
- **
|
|
|
|
| 137 |
|
| 138 |
## Evaluation
|
| 139 |
|
|
@@ -156,13 +160,29 @@ Replies were sampled at temperature 0.7, top_p 0.9 and repetition penalty 1.05,
|
|
| 156 |
| Words per article (median) | 1,055.5 | 1,030 |
|
| 157 |
| Cut off by the token limit | 1% | 6% |
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
## Limitations
|
| 160 |
|
| 161 |
- **The advice can be wrong.** It sounds confident and looks tidy either way. Be most careful with health, safety, legal and money questions: check anything that matters with a qualified source.
|
| 162 |
- **Everything is an article.** "hi", "tell me a joke" and "what's 2 + 2" all get a how-to article back. That is the point, but it means this is not a general assistant.
|
| 163 |
- **Knowledge is dated and general.** It knows what the base model knows plus a 2023 snapshot of how-to articles. It can't browse, and it may invent product names, measurements or steps.
|
| 164 |
- **Generated articles are not real articles** from the source site, and no contributor wrote or reviewed them.
|
| 165 |
-
- **Pictures can mislead.**
|
| 166 |
- **No extra safety training.** The fine-tune only taught a format, and the article habit is strong. It may write an article for a request it should turn down, so don't rely on it to refuse.
|
| 167 |
- **English only**, and long answers can be cut off at the token limit.
|
| 168 |
|
|
|
|
| 18 |
|
| 19 |
# WikiQwen-9B
|
| 20 |
|
| 21 |
+
**Ask anything, get a how-to article.** WikiQwen-9B is [Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) fine-tuned to answer every message the same way: as a tidy, step-by-step how-to article in markdown, with a picture caption above each step. Hand those captions to [WikiQwen-Illustrator-7B](https://huggingface.co/devon7y/WikiQwen-Illustrator-7B) and they become illustrations.
|
| 22 |
|
| 23 |
+
> **Try it first:** the [WikiQwen](https://huggingface.co/spaces/devon7y/wikiqwen) Space runs this model and draws each step with WikiQwen-Illustrator-7B.
|
| 24 |
+
|
| 25 |
+
> **Round 2 (current weights):** the picture captions now keep one look for every recurring person, animal and object across an article, so the pictures tell one story (see [Training](#training) and [Evaluation](#evaluation)). The round-1 weights are still in this repo's commit history.
|
| 26 |
|
| 27 |
## What It Does
|
| 28 |
|
|
|
|
| 64 |
|
| 65 |
Getting your first article takes about as long as boiling the kettle. The model is about 18 GB in bf16, so one 24 GB GPU is enough.
|
| 66 |
|
| 67 |
+
**1. Install the libraries.** You need PyTorch, Transformers 5 and Accelerate. The demo Space uses `transformers==5.17.0`.
|
| 68 |
|
| 69 |
```bash
|
| 70 |
pip install torch "transformers>=5.14" accelerate
|
|
|
|
| 97 |
print(article)
|
| 98 |
```
|
| 99 |
|
| 100 |
+
**6. Pull out the captions if you want pictures.** Each `[IMAGE: …]` line is a ready-made prompt for [WikiQwen-Illustrator-7B](https://huggingface.co/devon7y/WikiQwen-Illustrator-7B).
|
| 101 |
|
| 102 |
```python
|
| 103 |
import re
|
|
|
|
| 121 |
|
| 122 |
| Model | Base | Size | Notes |
|
| 123 |
| --- | --- | --- | --- |
|
| 124 |
+
| [WikiQwen-4B](https://huggingface.co/devon7y/WikiQwen-4B) | Qwen3.5-4B | 4B, dense | Fastest |
|
| 125 |
+
| **WikiQwen-9B** (this one) | Qwen3.5-9B | 9B, dense | Same recipe, more capacity, plus round-2 consistent captions; in the [WikiQwen](https://huggingface.co/spaces/devon7y/wikiqwen) Space |
|
| 126 |
+
| [WikiQwen-9B-FP8](https://huggingface.co/devon7y/WikiQwen-9B-FP8) | WikiQwen-9B (round 1) | 9B, FP8 weights | 11 GB of weights instead of 18 GB; slower than bf16 on current kernels |
|
| 127 |
| [WikiQwen-35B-A3B](https://huggingface.co/devon7y/WikiQwen-35B-A3B) | Qwen3.6-35B-A3B | 35B MoE, about 3B active | The largest |
|
| 128 |
| [WikiQwen-35B-A3B-FP8](https://huggingface.co/devon7y/WikiQwen-35B-A3B-FP8) | WikiQwen-35B-A3B | 35B MoE, FP8 experts | 37 GB instead of 69 GB: fits on one GPU |
|
| 129 |
| [WikiQwen-Illustrator](https://huggingface.co/devon7y/WikiQwen-Illustrator) | FLUX.2 [klein] base 4B | LoRA | Draws the `[IMAGE: …]` captions |
|
| 130 |
| [WikiQwen-Illustrator-9B](https://huggingface.co/devon7y/WikiQwen-Illustrator-9B) | FLUX.2 [klein] base 9B | LoRA | Sharper hands and object placement; FLUX non-commercial license |
|
| 131 |
+
| [WikiQwen-Illustrator-7B](https://huggingface.co/devon7y/WikiQwen-Illustrator-7B) | Qwen-Image-2.1 | LoRA | The WikiQwen Space's illustrator; spells the text in pictures far better (sample with true CFG 4) |
|
| 132 |
|
| 133 |
## Training
|
| 134 |
|
|
|
|
| 136 |
- **From article to chat:** each article became one conversation. The user turn is a realistic message written for that article by Qwen3.6-35B-A3B. The styles range from direct questions to oblique remarks and messages that aren't how-to questions at all, which is how the model learned to answer anything with an article. The assistant turn is the article in the markdown format above, keeping at most its first two methods or parts.
|
| 137 |
- **Captions:** every step carries an `[IMAGE: …]` line. (pending) of these captions describe the step's real Creative Commons illustration, written by a vision-language model (Qwen3.6-35B-A3B). The rest were written from the step text alone. The Illustrator was trained on captions in the same style, so the chat model writes prompts the image model already understands.
|
| 138 |
- **Size:** (pending) training conversations and (pending) for validation. A 1% bucket of articles never entered training, and the held-out evaluation prompts below come from it.
|
| 139 |
+
- **Round 2, consistent captions (current weights):** the round-1 captions were written one picture or one step at a time, so a recurring subject often changed color or look between steps. The untuned Qwen3.6-35B-A3B rewrote all captions of 25,300 training articles together, giving each recurring person, animal or object one fixed look and quoting the exact short text a picture should show, without touching the article text. The round-1 LoRA then continued for 734 steps (learning rate 5e-5, effective batch 16) on the 9,383 rewritten articles whose consistency improved and whose captions kept their step's own details, mixed with 2,346 unchanged articles that already had consistent captions.
|
| 140 |
+
- **Recipe (round 1):** supervised fine-tuning with LoRA (rank 32, alpha 64, dropout 0.05) on the attention and MLP projections (q, k, v, o, gate, up, down). Loss was on the assistant turn only. One epoch, learning rate 1e-4 with a cosine schedule and 3% warm-up, effective batch 16, sequences up to 4,096 tokens, bf16, on one GPU. The adapter was then merged into the base weights.
|
| 141 |
|
| 142 |
## Evaluation
|
| 143 |
|
|
|
|
| 160 |
| Words per article (median) | 1,055.5 | 1,030 |
|
| 161 |
| Cut off by the token limit | 1% | 6% |
|
| 162 |
|
| 163 |
+
### Picture consistency (round 2)
|
| 164 |
+
|
| 165 |
+
38 prompts x 8 samples (304 articles), serving settings, round 1 vs round 2. Checks are automatic: a recurring subject "changes color" when two captions of one article give it different colors.
|
| 166 |
+
|
| 167 |
+
| Check | Round 1 | Round 2 |
|
| 168 |
+
| --- | ---: | ---: |
|
| 169 |
+
| Articles with a color conflict between captions | 51.6% | 26.3% |
|
| 170 |
+
| Recurring subjects that change color | 39.5% | 13.3% |
|
| 171 |
+
| Articles where a person's look changes | 26.6% | 6.2% |
|
| 172 |
+
| Articles with a gender switch | 13.8% | 5.3% |
|
| 173 |
+
| Person captions that describe the person (hair or clothes) | 43% | 74% |
|
| 174 |
+
| Valid article format | 85.5% | 85.2% |
|
| 175 |
+
| Loops | 3.3% | 2.6% |
|
| 176 |
+
|
| 177 |
+
Validation loss on the round-1 set moved from 1.311 to 1.315, so round 2 kept round 1's writing.
|
| 178 |
+
|
| 179 |
## Limitations
|
| 180 |
|
| 181 |
- **The advice can be wrong.** It sounds confident and looks tidy either way. Be most careful with health, safety, legal and money questions: check anything that matters with a qualified source.
|
| 182 |
- **Everything is an article.** "hi", "tell me a joke" and "what's 2 + 2" all get a how-to article back. That is the point, but it means this is not a general assistant.
|
| 183 |
- **Knowledge is dated and general.** It knows what the base model knows plus a 2023 snapshot of how-to articles. It can't browse, and it may invent product names, measurements or steps.
|
| 184 |
- **Generated articles are not real articles** from the source site, and no contributor wrote or reviewed them.
|
| 185 |
+
- **Pictures can mislead.** A picture can show a step wrongly, and long text inside a picture can still come out with typos.
|
| 186 |
- **No extra safety training.** The fine-tune only taught a format, and the article habit is strong. It may write an article for a request it should turn down, so don't rely on it to refuse.
|
| 187 |
- **English only**, and long answers can be cut off at the token limit.
|
| 188 |
|