cenfis/alpaca-turkish-combined
Viewer • Updated • 82.4k • 251 • 14
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, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("atasoglu/gemma-2-2b-tr")
model = AutoModelForCausalLM.from_pretrained("atasoglu/gemma-2-2b-tr")How to use atasoglu/gemma-2-2b-tr with vLLM:
# 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
}'docker model run hf.co/atasoglu/gemma-2-2b-tr
How to use atasoglu/gemma-2-2b-tr with SGLang:
# 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
}'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
}'How to use atasoglu/gemma-2-2b-tr with Unsloth Studio:
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
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
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for atasoglu/gemma-2-2b-tr to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="atasoglu/gemma-2-2b-tr",
max_seq_length=2048,
)How to use atasoglu/gemma-2-2b-tr with Docker Model Runner:
docker model run hf.co/atasoglu/gemma-2-2b-tr
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("atasoglu/gemma-2-2b-tr")
model = AutoModelForCausalLM.from_pretrained("atasoglu/gemma-2-2b-tr")This gemma2 model was trained 2x faster with Unsloth and Huggingface's TRL library.
from unsloth import FastLanguageModel
import torch
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "atasoglu/gemma-2-2b-tr",
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
alpaca_prompt = """Aşağıda verilen talimat ve giriş ifadelerine uygun bir cevap yaz.
### Talimat:
Aşağıdaki programlama dillerinden hangisi yapay zeka çalışmak için daha uygundur?
Sebebini açıkla.
### GiriÅŸ:
Python, C++, Java, Rust
### Cevap:
"""
inputs = tokenizer(alpaca_prompt, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=128,
do_sample=True,
temperature=0.2,
repetition_penalty=1.15,
top_k=20,
top_p=0.7,
)
generated_tokens = outputs[:, inputs.input_ids.shape[1]:]
response = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
print(response)
# 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.']
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="atasoglu/gemma-2-2b-tr")