# pip install -U "mlx-vlm>=0.8.2"
from mlx_vlm import load, stream_generate, apply_chat_template
model, processor = load("Goekdeniz-Guelmez/Omoikane-50M-A27M-Instruct", trust_remote_code=False)
prompt = apply_chat_template(processor, model.config, "Who are you?")
for r in stream_generate(model, processor, prompt, max_tokens=256,
temperature=0.5, top_p=0.9, repetition_penalty=1.15):
print(r.text, end="", flush=True)
# pip install -U "mlx-vlm>=0.8.2"
from mlx_vlm import load, stream_generate
model, processor = load("Goekdeniz-Guelmez/Omoikane-50M-A27M-Base", trust_remote_code=False)
for r in stream_generate(model, processor, "The history of the Roman Empire",
max_tokens=64, temperature=0.8, top_p=0.95):
print(r.text, end="", flush=True)
from transformers import AutoModelForCausalLM, AutoTokenizer, LogitsProcessorList, RepetitionPenaltyLogitsProcessor
repo = "Goekdeniz-Guelmez/Omoikane-50M-A27M-Instruct"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True)
msgs = [{"role": "user", "content": "Who are you?"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True)["input_ids"]
# penalise repeats in the reply only: generate(repetition_penalty=...) would also penalise the JOSIE system prompt
rep = RepetitionPenaltyLogitsProcessor(1.15, prompt_ignore_length=ids.shape[1])
out = model.generate(ids, max_new_tokens=256, do_sample=True, temperature=0.5, top_p=0.9,
logits_processor=LogitsProcessorList([rep]))
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "Goekdeniz-Guelmez/Omoikane-50M-A27M-Base"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True)
ids = tok("The history of the Roman Empire", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=60, do_sample=True, temperature=0.8, top_p=0.95)
print(tok.decode(out[0]))
import sys
from huggingface_hub import snapshot_download
import mlx.core as mx
from tokenizers import Tokenizer
path = snapshot_download("Goekdeniz-Guelmez/Omoikane-50M-A27M-Base")
sys.path.insert(0, path)
from modeling_omoikane_mlx import load_model
model, cfg = load_model(path)
tok = Tokenizer.from_file(f"{path}/tokenizer.json")
logits = model(mx.array([tok.encode("The history of the Roman Empire").ids]))