Text Generation
Transformers
Safetensors
Hindi
English
qwen3_5
image-text-to-text
hindi
qwen3.5
unsloth
lora
instruct
india
conversational
Instructions to use pankajpandey-dev/qwen3.5-9b-hindi-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pankajpandey-dev/qwen3.5-9b-hindi-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pankajpandey-dev/qwen3.5-9b-hindi-instruct") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("pankajpandey-dev/qwen3.5-9b-hindi-instruct") model = AutoModelForMultimodalLM.from_pretrained("pankajpandey-dev/qwen3.5-9b-hindi-instruct", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pankajpandey-dev/qwen3.5-9b-hindi-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pankajpandey-dev/qwen3.5-9b-hindi-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pankajpandey-dev/qwen3.5-9b-hindi-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct
- SGLang
How to use pankajpandey-dev/qwen3.5-9b-hindi-instruct 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 "pankajpandey-dev/qwen3.5-9b-hindi-instruct" \ --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": "pankajpandey-dev/qwen3.5-9b-hindi-instruct", "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 "pankajpandey-dev/qwen3.5-9b-hindi-instruct" \ --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": "pankajpandey-dev/qwen3.5-9b-hindi-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use pankajpandey-dev/qwen3.5-9b-hindi-instruct with Docker Model Runner:
docker model run hf.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,144 +1,74 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
-
language:
|
| 4 |
-
|
| 5 |
-
- en
|
| 6 |
-
base_model: Qwen/Qwen3.5-9B
|
| 7 |
-
pipeline_tag: text-generation
|
| 8 |
library_name: transformers
|
| 9 |
-
|
| 10 |
-
- hindi
|
| 11 |
-
- qwen3_5
|
| 12 |
-
- qwen3.5
|
| 13 |
-
- unsloth
|
| 14 |
-
- lora
|
| 15 |
-
- instruction-tuning
|
| 16 |
-
- conversational
|
| 17 |
-
- india
|
| 18 |
datasets:
|
| 19 |
- ai4bharat/indic-instruct-data-v0.1
|
| 20 |
- CohereForAI/aya_dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
---
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
**Native Hindi answers, instantly — no English "thinking detour."**
|
| 26 |
-
|
| 27 |
-
Base Qwen3.5-9B knows Hindi, but ask it a simple Hindi question and it burns hundreds of tokens on an English chain-of-thought before answering — and its answers code-switch into English. This fine-tune fixes both: it responds **immediately, in pure Devanagari Hindi**, and follows instructions tightly (ask for तीन उपाय, get exactly 3).
|
| 28 |
-
|
| 29 |
-
Part of the 🇮🇳 Hindi LLM Series — small models fine-tuned for Hindi, quantized for edge/CPU use, trained on rented cloud GPUs for under $10 per run.
|
| 30 |
-
|
| 31 |
-
## Before / After
|
| 32 |
-
|
| 33 |
-
Same prompt: `स्वस्थ रहने के तीन उपाय बताइए।`
|
| 34 |
-
|
| 35 |
-
**Base Qwen3.5-9B** (400 tokens later, still hasn't answered):
|
| 36 |
-
```
|
| 37 |
-
Thinking Process:
|
| 38 |
-
1. **Analyze the Request:**
|
| 39 |
-
* Language: Hindi (Devanagari script).
|
| 40 |
-
* Task: Provide three ways to stay healthy...
|
| 41 |
-
2. **Identify Key Health Advice:**
|
| 42 |
-
* Healthy eating (balanced diet)...
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
**This model** (first tokens):
|
| 46 |
-
```
|
| 47 |
-
स्वस्थ रहने के लिए, सही आहार का सेवन करना जरूरी है, नियमित व्यायाम
|
| 48 |
-
करना चाहिए और पर्याप्त नींद लेनी चाहिए।
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
## Pipeline
|
| 52 |
-
|
| 53 |
-
```
|
| 54 |
-
Qwen/Qwen3.5-9B (instruct, hybrid-thinking)
|
| 55 |
-
|
|
| 56 |
-
v
|
| 57 |
-
SFT + LoRA (r=16, bf16) with Unsloth
|
| 58 |
-
- response-only loss, masked on "<|im_start|>assistant\n"
|
| 59 |
-
- trained WITH empty <think> blocks -> answers directly
|
| 60 |
-
|
|
| 61 |
-
v
|
| 62 |
-
qwen3.5-9b-hindi-instruct (this repo, merged 16-bit)
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
## Training data — 12,912 pairs from 4 sources
|
| 66 |
-
|
| 67 |
-
| Source | Pairs | Why |
|
| 68 |
-
|---|---|---|
|
| 69 |
-
| Anudesh (hi) | 5,000 | Native real-user Hindi prompts |
|
| 70 |
-
| Dolly (hi, IndicTrans2-translated) | 4,000 | Task diversity; kept only chrF++ >= 55 rows |
|
| 71 |
-
| wikiHow (hi) | 3,000 | Native long-form step-by-step answers |
|
| 72 |
-
| Aya (Hindi) | 912 | Human-written by native speakers |
|
| 73 |
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
| Code-switching in answers | Frequent | Not observed |
|
| 82 |
-
| "तीन बताइए" -> exactly 3 items | Unreliable | Yes |
|
| 83 |
-
| Formats (letter/essay/message) | Verbose, meta-commentary | Direct, correct format |
|
| 84 |
|
| 85 |
-
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
## Usage
|
| 88 |
|
|
|
|
| 89 |
```python
|
| 90 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=400, temperature=0.7)
|
| 99 |
-
print(tok.decode(out[0], skip_special_tokens=True))
|
| 100 |
```
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
-
- **Method:** Unsloth, LoRA r=16/alpha=16, bf16, q/k/v/o + gate/up/down (29M params, 0.31%)
|
| 111 |
-
- **Recipe:** 2 epochs, LR 1e-4 cosine, warmup 3%, effective batch 16, max_seq_len 2048
|
| 112 |
-
- **Loss:** response-only, final train loss 0.94
|
| 113 |
-
- Vision layers untouched (text-only fine-tune, vision untested)
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
2. Patching the template default to non-thinking is not enough for GGUF: **llama.cpp defines enable_thinking=true itself**. Hard-bake the closed think block into both branches.
|
| 118 |
|
| 119 |
-
##
|
|
|
|
| 120 |
|
| 121 |
-
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
- Thinking mode intentionally disabled. Not additionally safety-tuned.
|
| 125 |
-
|
| 126 |
-
## License & data notes
|
| 127 |
-
|
| 128 |
-
Weights: **Apache 2.0**. Data: Anudesh responses were Llama-2-70B-generated (Llama 2 terms), Dolly-hi is CC-BY-SA-3.0-derived, wikiHow from hi.wikihow.com, Aya Apache 2.0.
|
| 129 |
-
|
| 130 |
-
## Related
|
| 131 |
-
|
| 132 |
-
[GGUF quants](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct-GGUF) · [LoRA adapter](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct-lora) · [🇮🇳 Hindi LLM Series](https://huggingface.co/pankajpandey-dev)
|
| 133 |
-
|
| 134 |
-
## Citation
|
| 135 |
|
| 136 |
-
|
| 137 |
-
@misc{pandey2026qwen35hindi,
|
| 138 |
-
title = {Qwen3.5-9B-Hindi-Instruct},
|
| 139 |
-
author = {Pankaj Pandey},
|
| 140 |
-
year = {2026},
|
| 141 |
-
publisher = {Hugging Face},
|
| 142 |
-
howpublished = {https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct}
|
| 143 |
-
}
|
| 144 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language: [hi, en]
|
| 4 |
+
base_model: unsloth/Qwen3.5-9B
|
|
|
|
|
|
|
|
|
|
| 5 |
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
datasets:
|
| 8 |
- ai4bharat/indic-instruct-data-v0.1
|
| 9 |
- CohereForAI/aya_dataset
|
| 10 |
+
tags: [hindi, qwen3.5, unsloth, lora, instruct, india]
|
| 11 |
+
widget:
|
| 12 |
+
- text: "स्वस्थ रहने के तीन उपाय बताइए।"
|
| 13 |
+
- text: "दीपावली पर एक छोटा निबंध लिखिए।"
|
| 14 |
+
- text: "चाय बनाने की विधि चरणों में बताइए।"
|
| 15 |
---
|
| 16 |
+
# Qwen3.5-9B Hindi Instruct 🇮🇳
|
| 17 |
|
| 18 |
+
**Qwen3.5-9B fine-tuned to answer directly in fluent, native Hindi — no English code-switching, no English "thinking" detours.** Runs on a laptop CPU via the [GGUF version](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct-GGUF) (~5.7 GB).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
## Why this exists
|
| 21 |
+
Base Qwen3.5-9B knows Hindi, but ask it a Hindi question and it burns hundreds of tokens *thinking in English* inside its think block before answering — and its answers code-switch. This fine-tune closes the think block immediately and replies in pure Devanagari, following instructions tightly.
|
| 22 |
|
| 23 |
+
## Examples (from the release eval)
|
| 24 |
+
> **प्रश्न:** ऑनलाइन ठगी से बचने के तीन उपाय बताइए।
|
| 25 |
+
>
|
| 26 |
+
> **उत्तर:** आपके पास केवल एक कार्ड वाला खाता होना चाहिए (कभी भी अपने पूरे खाते को न दें)।
|
| 27 |
+
ऐसे फिशिंग ईमेल (जिनमें आपसे पैसा माँगा जाए) पर ध्यान न दें।
|
| 28 |
+
सभी ऑनलाइन लेनदेन की जांच करें।
|
| 29 |
|
| 30 |
+
> **प्रश्न:** 'ईमानदारी सबसे अच्छी नीति है' पर तीन वाक्य लिखिए।
|
| 31 |
+
>
|
| 32 |
+
> **उत्तर:** सच्चाई हमेशा सफलता लाती है। सत्य हमेशा सच्चाई से बढ़कर होता है। ईमानदारी सबसे अच्छी नीति है और ईमानदार��� हमेशा हमारे साथ रहती है।
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
> **प्रश्न:** मोबाइल फोन के दो लाभ और दो हानियाँ बताइए।
|
| 35 |
+
>
|
| 36 |
+
> **उत्तर:** संचार की सुविधा और जानकारी तक पहुंच, पर्यावरण पर प्रभाव, समय बर्बाद करना, अधिकारियों की जिम्मेदारी, संपर्क में आए व्यक्ति का समय बर्बाद करना, सामाजिक रूप से निर्लक्षी बनना
|
| 37 |
|
|
|
|
| 38 |
|
| 39 |
+
## Quickstart
|
| 40 |
```python
|
| 41 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 42 |
+
m = AutoModelForCausalLM.from_pretrained("pankajpandey-dev/qwen3.5-9b-hindi-instruct", torch_dtype="bfloat16", device_map="auto")
|
| 43 |
+
t = AutoTokenizer.from_pretrained("pankajpandey-dev/qwen3.5-9b-hindi-instruct")
|
| 44 |
+
msgs = [{"role": "user", "content": "जल संरक्षण के पाँच तरीके बताइए।"}]
|
| 45 |
+
text = t.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False)
|
| 46 |
+
out = m.generate(**t(text=text, return_tensors="pt").to(m.device),
|
| 47 |
+
max_new_tokens=400, repetition_penalty=1.1)
|
| 48 |
+
print(t.decode(out[0], skip_special_tokens=True))
|
|
|
|
|
|
|
| 49 |
```
|
| 50 |
+
Use `repetition_penalty=1.1` (set in this repo's generation_config) — long letter/essay outputs can loop without it. The chat template opens a think block; this model closes it immediately — strip `<think>...</think>` from output if present.
|
| 51 |
|
| 52 |
+
## Training recipe (fully reproducible)
|
| 53 |
+
| | |
|
| 54 |
+
|---|---|
|
| 55 |
+
| Base | unsloth/Qwen3.5-9B (bf16) |
|
| 56 |
+
| Method | LoRA r=16, alpha=16, response-only loss (Unsloth) |
|
| 57 |
+
| Data | 12,912 Hindi pairs — anudesh 5,000 · dolly-hi 4,000 (chrF++ >= 55) · wikiHow-hi 3,000 · Aya-hi 912 |
|
| 58 |
+
| Schedule | 2 epochs, LR 1e-4 cosine, effective batch 16, seq 2048 |
|
| 59 |
+
| Hardware | 1x NVIDIA L40S (48 GB), ~135 min |
|
| 60 |
+
| Final train loss | 0.938 |
|
| 61 |
|
| 62 |
+
Data deduplicated across sources, filtered for length and Latin-script ratio. wikiHow adds long-form step-by-step answers; Aya adds human-written originals.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
## Limitations
|
| 65 |
+
Parts of the data are machine-translated (dolly) or model-generated (anudesh via Llama-2-70B), so occasional unnatural phrasing or factual errors occur. Long formal-letter outputs may repeat without repetition_penalty=1.1. No additional safety tuning. Knowledge cutoff follows base Qwen3.5.
|
|
|
|
| 66 |
|
| 67 |
+
## Licensing
|
| 68 |
+
Weights: Apache 2.0. Data licenses apply to data, not weights: dolly-hi CC-BY-SA 3.0-derived; anudesh generated by Llama-2-70B (Llama 2 license); Aya Apache 2.0.
|
| 69 |
|
| 70 |
+
---
|
| 71 |
+
## 🇮🇳 About the Hindi LLM Series
|
| 72 |
+
Weekly open releases making small LLMs speak fluent, native Hindi — trained on free/low-cost GPUs, shipped as GGUF for laptops and edge devices. Built by [pankajpandey-dev](https://huggingface.co/pankajpandey-dev) *(contact links on profile)*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
**This release:** [Model](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct) · [GGUF](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct-GGUF) · [LoRA](https://huggingface.co/pankajpandey-dev/qwen3.5-9b-hindi-instruct-lora) · **Series:** [🇮🇳 Hindi LLM Collection](https://huggingface.co/pankajpandey-dev)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|