gvij commited on
Commit
8940321
·
verified ·
1 Parent(s): 847197c

Upload USAGE_GUIDE.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. USAGE_GUIDE.md +181 -0
USAGE_GUIDE.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Qwen3-0.6B GGUF Models
2
+
3
+ This directory contains Qwen3-0.6B language model converted to GGUF format with multiple quantization levels optimized for CPU inference.
4
+
5
+ ## Available Model Variants
6
+
7
+ | Variant | File Size | Use Case | Quality | Speed |
8
+ |---------|-----------|----------|---------|-------|
9
+ | **FP16** | 1.4 GB | Maximum accuracy, baseline reference | Highest | Slowest |
10
+ | **Q8_0** | 767 MB | High-quality CPU inference | Very High | Medium |
11
+ | **Q5_K_M** | 526 MB | Balanced quality and performance | High | Fast |
12
+ | **Q4_K_M** | 462 MB | Edge devices, fastest inference | Good | Fastest |
13
+
14
+ ### Quantization Recommendations
15
+
16
+ - **Q4_K_M**: Best for edge devices, mobile, or when speed is critical. Minimal quality loss for most tasks.
17
+ - **Q5_K_M**: Recommended for production use. Excellent balance of quality and resource efficiency.
18
+ - **Q8_0**: Use when quality is paramount and you have sufficient memory. Close to FP16 performance.
19
+ - **FP16**: Reference model for validation and quality comparison. Use for benchmarking.
20
+
21
+ ## Model Specifications
22
+
23
+ - **Architecture**: Qwen3 Causal Language Model
24
+ - **Parameters**: 0.6B (Non-embedding: 0.44B)
25
+ - **Layers**: 28
26
+ - **Attention**: Grouped Query Attention (GQA) - 16 heads for Q, 8 heads for KV
27
+ - **Context Length**: 32,768 tokens (40,960 in config)
28
+ - **Vocabulary Size**: 151,936 tokens
29
+ - **Special Features**:
30
+ - Thinking/non-thinking mode with `<think>...</think>` tags
31
+ - Multilingual support (100+ languages)
32
+ - Tool calling capabilities
33
+ - Enhanced reasoning
34
+
35
+ ## Usage Instructions
36
+
37
+ ### 1. Using llama.cpp CLI
38
+
39
+ ```bash
40
+ # Basic text generation
41
+ /path/to/llama-cli -m qwen3-0.6b-q5_k_m.gguf -p "Hello, I am" -n 512 --temp 0.7
42
+
43
+ # Interactive chat mode
44
+ /path/to/llama-cli -m qwen3-0.6b-q5_k_m.gguf --interactive-first --reverse-prompt "User:"
45
+
46
+ # With GPU offloading (if available)
47
+ /path/to/llama-cli -m qwen3-0.6b-q5_k_m.gguf -ngl 28 -p "Explain quantum computing"
48
+ ```
49
+
50
+ ### 2. Using Ollama
51
+
52
+ Create a `Modelfile`:
53
+
54
+ ```dockerfile
55
+ FROM ./qwen3-0.6b-q5_k_m.gguf
56
+
57
+ PARAMETER temperature 0.7
58
+ PARAMETER top_k 40
59
+ PARAMETER top_p 0.9
60
+
61
+ TEMPLATE """<|im_start|>system
62
+ You are a helpful AI assistant.<|im_end|>
63
+ <|im_start|>user
64
+ {{ .Prompt }}<|im_end|>
65
+ <|im_start|>assistant
66
+ """
67
+
68
+ PARAMETER stop "<|im_start|>"
69
+ PARAMETER stop "<|im_end|>"
70
+ ```
71
+
72
+ Import and run:
73
+
74
+ ```bash
75
+ # Create the model
76
+ ollama create qwen3-0.6b -f Modelfile
77
+
78
+ # Run the model
79
+ ollama run qwen3-0.6b "What is machine learning?"
80
+ ```
81
+
82
+ ### 3. Using Python (llama-cpp-python)
83
+
84
+ ```python
85
+ from llama_cpp import Llama
86
+
87
+ # Initialize model
88
+ llm = Llama(
89
+ model_path="qwen3-0.6b-q5_k_m.gguf",
90
+ n_ctx=2048,
91
+ n_threads=4,
92
+ n_gpu_layers=0,
93
+ verbose=False
94
+ )
95
+
96
+ # Generate text
97
+ output = llm(
98
+ "Write a short poem about AI:",
99
+ max_tokens=256,
100
+ temperature=0.7,
101
+ stop=["<|im_end|>"]
102
+ )
103
+
104
+ print(output['choices'][0]['text'])
105
+ ```
106
+
107
+ ## Performance Characteristics
108
+
109
+ ### Inference Speed (approximate, CPU-dependent)
110
+
111
+ | Model | Tokens/sec (2-core) | Tokens/sec (8-core) | Memory Usage |
112
+ |-------|---------------------|---------------------|--------------|
113
+ | Q4_K_M | ~15-20 | ~40-60 | ~800 MB |
114
+ | Q5_K_M | ~12-18 | ~35-50 | ~900 MB |
115
+ | Q8_0 | ~10-15 | ~30-40 | ~1.2 GB |
116
+ | FP16 | ~8-12 | ~25-35 | ~1.8 GB |
117
+
118
+ *Note: Actual performance depends on CPU architecture, cache size, and prompt complexity.*
119
+
120
+ ### Recommended CPU Configurations
121
+
122
+ - **Minimum**: 2 cores, 2GB RAM - Use Q4_K_M
123
+ - **Recommended**: 4 cores, 4GB RAM - Use Q5_K_M
124
+ - **Optimal**: 8+ cores, 8GB RAM - Use Q8_0 or FP16
125
+
126
+ ## Context Length Management
127
+
128
+ The model supports up to 32,768 tokens but uses less memory with smaller contexts:
129
+
130
+ ```bash
131
+ # Short context (faster, less memory)
132
+ llama-cli -m qwen3-0.6b-q5_k_m.gguf --ctx-size 2048
133
+
134
+ # Long context (slower, more memory)
135
+ llama-cli -m qwen3-0.6b-q5_k_m.gguf --ctx-size 32768
136
+ ```
137
+
138
+ ## Multilingual Support
139
+
140
+ Qwen3-0.6B supports 100+ languages including English, Chinese, Spanish, French, German, Japanese, Korean, and many more.
141
+
142
+ ## Troubleshooting
143
+
144
+ ### Model fails to load
145
+ - **Solution**: Use smaller quantization (Q4_K_M) or reduce context size
146
+
147
+ ### Slow generation
148
+ - **Solution**: Increase thread count, use Q4_K_M, or reduce batch size
149
+
150
+ ### Poor quality outputs
151
+ - **Solution**: Use higher quantization (Q8_0 or FP16), adjust temperature
152
+
153
+ ## Conversion Details
154
+
155
+ - **Source**: Qwen/Qwen3-0.6B from Hugging Face Hub
156
+ - **Conversion Tool**: llama.cpp convert_hf_to_gguf.py
157
+ - **Base Format**: FP16 (converted from BF16)
158
+ - **Quantization Tool**: llama-quantize
159
+ - **Validated**: All models tested for loading and inference
160
+
161
+ ## License
162
+
163
+ This model follows the Apache 2.0 license from the original Qwen3-0.6B model.
164
+
165
+ **Original Model**: https://huggingface.co/Qwen/Qwen3-0.6B
166
+
167
+ ## Support & Resources
168
+
169
+ - **llama.cpp Documentation**: https://github.com/ggerganov/llama.cpp
170
+ - **Ollama Documentation**: https://ollama.ai/
171
+ - **Qwen3 Model Card**: https://huggingface.co/Qwen/Qwen3-0.6B
172
+
173
+ ## Version Information
174
+
175
+ - **Conversion Date**: 2024-12-17
176
+ - **llama.cpp Version**: Build 7451 (669696e00)
177
+ - **GGUF Version**: V3 (latest)
178
+
179
+ ---
180
+
181
+ **Note**: Performance metrics are approximate and will vary based on hardware. Test different quantization levels to find the optimal balance for your use case.