Edit model card
Phi-3 Logo

MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2

This model is a fine-tune (DPO) of microsoft/Phi-3-mini-4k-instruct model.

⚑ Quantized GGUF

All GGUF models are available here: MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2-GGUF

πŸ† Open LLM Leaderboard Evaluation Results

Detailed results can be found here

Metric Value
Avg. 69.78
AI2 Reasoning Challenge (25-Shot) 62.80
HellaSwag (10-Shot) 80.76
MMLU (5-Shot) 69.10
TruthfulQA (0-shot) 59.97
Winogrande (5-shot) 72.45
GSM8k (5-shot) 73.62

Prompt Template

This model uses ChatML prompt template:

<|im_start|>system
{System}
<|im_end|>
<|im_start|>user
{User}
<|im_end|>
<|im_start|>assistant
{Assistant}

How to use

You can use this model by using MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2 as the model name in Hugging Face's transformers library.

from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
from transformers import pipeline
import torch

model_id = "MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2"

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
    # attn_implementation="flash_attention_2"
)

tokenizer = AutoTokenizer.from_pretrained(
    model_id,
    trust_remote_code=True
)

streamer = TextStreamer(tokenizer)

messages = [
    {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
    {"role": "user", "content": "Who are you?"},
]

# this should work perfectly for the model to stop generating
terminators = [
    tokenizer.eos_token_id, # this should be <|im_end|>
    tokenizer.convert_tokens_to_ids("<|assistant|>"), # sometimes model stops generating at <|assistant|>
    tokenizer.convert_tokens_to_ids("<|end|>") # sometimes model stops generating at <|end|>
]

pipe = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
)

generation_args = {
    "max_new_tokens": 500,
    "return_full_text": False,
    "temperature": 0.0,
    "do_sample": False,
    "streamer": streamer,
    "eos_token_id": terminators,
}

output = pipe(messages, **generation_args)
print(output[0]['generated_text'])

Downloads last month
357
Safetensors
Model size
3.82B params
Tensor type
BF16
Β·
Inference API
Input a message to start chatting with MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2.
Inference API (serverless) has been turned off for this model.

Finetuned from

Collections including MaziyarPanahi/Phi-3-mini-4k-instruct-v0.2

Evaluation results