Instructions to use ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1") model = AutoModelForCausalLM.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1") 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 ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1
- SGLang
How to use ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1 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 "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1" \ --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": "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1", "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 "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1" \ --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": "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1 with Docker Model Runner:
docker model run hf.co/ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1
Use Docker
docker model run hf.co/ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1
turkish-gpt2-medium-350m-instruct-v0.1
Derived from ytu-ce-cosmos/turkish-gpt2-medium, this model is a Turkish Language Model (LLM) finetuned with a dataset consisting of 35K instructions. Due to the diverse nature of the training data, which includes websites, books, and other text sources, this model can exhibit biases and generate wrong answers. Users should be aware of these biases and use the model responsibly.
Quickstart
import torch
from transformers import AutoTokenizer, GPT2LMHeadModel
from transformers import pipeline
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device_id = 0 if torch.cuda.is_available() else -1
model = GPT2LMHeadModel.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1").to(device)
tokenizer = AutoTokenizer.from_pretrained("ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1")
text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer, device=device_id, max_new_tokens=256)
def get_model_response(instruction):
instruction_prompt = f"### Kullanıcı:\n{instruction}\n### Asistan:\n"
result = text_generator(instruction_prompt)
generated_response = result[0]['generated_text']
return generated_response[len(instruction_prompt):]
model_response = get_model_response("Evde egzersiz yapmanın avantajlarını açıkla.")
print(model_response)
"""
Evde egzersiz yapmak, gelişmiş fiziksel ve zihinsel sağlık için harika bir yoldur. Düzenli egzersizin, artan enerji seviyeleri, gelişmiş kas gücü ve esnekliği, gelişmiş uyku kalitesi ve daha iyi genel esenlik dahil olmak üzere birçok faydası vardır. Evde egzersiz yapmak ayrıca stresi azaltmaya, kas gücünü artırmaya ve genel sağlığı iyileştirmeye yardımcı olabilir.
"""
To use the chat template:
chat_generator = pipeline("conversational", model=model, tokenizer=tokenizer, device=device_id, max_new_tokens=256)
messages = [
{"role": "user", "content": "Evde egzersiz yapmanın avantajlarını açıkla."}
]
chat_outputs = chat_generator(messages)
print(chat_outputs)
"""
Conversation id: 236ffc4a-2a36-4191-92fb-90d6753df1ae
user: Evde egzersiz yapmanın avantajlarını açıkla.
assistant: Evde egzersiz yapmak, gelişmiş fiziksel ve zihinsel sağlık için sayısız avantaj sunar. Düzenli egzersiz, stresi azaltmaya, kas gücünü artırmaya ve genel sağlığı iyileştirmeye yardımcı olabilir. Ayrıca, evde egzersiz yapmak, daha iyi uyku kalitesi, artan enerji seviyeleri ve gelişmiş bilişsel işlevler gibi daha iyi fiziksel ve zihinsel sağlık sonuçları sağlayabilir. Evde egzersiz yapmak ayrıca, gelişmiş esneklik, denge ve koordinasyon, gelişmiş kalp sağlığı ve gelişmiş kemik sağlığı dahil olmak üzere gelişmiş fiziksel ve zihinsel sağlık yararları sağlayabilir.
"""
Training Details
We've meticulously fine-tuned this model with a 35,000-instruction Turkish dataset to enhance its precision and adaptability.
By employing LoRA (Low-Rank Adaptation), we have successfully propelled this model to the pinnacle of its performance capabilities.
LoRA Config:
- rank = 256
- lora_alpha = 512
- lora_dropout = 0.05
- bias="none"
- task_type="CAUSAL_LM"
In addition to monitoring loss, we successfully integrated Rouge calculations into our system's evaluation metrics.
One of the innovative techniques we adopted involved employing a model to cleanse our data.
Other relevant information can be found in the paper.
Model Description
- Developed by: ytu-ce-cosmos
- Finetuned from model :
ytu-ce-cosmos/turkish-gpt2-medium
Acknowledgments
- Thanks to the generous support from the Hugging Face team, it is possible to download models from their S3 storage 🤗
- Research supported with Cloud TPUs from Google's TPU Research Cloud (TRC)
Citation
@article{kesgin2024introducing,
title={Introducing cosmosGPT: Monolingual Training for Turkish Language Models},
author={Kesgin, H Toprak and Yuce, M Kaan and Dogan, Eren and Uzun, M Egemen and Uz, Atahan and Seyrek, H Emre and Zeer, Ahmed and Amasyali, M Fatih},
journal={arXiv preprint arXiv:2404.17336},
year={2024}
}
Framework versions
- PEFT 0.9.0
Contact
COSMOS AI Research Group, Yildiz Technical University Computer Engineering Department
https://cosmos.yildiz.edu.tr/
cosmos@yildiz.edu.tr
- Downloads last month
- 130
Model tree for ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1
Base model
ytu-ce-cosmos/turkish-gpt2-medium
Install from pip and serve model
# Install vLLM from pip: pip install vllm# Start the vLLM server: vllm serve "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1"# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ytu-ce-cosmos/turkish-gpt2-medium-350m-instruct-v0.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'