AlicanKiraz0/Turkish-Finance-SFT-Dataset
Viewer • Updated • 2.4k • 242 • 58
How to use Dbmaxwell/Turkish-Finance-SFT-QLoRA with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("ytu-ce-cosmos/Turkish-Gemma-9b-T1")
model = PeftModel.from_pretrained(base_model, "Dbmaxwell/Turkish-Finance-SFT-QLoRA")How to use Dbmaxwell/Turkish-Finance-SFT-QLoRA with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Dbmaxwell/Turkish-Finance-SFT-QLoRA")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Dbmaxwell/Turkish-Finance-SFT-QLoRA", dtype="auto")How to use Dbmaxwell/Turkish-Finance-SFT-QLoRA with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Dbmaxwell/Turkish-Finance-SFT-QLoRA"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Dbmaxwell/Turkish-Finance-SFT-QLoRA",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Dbmaxwell/Turkish-Finance-SFT-QLoRA
How to use Dbmaxwell/Turkish-Finance-SFT-QLoRA with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Dbmaxwell/Turkish-Finance-SFT-QLoRA" \
--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": "Dbmaxwell/Turkish-Finance-SFT-QLoRA",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Dbmaxwell/Turkish-Finance-SFT-QLoRA" \
--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": "Dbmaxwell/Turkish-Finance-SFT-QLoRA",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Dbmaxwell/Turkish-Finance-SFT-QLoRA with Docker Model Runner:
docker model run hf.co/Dbmaxwell/Turkish-Finance-SFT-QLoRA
import os
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
import os, torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
BASE_MODEL = "ytu-ce-cosmos/Turkish-Gemma-9b-T1"
ADAPTER = "Dbmaxwell/Turkish-Finance-SFT-QLoRA"
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
tok = AutoTokenizer.from_pretrained(BASE_MODEL, token=token, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(
BASE_MODEL,
token=token,
trust_remote_code=True,
quantization_config=bnb,
device_map="auto",
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
)
model = PeftModel.from_pretrained(
base, ADAPTER,
device_map="auto",
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
)
model.eval()
q = """Bir hisse senedinde uzun süredir devam eden yatay konsolidasyon bölgesi yukarı yönlü hacimli bir kırılımla aşıldıktan sonra, fiyatın tekrar bu banda doğru sarkmasına rağmen volatilitenin belirgin biçimde düşmesi, trendin devamı açısından nasıl yorumlanmalıdır?"""
prompt = f"<bos><start_of_turn>user\n{q}<end_of_turn>\n<start_of_turn>model\n"
inp = tok(prompt, return_tensors="pt").to(next(model.parameters()).device)
with torch.inference_mode():
out = model.generate(
**inp,
max_new_tokens=4096,
do_sample=False
)
print(tok.decode(out[0][inp["input_ids"].shape[1]:], skip_special_tokens=True)) #output in files/ex1.md
Base model
ytu-ce-cosmos/Turkish-Gemma-9b-T1