Text Generation
Transformers
Safetensors
Hindi
English
gemma4
image-text-to-text
hindi
indic
gemma
unsloth
conversational
Instructions to use pankajpandey-dev/gemma-4-e4b-hindi-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pankajpandey-dev/gemma-4-e4b-hindi-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pankajpandey-dev/gemma-4-e4b-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/gemma-4-e4b-hindi-instruct") model = AutoModelForMultimodalLM.from_pretrained("pankajpandey-dev/gemma-4-e4b-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?"} ] }, ] 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/gemma-4-e4b-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/gemma-4-e4b-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/gemma-4-e4b-hindi-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pankajpandey-dev/gemma-4-e4b-hindi-instruct
- SGLang
How to use pankajpandey-dev/gemma-4-e4b-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/gemma-4-e4b-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/gemma-4-e4b-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/gemma-4-e4b-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/gemma-4-e4b-hindi-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use pankajpandey-dev/gemma-4-e4b-hindi-instruct with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pankajpandey-dev/gemma-4-e4b-hindi-instruct to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pankajpandey-dev/gemma-4-e4b-hindi-instruct to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for pankajpandey-dev/gemma-4-e4b-hindi-instruct to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="pankajpandey-dev/gemma-4-e4b-hindi-instruct", max_seq_length=2048, ) - Docker Model Runner
How to use pankajpandey-dev/gemma-4-e4b-hindi-instruct with Docker Model Runner:
docker model run hf.co/pankajpandey-dev/gemma-4-e4b-hindi-instruct
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,21 +1,101 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
- text-generation-inference
|
| 5 |
-
- transformers
|
| 6 |
-
- unsloth
|
| 7 |
-
- gemma4
|
| 8 |
-
license: apache-2.0
|
| 9 |
language:
|
|
|
|
| 10 |
- en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
-
|
| 16 |
-
-
|
| 17 |
-
-
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: gemma
|
| 3 |
+
base_model: unsloth/gemma-4-E4B-it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
language:
|
| 5 |
+
- hi
|
| 6 |
- en
|
| 7 |
+
tags:
|
| 8 |
+
- hindi
|
| 9 |
+
- indic
|
| 10 |
+
- gemma
|
| 11 |
+
- unsloth
|
| 12 |
+
- text-generation
|
| 13 |
+
datasets:
|
| 14 |
+
- ai4bharat/indic-instruct-data-v0.1
|
| 15 |
+
pipeline_tag: text-generation
|
| 16 |
+
library_name: transformers
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# 🇮🇳 Gemma-4-E4B-Hindi-Instruct (16-bit)
|
| 20 |
+
|
| 21 |
+
A Hindi instruction-tuned fine-tune of **Gemma 4 E4B**. This is the merged 16-bit model for use with 🤗 Transformers / vLLM / further fine-tuning.
|
| 22 |
+
|
| 23 |
+
For local CPU/edge use, see the **GGUF** build.
|
| 24 |
+
|
| 25 |
+
> Part of my **Hindi LLM Series** — small, openly-documented Indic models that actually follow instructions in Hindi and run on your own machine.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## Usage (Transformers)
|
| 30 |
+
|
| 31 |
+
```python
|
| 32 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
model_id = "pankajpandey-dev/gemma-4-e4b-hindi-instruct"
|
| 36 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
| 37 |
+
proc = AutoProcessor.from_pretrained(model_id)
|
| 38 |
+
|
| 39 |
+
msgs = [{"role": "user", "content": [{"type": "text", "text": "मशीन लर्निंग को आसान शब्दों में समझाओ।"}]}]
|
| 40 |
+
inputs = proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=True,
|
| 41 |
+
return_dict=True, return_tensors="pt").to(model.device)
|
| 42 |
+
out = model.generate(**inputs, max_new_tokens=256, use_cache=True)
|
| 43 |
+
print(proc.decode(out[0], skip_special_tokens=True))
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## Example outputs
|
| 49 |
+
|
| 50 |
+
**Prompt:** भारत के बारे में एक रोचक तथ्य बताओ।
|
| 51 |
+
> भारत दुनिया में सबसे अधिक भाषाओं वाले देशों में से एक है — 22 आधिकारिक भाषाएँ और 1,000 से अधिक बोलियाँ। हिंदी एक इंडो-आर्यन भाषा है, जबकि तमिल एक द्रविड़ भाषा है।
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## Training details
|
| 56 |
+
|
| 57 |
+
| | |
|
| 58 |
+
|---|---|
|
| 59 |
+
| Base model | `unsloth/gemma-4-E4B-it` |
|
| 60 |
+
| Method | LoRA (r=16, α=16), response-only loss |
|
| 61 |
+
| Framework | [Unsloth](https://github.com/unslothai/unsloth) |
|
| 62 |
+
| Data | ~10k Hindi instruction pairs (AI4Bharat indic-instruct: anudesh + dolly, hi splits) |
|
| 63 |
+
| Epochs | 2 |
|
| 64 |
+
| LR / schedule | 1e-4, cosine |
|
| 65 |
+
| Precision | bf16 (4-bit QLoRA base) |
|
| 66 |
+
| Hardware | Single NVIDIA L4 (24 GB) |
|
| 67 |
+
| Final train loss | ~0.29 |
|
| 68 |
+
|
| 69 |
+
Trained text-only (vision layers frozen), single-BOS chat template to avoid double-BOS corruption.
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## Related repos
|
| 74 |
+
|
| 75 |
+
- GGUF (Q4/Q5/Q8): [`pankajpandey-dev/gemma-4-e4b-hindi-instruct-GGUF`](https://huggingface.co/pankajpandey-dev/gemma-4-e4b-hindi-instruct-GGUF)
|
| 76 |
+
- LoRA adapter: [`pankajpandey-dev/gemma-4-e4b-hindi-instruct-lora`](https://huggingface.co/pankajpandey-dev/gemma-4-e4b-hindi-instruct-lora)
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## Provenance & license (please read)
|
| 81 |
+
|
| 82 |
+
Mixed-license lineage — review all before redistribution or commercial use:
|
| 83 |
+
|
| 84 |
+
- **Weights** derive from **Gemma 4**, under the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
|
| 85 |
+
- **Data** from [AI4Bharat indic-instruct-data-v0.1](https://huggingface.co/datasets/ai4bharat/indic-instruct-data-v0.1):
|
| 86 |
+
- **Dolly** split — from `databricks-dolly-15k`, **CC-BY-SA-3.0**.
|
| 87 |
+
- **Anudesh** split — responses from **Llama-2-70B**, so the **Llama 2 Community License** applies.
|
| 88 |
+
|
| 89 |
+
Raw training data is not redistributed here. You are responsible for complying with the Gemma, Llama 2, and CC-BY-SA terms.
|
| 90 |
+
|
| 91 |
---
|
| 92 |
|
| 93 |
+
## Limitations
|
| 94 |
|
| 95 |
+
- ~8B-class model: strong Hindi fluency, but can hallucinate facts and occasionally repeat phrasing on long open-ended generation.
|
| 96 |
+
- Tuned for single-turn Hindi instructions; long multi-turn chat is not the focus.
|
| 97 |
+
- Not safety-aligned for production.
|
| 98 |
|
| 99 |
+
## Acknowledgements
|
| 100 |
|
| 101 |
+
Base model by Google (Gemma 4). Data by AI4Bharat. Fine-tuning with Unsloth. 🙏
|