File size: 1,719 Bytes
7414022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
820b277
7414022
820b277
 
 
 
7414022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
820b277
 
7414022
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
datasets:
- TFLai/Turkish-Alpaca
language:
- tr
---

# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->
malhajar/phi-2-chat-turkish is a finetuned version of phi-2 using SFT Training.
This model can answer information in turkish language as it is finetuned on a turkish dataset specifically [`Turkish-Alpaca`]( https://huggingface.co/datasets/TFLai/Turkish-Alpaca) 

### Model Description

- **Developed by:** [`Mohamad Alhajar`](https://www.linkedin.com/in/muhammet-alhajar/) 
- **Language(s) (NLP):** Turkish
- **Finetuned from model:** [`microsoft/phi-2`](https://huggingface.co/microsoft/phi-2)

### Prompt Template
```
### Instruction:

<prompt> (without the <>)

### Response:
```
## How to Get Started with the Model

Use the code sample provided in the original post to interact with the model.
```python
from transformers import AutoTokenizer,AutoModelForCausalLM
 
model_id = "malhajar/phi-2-chat-turkish"
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
                                             device_map="auto",
                                             torch_dtype=torch.float16,
                                             revision="main")

tokenizer = AutoTokenizer.from_pretrained(model_id)

question: "Türkiyenin en büyük şehir nedir?"
# For generating a response
prompt = f'''
### Instruction:  {question} ### Response:
'''
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
output = model.generate(inputs=input_ids,max_new_tokens=512,pad_token_id=tokenizer.eos_token_id,top_k=50, do_sample=True,repetition_penalty=1.3
        top_p=0.95,trust_remote_code=True,)
response = tokenizer.decode(output[0])

print(response)
```