Text Generation
Transformers
Safetensors
gemma3_text
unsloth
trl
grpo
conversational
text-generation-inference
Instructions to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="erythropygia/Gemma-3-1b-it-OpenR1-Turkish") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("erythropygia/Gemma-3-1b-it-OpenR1-Turkish") model = AutoModelForCausalLM.from_pretrained("erythropygia/Gemma-3-1b-it-OpenR1-Turkish") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "erythropygia/Gemma-3-1b-it-OpenR1-Turkish" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "erythropygia/Gemma-3-1b-it-OpenR1-Turkish", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/erythropygia/Gemma-3-1b-it-OpenR1-Turkish
- SGLang
How to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish 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 "erythropygia/Gemma-3-1b-it-OpenR1-Turkish" \ --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": "erythropygia/Gemma-3-1b-it-OpenR1-Turkish", "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 "erythropygia/Gemma-3-1b-it-OpenR1-Turkish" \ --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": "erythropygia/Gemma-3-1b-it-OpenR1-Turkish", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish 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 erythropygia/Gemma-3-1b-it-OpenR1-Turkish 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 erythropygia/Gemma-3-1b-it-OpenR1-Turkish to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for erythropygia/Gemma-3-1b-it-OpenR1-Turkish to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="erythropygia/Gemma-3-1b-it-OpenR1-Turkish", max_seq_length=2048, ) - Docker Model Runner
How to use erythropygia/Gemma-3-1b-it-OpenR1-Turkish with Docker Model Runner:
docker model run hf.co/erythropygia/Gemma-3-1b-it-OpenR1-Turkish
Gemma-3-1b-it-OpenR1-Turkish
Model Description
erythropygia/Gemma-3-1b-it-OpenR1-Turkish is a 1B-parameter Turkish instruction-tuned language model, fine-tuned using GRPO (Group Relative Policy Optimization) techniques for better efficiency and response quality.
Model Details
- Base Model: google/gemma-3-1b-it
- Fine-tuned with GRPO and LoRa (Low-Rank Adaptation)
- max_seq_lenght: 2048 tokens
- max_prompt_lenght: 1024 tokens
- Fine-tuning on an L4 GPU for 11 more hours
Usage
Install Dependencies
%%capture
import os
if "COLAB_" not in "".join(os.environ.keys()):
!pip install unsloth vllm
else:
# [NOTE] Do the below ONLY in Colab! Use [[pip install unsloth vllm]]
!pip install --no-deps unsloth vllm
# Install latest Hugging Face for Gemma-3!
!pip install --no-deps git+https://github.com/huggingface/transformers@v4.49.0-Gemma-3
#@title Colab Extra Install { display-mode: "form" }
%%capture
import os
if "COLAB_" not in "".join(os.environ.keys()):
!pip install unsloth vllm
else:
!pip install --no-deps unsloth vllm
# [NOTE] Do the below ONLY in Colab! Use [[pip install unsloth vllm]]
# Skip restarting message in Colab
import sys, re, requests; modules = list(sys.modules.keys())
for x in modules: sys.modules.pop(x) if "PIL" in x or "google" in x else None
!pip install --no-deps bitsandbytes accelerate xformers==0.0.29.post3 peft trl triton cut_cross_entropy unsloth_zoo
!pip install sentencepiece protobuf datasets huggingface_hub hf_transfer
# vLLM requirements - vLLM breaks Colab due to reinstalling numpy
f = requests.get("https://raw.githubusercontent.com/vllm-project/vllm/refs/heads/main/requirements/common.txt").content
with open("vllm_requirements.txt", "wb") as file:
file.write(re.sub(rb"(transformers|numpy|xformers)[^\n]{1,}\n", b"", f))
!pip install -r vllm_requirements.txt
from unsloth import FastModel
import torch
max_seq_length = 2096
model, tokenizer = FastModel.from_pretrained(
model_name = "erythropygia/Gemma-3-1b-it-OpenR1-Turkish",
max_seq_length = max_seq_length,
load_in_4bit = False, # 4 bit quantization to reduce memory
load_in_8bit = False, # A bit more accurate, uses 2x memory
token = "YOUR_HF_TOKEN",
)
# Load and prep dataset
SYSTEM_PROMPT = f"""
Aşağıdaki formatta cevap ver
<think></think> etiketleri arasıda problemi nasıl çözeceğin hakkında düşün ve adım adım çözümünü planla.
Ardından, çözümünü <answer></answer> arasına yerleştir. Yanıt, <answer></answer> kısmının içinde belirtilen mantıklı adımlara dayanmalı
Format aşağıdaki gibi olmalıdır:
<think>
...
</think>
<answer>
...
</answer>
"""
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "python'da stok yönetimi için örnek bir class yazar mısın?"},
]
text = tokenizer.apply_chat_template(
messages,
add_generation_prompt = True, # Must add for generation
tokenize = False,
)
from transformers import TextStreamer
_ = model.generate(
**tokenizer(text, return_tensors = "pt").to("cuda"),
max_new_tokens = 1024, # Increase for longer outputs!
# Recommended Gemma-3 settings!
temperature = 1, top_p = 0.95, top_k = 128,
streamer = TextStreamer(tokenizer, skip_prompt = True),
)
Response:
<think>
Stok yönetimi için bir Python sınıfı yazmak, stoklarınızı yönetmek için gerekli olan temel işlevleri kapsayacak şekilde tasarlanmalıdır.
Bu sınıf, stokların eklenmesini, silmesini, fiyatlarını güncellemesini ve stok seviyelerini hesaplamasını içermelidir.
Ayrıca, stok seviyelerinin stok seviyeleriyle karşılaştırılmasını ve stok seviyelerinin yüksek olduğunda stokları satmasını veya almasını sağlamalıdır.
Ayrıca, stok seviyelerinin düşük olduğunda stokları almasını sağlamalıdır.
</think>
<answer>
class Stok:
def __init__(self, stok_id, stok_adı, başlangic_miktar, fiyat, stok_seviyesi):
self.stok_id = stok_id
self.stok_adi = stok_adı
self.baslangic_miktar = başlangic_miktar
self.fiyat = fiyat
self.stok_seviyesi = stok_seviyesi
def ekle(self, miktar):
if miktar > self.baslangic_miktar:
self.baslangic_miktar += miktar
return True
else:
return False
def sil(self, stok_id):
if stok_id in self.stok_seviyeleri:
del self.stok_seviyeleri[stok_id]
else:
print("Stok ID'si bulunamadı.")
return False
def güncelle_fiyat(self, yeni_fiyat):
self.fiyat = yeni_fiyat
return True
def hesapla_stok_seviyesi(self):
if self.stok_seviyesi == 0:
return 1
else:
return self.stok_seviyesi
def print_stok_bilgileri(self):
print(f"Stok ID: {self.stok_id}, Stok Adı: {self.stok_adi}, Başlangıç Miktarı: {self.baslangic_miktar}, Fiyat: {self.fiyat}, Stok Seviyesi: {self.stok_seviyesi}")
# Örnek Kullanım
stok1 = Stok(1, "Meyve", 100, 10.0, 5)
stok2 = Stok(2, "Elma", 20, 5.0, 2)
print("Önceki Stok Bilgileri:")
stok1.print_stok_bilgileri()
stok2.print_stok_bilgileri()
stok1.ekle(10)
stok1.ekle(5)
stok1.ekle(15)
stok1.print_stok_bilgileri()
stok1.sil(1)
print("\nStok ID 1 silindi.")
stok1.print_stok_bilgileri()
stok1.güncelle_fiyat(8.0)
stok1.print_stok_bilgileri()
</answer>
- Downloads last month
- 4