Text Generation
Transformers
Safetensors
English
qwen2
qwen2.5
quantization
mixed-precision
custom-code
nanollm
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use RthItalia/NanoLLM-Qwen2.5-3B-v3.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RthItalia/NanoLLM-Qwen2.5-3B-v3.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RthItalia/NanoLLM-Qwen2.5-3B-v3.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("RthItalia/NanoLLM-Qwen2.5-3B-v3.1") model = AutoModelForMultimodalLM.from_pretrained("RthItalia/NanoLLM-Qwen2.5-3B-v3.1") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RthItalia/NanoLLM-Qwen2.5-3B-v3.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RthItalia/NanoLLM-Qwen2.5-3B-v3.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RthItalia/NanoLLM-Qwen2.5-3B-v3.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RthItalia/NanoLLM-Qwen2.5-3B-v3.1
- SGLang
How to use RthItalia/NanoLLM-Qwen2.5-3B-v3.1 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 "RthItalia/NanoLLM-Qwen2.5-3B-v3.1" \ --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": "RthItalia/NanoLLM-Qwen2.5-3B-v3.1", "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 "RthItalia/NanoLLM-Qwen2.5-3B-v3.1" \ --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": "RthItalia/NanoLLM-Qwen2.5-3B-v3.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RthItalia/NanoLLM-Qwen2.5-3B-v3.1 with Docker Model Runner:
docker model run hf.co/RthItalia/NanoLLM-Qwen2.5-3B-v3.1
Update model card for full single safetensors
Browse files
README.md
CHANGED
|
@@ -1,58 +1,28 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
| 3 |
-
- en
|
| 4 |
-
- zh
|
| 5 |
-
- it
|
| 6 |
license: other
|
| 7 |
-
tags:
|
| 8 |
-
- quantization
|
| 9 |
-
- qwen
|
| 10 |
-
- qwen2.5
|
| 11 |
-
- mixed-precision
|
| 12 |
-
- inference
|
| 13 |
library_name: transformers
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# NanoLLM
|
| 18 |
-
|
| 19 |
-
NanoLLM v3.1 artifacts are compact overlay artifacts for Qwen2.5 models. The loader starts from the base model in bitsandbytes 8-bit mode, then replaces the modules that passed the NanoLLM cascade with `TrueQuantLinear` modules.
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
| --- | --- | ---: | --- | ---: | ---: | ---: |
|
| 25 |
-
| Qwen2.5-3B-Instruct | `final_artifact_3B.zip` | 799,189,680 bytes | PASS | 0.990625 | 0.984375 | 143 / 109 |
|
| 26 |
-
| Qwen2.5-7B-Instruct | `final_artifact_7B.zip` | 891,419,698 bytes | PASS | 0.990625 | 0.98046875 | 66 / 130 |
|
| 27 |
-
| Qwen2.5-14B-Instruct | `final_artifact_Qwen2.5-14B-Instruct_pruned_pass.zip` | 1,482,019,132 bytes | PASS | 0.990625 | 0.98046875 | 76 / 260 |
|
| 28 |
-
|
| 29 |
-
The current release gate checks average next-token-logit cosine similarity against the 8-bit reference: `avg >= 0.99`. Minimum cosine is reported as a diagnostic.
|
| 30 |
-
|
| 31 |
-
## Quick Start
|
| 32 |
|
| 33 |
```python
|
| 34 |
-
from
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 39 |
-
outputs = model.generate(**inputs, max_new_tokens=160, do_sample=False)
|
| 40 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 41 |
```
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
```
|
| 48 |
-
|
| 49 |
-
## Runtime Notes
|
| 50 |
-
|
| 51 |
-
- `build_reference_mode`: `8bit`
|
| 52 |
-
- `reference_scope`: `original_baseline`
|
| 53 |
-
- `pending_policy`: `leave_in_base_8bit`
|
| 54 |
-
- `NANO_LOAD_4BIT=1` can be used experimentally to load the base model in 4-bit, but the release tests use 8-bit.
|
| 55 |
-
|
| 56 |
-
## License
|
| 57 |
-
|
| 58 |
-
The NanoLLM quantization pipeline is proprietary/internal. Generated artifacts are published for research and evaluation subject to the repository license terms.
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: other
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
library_name: transformers
|
| 4 |
+
base_model: Qwen/Qwen2.5-3B-Instruct
|
| 5 |
+
tags:
|
| 6 |
+
- nanollm
|
| 7 |
+
- qwen2.5
|
| 8 |
+
- safetensors
|
| 9 |
+
- text-generation
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# NanoLLM Qwen2.5-3B-Instruct v3.1
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
Self-contained full NanoLLM model is in `full_single/`.
|
| 15 |
|
| 16 |
+
Usage:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
```python
|
| 19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 20 |
+
repo_id = "RthItalia/NanoLLM-Qwen2.5-3B-v3.1"
|
| 21 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="full_single", use_fast=True)
|
| 22 |
+
model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="full_single", device_map="auto")
|
|
|
|
|
|
|
|
|
|
| 23 |
```
|
| 24 |
|
| 25 |
+
Validation against 8-bit reference:
|
| 26 |
+
- avg cosine: 0.98984375
|
| 27 |
+
- min cosine: 0.984375
|
| 28 |
+
- gate: avg >= 0.985
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|