Instructions to use Devnexai/gemma4-code-assistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Devnexai/gemma4-code-assistant with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B") model = PeftModel.from_pretrained(base_model, "Devnexai/gemma4-code-assistant") - Transformers
How to use Devnexai/gemma4-code-assistant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Devnexai/gemma4-code-assistant") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Devnexai/gemma4-code-assistant", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Devnexai/gemma4-code-assistant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Devnexai/gemma4-code-assistant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Devnexai/gemma4-code-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Devnexai/gemma4-code-assistant
- SGLang
How to use Devnexai/gemma4-code-assistant 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 "Devnexai/gemma4-code-assistant" \ --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": "Devnexai/gemma4-code-assistant", "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 "Devnexai/gemma4-code-assistant" \ --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": "Devnexai/gemma4-code-assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Devnexai/gemma4-code-assistant with Docker Model Runner:
docker model run hf.co/Devnexai/gemma4-code-assistant
commit con Fix model card: license field, PEFT quick start
Browse files
README.md
CHANGED
|
@@ -8,33 +8,39 @@ tags:
|
|
| 8 |
- sft
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
-
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
---
|
| 14 |
|
| 15 |
# Model Card for gemma4-code-assistant
|
| 16 |
|
| 17 |
-
This model is a fine-tuned version of [google/gemma-4-E2B](https://huggingface.co/google/gemma-4-E2B).
|
| 18 |
-
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 19 |
|
| 20 |
## Quick start
|
| 21 |
|
| 22 |
-
|
| 23 |
-
from transformers import pipeline
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
## Training procedure
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
This model was trained with SFT.
|
| 38 |
|
| 39 |
### Framework versions
|
| 40 |
|
|
@@ -47,10 +53,6 @@ This model was trained with SFT.
|
|
| 47 |
|
| 48 |
## Citations
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
Cite TRL as:
|
| 53 |
-
|
| 54 |
```bibtex
|
| 55 |
@software{vonwerra2020trl,
|
| 56 |
title = {{TRL: Transformers Reinforcement Learning}},
|
|
@@ -59,4 +61,5 @@ Cite TRL as:
|
|
| 59 |
url = {https://github.com/huggingface/trl},
|
| 60 |
year = {2020}
|
| 61 |
}
|
|
|
|
| 62 |
```
|
|
|
|
| 8 |
- sft
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
+
license: gemma
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
---
|
| 14 |
|
| 15 |
# Model Card for gemma4-code-assistant
|
| 16 |
|
| 17 |
+
This model is a fine-tuned version of [google/gemma-4-E2B](https://huggingface.co/google/gemma-4-E2B), specialized for code assistance tasks. It was trained with supervised fine-tuning (SFT) using [TRL](https://github.com/huggingface/trl) and published by [DevNexAI](https://huggingface.co/Devnexai).
|
|
|
|
| 18 |
|
| 19 |
## Quick start
|
| 20 |
|
| 21 |
+
This is a LoRA adapter — load the base model first and apply the adapter on top:
|
|
|
|
| 22 |
|
| 23 |
+
```python
|
| 24 |
+
from peft import PeftModel
|
| 25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 26 |
+
|
| 27 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 28 |
+
"google/gemma-4-E2B", device_map="auto"
|
| 29 |
+
)
|
| 30 |
+
model = PeftModel.from_pretrained(base, "Devnexai/gemma4-code-assistant")
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("Devnexai/gemma4-code-assistant")
|
| 32 |
+
|
| 33 |
+
messages = [{"role": "user", "content": "Write a Python function to check if a string is a palindrome."}]
|
| 34 |
+
inputs = tokenizer.apply_chat_template(
|
| 35 |
+
messages, add_generation_prompt=True, return_tensors="pt"
|
| 36 |
+
).to(model.device)
|
| 37 |
+
output = model.generate(inputs, max_new_tokens=256)
|
| 38 |
+
print(tokenizer.decode(output[0][inputs.shape[-1]:], skip_special_tokens=True))
|
| 39 |
```
|
| 40 |
|
| 41 |
## Training procedure
|
| 42 |
|
| 43 |
+
This model was trained with SFT (LoRA/PEFT).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
### Framework versions
|
| 46 |
|
|
|
|
| 53 |
|
| 54 |
## Citations
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
```bibtex
|
| 57 |
@software{vonwerra2020trl,
|
| 58 |
title = {{TRL: Transformers Reinforcement Learning}},
|
|
|
|
| 61 |
url = {https://github.com/huggingface/trl},
|
| 62 |
year = {2020}
|
| 63 |
}
|
| 64 |
+
```
|
| 65 |
```
|