metadata
license: llama3
tags:
- moe
- merge
- llama-3
language:
- en
- tr
pipeline_tag: text-generation
library_name: transformers
💻 For English
Megatron_llama3_2x8B is a Mixure of Experts (MoE) (two llama3 models)
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "Eurdem/Megatron_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 who always responds friendly."},
{"role": "user", "content": "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,
eos_token_id = tokenizer.eos_token_id
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
Megatron_llama3_2x8B
💻 Türkçe İçin
!pip install -qU transformers bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "Eurdem/Megatron_llama3_2x8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto", load_in_4bit= True)
messages = [
{"role": "system", "content": "Sen Defne isimli Türkçe konuşan bir chatbotsun."},
{"role": "user", "content": "Sana 2 sorum var. 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,
eos_token_id = tokenizer.eos_token_id
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
Çıktı
Sorunuzun 2. kısmı için, f(x) = 3x^2 + 4x + 12 formülünü ele alalım. f(3)'ün hesabını yapalım:
f(3) = 3(3)^2 + 4(3) + 12
= 3(9) + 12 + 12
= 27 + 24
= 51
Bu nedenle, f(3) 51'dir.```