Instructions to use Andrew0425/AgenticASR-Refiner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Andrew0425/AgenticASR-Refiner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Andrew0425/AgenticASR-Refiner") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Andrew0425/AgenticASR-Refiner") model = AutoModelForCausalLM.from_pretrained("Andrew0425/AgenticASR-Refiner", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Andrew0425/AgenticASR-Refiner with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Andrew0425/AgenticASR-Refiner" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Andrew0425/AgenticASR-Refiner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Andrew0425/AgenticASR-Refiner
- SGLang
How to use Andrew0425/AgenticASR-Refiner 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 "Andrew0425/AgenticASR-Refiner" \ --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": "Andrew0425/AgenticASR-Refiner", "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 "Andrew0425/AgenticASR-Refiner" \ --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": "Andrew0425/AgenticASR-Refiner", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Andrew0425/AgenticASR-Refiner with Docker Model Runner:
docker model run hf.co/Andrew0425/AgenticASR-Refiner
onnx-int4
#2
by xcczach - opened
- .gitattributes +1 -0
- onnx-int4/README.md +48 -0
- onnx-int4/config.json +34 -0
- onnx-int4/generation_config.json +14 -0
- onnx-int4/model.onnx +3 -0
- onnx-int4/model.onnx.data +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
onnx-int4/model.onnx.data filter=lfs diff=lfs merge=lfs -text
|
onnx-int4/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AgenticASR-Refiner ONNX (INT4)
|
| 2 |
+
|
| 3 |
+
INT4 weight-only quantization of the Optimum ONNX export of
|
| 4 |
+
`Andrew0425/AgenticASR-Refiner` (Llama-based ASR transcript refiner, 24 layers,
|
| 5 |
+
hidden 1536, GQA 16/2, head_dim 128, vocab 130560).
|
| 6 |
+
|
| 7 |
+
- `model.onnx` + `model.onnx.data` — INT4 (MatMulNBits, block size 32, symmetric,
|
| 8 |
+
accuracy level 4), ~1.3 GB. Graph I/O is identical to the fp32 export
|
| 9 |
+
(`input_ids` / `attention_mask` / `position_ids` / `past_key_values.*`).
|
| 10 |
+
- Quantized with `onnxruntime 1.24.4` `MatMulNBitsQuantizer`
|
| 11 |
+
(`onnxruntime.quantization.matmul_nbits_quantizer`).
|
| 12 |
+
- Requires ONNX Runtime >= 1.20 (CPU EP supports `MatMulNBits`).
|
| 13 |
+
|
| 14 |
+
Tokenization uses the original repo tokenizer (`tokenizer.json` at the repo root).
|
| 15 |
+
|
| 16 |
+
## Verified generation (ONNX Runtime 1.28, CPU)
|
| 17 |
+
|
| 18 |
+
| Input | Output |
|
| 19 |
+
|---|---|
|
| 20 |
+
| 我今天去了公司然后然后开了个会,明天再去见张总 | 我今天去了公司然后开了个会,明天再去见张总 |
|
| 21 |
+
| 你好你好你好我是那个小李啊 电话是13800138000 | 你好我是小李,电话是13800138000 |
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
import numpy as np
|
| 27 |
+
import onnxruntime as ort
|
| 28 |
+
from transformers import AutoTokenizer
|
| 29 |
+
|
| 30 |
+
tokenizer = AutoTokenizer.from_pretrained("Andrew0425/AgenticASR-Refiner")
|
| 31 |
+
session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
|
| 32 |
+
input_names = [i.name for i in session.get_inputs()]
|
| 33 |
+
kv_names = [n for n in input_names if n.startswith("past_key_values")]
|
| 34 |
+
|
| 35 |
+
prompt = tokenizer.apply_chat_template(
|
| 36 |
+
[{"role": "system", "content": "你是 ASR 文本纠错助手。保留原意,最小修改。"},
|
| 37 |
+
{"role": "user", "content": "我今天去了公司然后然后开了个会"}],
|
| 38 |
+
tokenize=False, add_generation_prompt=True,
|
| 39 |
+
)
|
| 40 |
+
ids = tokenizer(prompt).input_ids
|
| 41 |
+
pasts = [np.zeros((1, 2, 0, 128), dtype=np.float32) for _ in kv_names]
|
| 42 |
+
|
| 43 |
+
# prefill, then loop decode: feed input_ids/attention_mask/position_ids + pasts
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
Note: `optimum-onnx 0.1.0` cannot yet run this checkpoint (dummy KV-cache shape
|
| 47 |
+
uses `hidden_size // num_heads` = 96 instead of `head_dim` = 128); use the raw
|
| 48 |
+
ONNX Runtime loop above, or a future fixed version of optimum-onnx.
|
onnx-int4/config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 1,
|
| 10 |
+
"head_dim": 128,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 1536,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 4608,
|
| 15 |
+
"max_position_embeddings": 131072,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 16,
|
| 19 |
+
"num_hidden_layers": 24,
|
| 20 |
+
"num_key_value_heads": 2,
|
| 21 |
+
"pad_token_id": 1,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"rope_theta": 5000000,
|
| 26 |
+
"rope_type": "default"
|
| 27 |
+
},
|
| 28 |
+
"rope_scaling": null,
|
| 29 |
+
"rope_theta": 10000.0,
|
| 30 |
+
"tie_word_embeddings": false,
|
| 31 |
+
"transformers_version": "4.57.6",
|
| 32 |
+
"use_cache": true,
|
| 33 |
+
"vocab_size": 130560
|
| 34 |
+
}
|
onnx-int4/generation_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": [
|
| 6 |
+
1,
|
| 7 |
+
1,
|
| 8 |
+
130073
|
| 9 |
+
],
|
| 10 |
+
"pad_token_id": 1,
|
| 11 |
+
"temperature": 0.9,
|
| 12 |
+
"top_p": 0.95,
|
| 13 |
+
"transformers_version": "4.57.6"
|
| 14 |
+
}
|
onnx-int4/model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:602b5e2192cf05f9656f419fe9a9cc7a45c23ced3659aa5441fbef8ba8387f85
|
| 3 |
+
size 1144846
|
onnx-int4/model.onnx.data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b93ed739800441b1e11563b8cf10bb0643e4db5e7cd82c35b305e1af55a7ed83
|
| 3 |
+
size 1352472576
|