Text Generation
Transformers
Safetensors
English
Turkish
gemma2
text-generation-inference
unsloth
trl
Instructions to use atasoglu/gemma-2-2b-tr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use atasoglu/gemma-2-2b-tr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="atasoglu/gemma-2-2b-tr")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("atasoglu/gemma-2-2b-tr") model = AutoModelForMultimodalLM.from_pretrained("atasoglu/gemma-2-2b-tr") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use atasoglu/gemma-2-2b-tr with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "atasoglu/gemma-2-2b-tr" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "atasoglu/gemma-2-2b-tr", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/atasoglu/gemma-2-2b-tr
- SGLang
How to use atasoglu/gemma-2-2b-tr 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 "atasoglu/gemma-2-2b-tr" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "atasoglu/gemma-2-2b-tr", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "atasoglu/gemma-2-2b-tr" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "atasoglu/gemma-2-2b-tr", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Studio
How to use atasoglu/gemma-2-2b-tr 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 atasoglu/gemma-2-2b-tr 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 atasoglu/gemma-2-2b-tr to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for atasoglu/gemma-2-2b-tr to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="atasoglu/gemma-2-2b-tr", max_seq_length=2048, ) - Docker Model Runner
How to use atasoglu/gemma-2-2b-tr with Docker Model Runner:
docker model run hf.co/atasoglu/gemma-2-2b-tr
Update README.md
Browse files
README.md
CHANGED
|
@@ -20,3 +20,49 @@ tags:
|
|
| 20 |
This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 21 |
|
| 22 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 21 |
|
| 22 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
| 23 |
+
|
| 24 |
+
# Usage
|
| 25 |
+
|
| 26 |
+
```py
|
| 27 |
+
from unsloth import FastLanguageModel
|
| 28 |
+
import torch
|
| 29 |
+
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
|
| 30 |
+
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
|
| 31 |
+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
|
| 32 |
+
|
| 33 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 34 |
+
model_name = "atasoglu/gemma-2-2b-tr",
|
| 35 |
+
max_seq_length = max_seq_length,
|
| 36 |
+
dtype = dtype,
|
| 37 |
+
load_in_4bit = load_in_4bit,
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
| 41 |
+
|
| 42 |
+
alpaca_prompt = """Aşağıda verilen talimat ve giriş ifadelerine uygun bir cevap yaz.
|
| 43 |
+
|
| 44 |
+
### Talimat:
|
| 45 |
+
Aşağıdaki programlama dillerinden hangisi yapay zeka çalışmak için daha uygundur?
|
| 46 |
+
Sebebini açıkla.
|
| 47 |
+
|
| 48 |
+
### Giriş:
|
| 49 |
+
Python, C++, Java, Rust
|
| 50 |
+
|
| 51 |
+
### Cevap:
|
| 52 |
+
"""
|
| 53 |
+
inputs = tokenizer(alpaca_prompt, return_tensors="pt").to("cuda")
|
| 54 |
+
outputs = model.generate(
|
| 55 |
+
**inputs,
|
| 56 |
+
max_new_tokens=128,
|
| 57 |
+
do_sample=True,
|
| 58 |
+
temperature=0.2,
|
| 59 |
+
repetition_penalty=1.15,
|
| 60 |
+
top_k=20,
|
| 61 |
+
top_p=0.7,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
generated_tokens = outputs[:, inputs.input_ids.shape[1]:]
|
| 65 |
+
response = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
|
| 66 |
+
print(response)
|
| 67 |
+
# Output: ['C++ veya Python en iyi seçenektir çünkü bu iki dilde çok sayıda yapay zeka araçları vardır. Bu araçlar, veri analizi, öğrenme algoritmaları ve karar verme süreçlerini kolaylaştırır. Ayrıca, her ikisinin de güçlü bir kütüphanesi olması da önemlidir.']
|
| 68 |
+
```
|