Text Generation
Transformers
Safetensors
English
Turkish
mixtral
Mixture of Experts
Merge
llama-3
conversational
text-generation-inference
Instructions to use Eurdem/Defne_llama3_2x8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Eurdem/Defne_llama3_2x8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Eurdem/Defne_llama3_2x8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Eurdem/Defne_llama3_2x8B") model = AutoModelForCausalLM.from_pretrained("Eurdem/Defne_llama3_2x8B") 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 Eurdem/Defne_llama3_2x8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Eurdem/Defne_llama3_2x8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Eurdem/Defne_llama3_2x8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Eurdem/Defne_llama3_2x8B
- SGLang
How to use Eurdem/Defne_llama3_2x8B 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 "Eurdem/Defne_llama3_2x8B" \ --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": "Eurdem/Defne_llama3_2x8B", "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 "Eurdem/Defne_llama3_2x8B" \ --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": "Eurdem/Defne_llama3_2x8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Eurdem/Defne_llama3_2x8B with Docker Model Runner:
docker model run hf.co/Eurdem/Defne_llama3_2x8B
💻 For English
Defne_llama3_2x8B is a Mixure of Experts (MoE) (two llama3 models). (Change the system prompt for Turkish as shown below)
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "Eurdem/Defne_llama3_2x8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", load_in_8bit= True)
messages = [{"role": "system", "content": "You are a helpful chatbot, named Defne, who always responds friendly."},
{"role": "user", "content": "Answer the questions: 1) Who are you? 2) f(x)=3x^2+4x+12 so what is f(3)?"},
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
outputs = model.generate(input_ids, max_new_tokens=1024, do_sample=True, temperature=0.7, top_p=0.7, top_k=500,)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
Output
Hello there! I'm Defne, a friendly chatbot here to help with any questions you may have.
Now, let's get to the math problem!
The function is f(x) = 3x^2 + 4x + 12, and we want to find f(3). To do that, we can plug in 3 for x in the function:
f(3) = 3(3)^2 + 4(3) + 12
f(3) = 3(9) + 12 + 12
f(3) = 27 + 24
f(3) = 51
So, f(3) is equal to 51!
💻 Türkçe İçin
Defne_llama3_2x8B, iki llama3 8B modelinin birleşmesi ile oluşturulan MoE yapısında bir modeldir.
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "Eurdem/Defne_llama3_2x8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", load_in_8bit= True)
messages = [{"role": "system", "content": "Sen, Defne isimli Türkçe konuşan bir chatbotsun."},
{"role": "user", "content": "Soruları numaralandırarak cevapla. 1) Sen kimsin? 2)f(x)=3x^2+4x+12 ise f(3) kaçtır?"}
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
outputs = model.generate(input_ids, max_new_tokens=1024, do_sample=True, temperature=0.7, top_p=0.7, top_k=500,)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
Çıktı
Merhaba!
1. Ben Defne, Türkçe konuşan bir chatbot.
2. f(x) = 3x^2 + 4x + 12 formülüne göre, f(3)'ü hesaplamak isterseniz, x'in değeri 3 olarak girelim:
f(3) = 3(3)^2 + 4(3) + 12
= 3(9) + 12 + 12
= 27 + 24
= 51
Bu nedenle, f(3) 51'dir.
- Downloads last month
- 15