Text Generation
Transformers
PyTorch
Safetensors
Turkish
phi3
phi
nlp
instruction-tuning
turkish
chat
conversational
custom_code
text-generation-inference
Instructions to use barandinho/phi4-turkish-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use barandinho/phi4-turkish-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="barandinho/phi4-turkish-instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("barandinho/phi4-turkish-instruct", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("barandinho/phi4-turkish-instruct", trust_remote_code=True) 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 Settings
- vLLM
How to use barandinho/phi4-turkish-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "barandinho/phi4-turkish-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "barandinho/phi4-turkish-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/barandinho/phi4-turkish-instruct
- SGLang
How to use barandinho/phi4-turkish-instruct 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 "barandinho/phi4-turkish-instruct" \ --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": "barandinho/phi4-turkish-instruct", "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 "barandinho/phi4-turkish-instruct" \ --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": "barandinho/phi4-turkish-instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use barandinho/phi4-turkish-instruct with Docker Model Runner:
docker model run hf.co/barandinho/phi4-turkish-instruct
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
license_link: https://huggingface.co/microsoft/phi-4/resolve/main/LICENSE
|
| 4 |
+
language:
|
| 5 |
+
- tr
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- phi
|
| 9 |
+
- nlp
|
| 10 |
+
- instruction-tuning
|
| 11 |
+
- turkish
|
| 12 |
+
- chat
|
| 13 |
+
- conversational
|
| 14 |
+
inference:
|
| 15 |
+
parameters:
|
| 16 |
+
temperature: 0.7
|
| 17 |
+
widget:
|
| 18 |
+
- messages:
|
| 19 |
+
- role: user
|
| 20 |
+
content: "Internet'i nasıl açıklayabilirim?"
|
| 21 |
+
library_name: transformers
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# Phi-4 Turkish Instruction-Tuned Model
|
| 25 |
+
|
| 26 |
+
This model is a fine-tuned version of Microsoft's **Phi-4** model for Turkish instruction-following tasks. It was trained on a **55,000-sample Turkish instruction dataset**, making it well-suited for generating helpful and coherent responses in Turkish.
|
| 27 |
+
|
| 28 |
+
## Model Summary
|
| 29 |
+
|
| 30 |
+
| | |
|
| 31 |
+
|-------------------------|-----------------------------------------------|
|
| 32 |
+
| **Developers** | Baran Bingöl (Hugging Face: [barandinho](https://huggingface.co/barandinho)) |
|
| 33 |
+
| **Base Model** | [microsoft/phi-4](https://huggingface.co/microsoft/phi-4) |
|
| 34 |
+
| **Architecture** | 14B parameters, dense decoder-only Transformer|
|
| 35 |
+
| **Training Data** | 55K Turkish instruction samples |
|
| 36 |
+
| **Context Length** | 16K tokens |
|
| 37 |
+
| **License** | MIT ([License Link](https://huggingface.co/microsoft/phi-4/resolve/main/LICENSE)) |
|
| 38 |
+
|
| 39 |
+
## Intended Use
|
| 40 |
+
|
| 41 |
+
### Primary Use Cases
|
| 42 |
+
- Turkish conversational AI systems
|
| 43 |
+
- Chatbots and virtual assistants
|
| 44 |
+
- Educational tools for Turkish users
|
| 45 |
+
- General-purpose text generation in Turkish
|
| 46 |
+
|
| 47 |
+
### Out-of-Scope Use Cases
|
| 48 |
+
- High-risk domains (medical, legal, financial advice) without proper evaluation
|
| 49 |
+
- Use in sensitive or safety-critical systems without safeguards
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
|
| 53 |
+
### Input Formats
|
| 54 |
+
|
| 55 |
+
Given the nature of the training data, `phi-4` is best suited for prompts using the chat format as follows:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
<|im_start|>system<|im_sep|>
|
| 59 |
+
Sen yardımsever bir yapay zekasın.<|im_end|>
|
| 60 |
+
<|im_start|>user<|im_sep|>
|
| 61 |
+
Kuantum hesaplama neden önemlidir?<|im_end|>
|
| 62 |
+
<|im_start|>assistant<|im_sep|>
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### With `transformers`
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
import transformers
|
| 69 |
+
|
| 70 |
+
pipeline = transformers.pipeline(
|
| 71 |
+
"text-generation",
|
| 72 |
+
model="barandinho/phi4-turkish-instruct",
|
| 73 |
+
model_kwargs={"torch_dtype": "auto"},
|
| 74 |
+
device_map="auto",
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
messages = [
|
| 78 |
+
{"role": "system", "content": "Sen yardımsever bir yapay zekasın."},
|
| 79 |
+
{"role": "user", "content": "Kuantum hesaplama neden önemlidir?"},
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
outputs = pipeline(messages, max_new_tokens=128)
|
| 83 |
+
print(outputs[0]["generated_text"][-1])
|
| 84 |
+
```
|