Views
No views yet


1from llama_cpp import Llama
2from ctransformers import AutoModelForCausalLM
3
4# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
5llm_p = AutoModelForCausalLM.from_pretrained("umarigan/Trendyol-LLM-7b-chat-v0.1-GGUF",
6 model_file="trendyol-llm-7b-chat-v0.1.Q4_K_M.gguf",
7 model_type="llama",
8 gpu_layers=0)
9
10# Chat Completion API
11llm = Llama(model_path=llm_p.model_path,
12 chat_format="llama-2") # Set chat_format according to the model you are using
13llm.create_chat_completion(
14 messages = [
15 {"role": "system", "content": "çocuk hikayeleri yazan bir yazarsın"},
16 {
17 "role": "user",
18 "content": "köpekler hakkında bir çocuk hikayesi yaz"
19 }
20 ]
21){'id': 'chatcmpl-0d665fb2-a92a-408c-bc03-78c32bccab0d',
'object': 'chat.completion',
'created': 1707822047,
'model': '/root/.cache/huggingface/hub/models--umarigan--Trendyol-LLM-7b-chat-v0.1-GGUF/blobs/323878a8570093178040e78b438d5670c0fdae2aa614a8ed58e784d697d4db52',
'choices': [{'index': 0,
'message': {'role': 'assistant',
'content': ' Bir zamanlar, ormanda yaşayan cesur ve sadık bir köpek varmış. O, her zaman arkadaşlarına yardım etmeye hazırdı ve asla korkmuyordu. Bir gün, ormanın derinliklerinde gizemli bir ses duydu ve araştırmaya karar verdi. Yol boyunca birçok yaratıkla karşılaştı ama hiçbirinin kimliğini bilmiyordu. Sonunda, gizemli sesin geldiği yere ulaştı ve sonunda onu buldu.'},
'finish_reason': 'stop'}],
'usage': {'prompt_tokens': 39, 'completion_tokens': 85, 'total_tokens': 124}}