Text Generation
Transformers
Safetensors
Chinese
English
audio-only-thinker
qwen2.5
audio
open-source
thinker
conversational
custom_code
Instructions to use chunhuizng/AudioOnlyThinker with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chunhuizng/AudioOnlyThinker with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chunhuizng/AudioOnlyThinker", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("chunhuizng/AudioOnlyThinker", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use chunhuizng/AudioOnlyThinker with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chunhuizng/AudioOnlyThinker" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chunhuizng/AudioOnlyThinker", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chunhuizng/AudioOnlyThinker
- SGLang
How to use chunhuizng/AudioOnlyThinker 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 "chunhuizng/AudioOnlyThinker" \ --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": "chunhuizng/AudioOnlyThinker", "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 "chunhuizng/AudioOnlyThinker" \ --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": "chunhuizng/AudioOnlyThinker", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chunhuizng/AudioOnlyThinker with Docker Model Runner:
docker model run hf.co/chunhuizng/AudioOnlyThinker
| # audio_only_processor.py | |
| import numpy as np | |
| from typing import List, Optional, Union | |
| from transformers import WhisperFeatureExtractor, Qwen2TokenizerFast | |
| from transformers.processing_utils import ProcessorMixin | |
| from transformers.tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput | |
| from transformers.feature_extraction_utils import BatchFeature | |
| class AudioOnlyProcessor(ProcessorMixin): | |
| """ | |
| A processor class for AudioOnlyThinker. Handles only text + audio input (no image/video support). | |
| """ | |
| feature_extractor_class = "WhisperFeatureExtractor" | |
| tokenizer_class = ("Qwen2Tokenizer", "Qwen2TokenizerFast") | |
| model_input_names = ["input_features", "attention_mask", "input_ids", "feature_attention_mask"] | |
| def __init__(self, feature_extractor=None, tokenizer=None, chat_template=None): | |
| self.audio_token = "<|AUDIO|>" | |
| self.audio_bos_token = "<|audio_bos|>" | |
| self.audio_eos_token = "<|audio_eos|>" | |
| self.tokenizer = tokenizer | |
| self.feature_extractor = feature_extractor | |
| self.current_processor = self.tokenizer | |
| self.chat_template = chat_template | |
| def __call__( | |
| self, | |
| text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]], | |
| audios: Union[np.ndarray, List[np.ndarray]], | |
| sampling_rate: Optional[int] = 16000, | |
| padding: Union[bool, str, PaddingStrategy] = False, | |
| **kwargs, | |
| ) -> BatchFeature: | |
| if not isinstance(text, list): | |
| text = [text] | |
| audios_inputs = self.feature_extractor( | |
| audios, sampling_rate=sampling_rate, return_attention_mask=True, padding="max_length", **kwargs | |
| ) | |
| audios_inputs["feature_attention_mask"] = audios_inputs.pop("attention_mask") | |
| audios_inputs["input_features"] = audios_inputs.pop("input_features") | |
| input_lengths = (audios_inputs["feature_attention_mask"].sum(-1).numpy() - 1) // 2 + 1 | |
| audio_lengths = (input_lengths - 2) // 2 + 1 | |
| # Replace <|AUDIO|> token with audio_placeholder repeated by length | |
| for i in range(len(text)): | |
| text[i] = text[i].replace( | |
| self.audio_token, | |
| "<|audio_placeholder|>" * audio_lengths[0], # assumes 1 audio per input | |
| 1, | |
| ) | |
| text[i] = text[i].replace("<|audio_placeholder|>", self.audio_token) | |
| text_inputs = self.tokenizer(text, padding=padding, return_tensors=kwargs.get("return_tensors", None)) | |
| return BatchFeature(data={**text_inputs, **audios_inputs}, tensor_type=kwargs.get("return_tensors")) | |
| def apply_chat_template(self, conversations, chat_template=None, **kwargs): | |
| if isinstance(conversations[0], dict): | |
| conversations = [conversations] | |
| return self.tokenizer.apply_chat_template(conversations, chat_template=chat_template, **kwargs) | |
| def batch_decode(self, *args, **kwargs): | |
| return self.tokenizer.batch_decode(*args, **kwargs) | |
| def decode(self, *args, **kwargs): | |
| return self.tokenizer.decode(*args, **kwargs) | |
| def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): | |
| tokenizer = Qwen2TokenizerFast.from_pretrained(pretrained_model_name_or_path, **kwargs) | |
| feature_extractor = WhisperFeatureExtractor.from_pretrained(pretrained_model_name_or_path, **kwargs) | |
| return cls(feature_extractor=feature_extractor, tokenizer=tokenizer) | |
| def save_pretrained(self, save_directory): | |
| self.tokenizer.save_pretrained(save_directory) | |
| self.feature_extractor.save_pretrained(save_directory) | |