daekeun-ml's picture
Update README.md
824c899 verified
|
raw
history blame
3.19 kB
metadata
library_name: transformers
license: apache-2.0
datasets:
  - Intel/orca_dpo_pairs
  - wikipedia
  - Open-Orca/OpenOrca
language:
  - en

phi-2-upscaled-4B-instruct-v0.1

Model Details

This model is a model that performed continued pre-training and fine-tuning (instruction tuning) using the depth up-scaling (DUS) technique disclosed by Upstage.

DUS(Depth Up-Scaling) and continued pre-training

Similar to the methodology disclosed in the paper, we expanded from 32 transformer blocks to 48 blocks and then continued pre-training with the public dataset. Pre-training was performed for 3 days using 4 ml.g5.48xlarge instances from AWS (NVIDIA A10G GPU x 32ea). For pre-training, we used a sample set from Wikipedia.

Fine-tuning

After performing pre-training, instruction tuning and alignment tuning were performed sequentially. This process only took about 10 hours using AWS ml.g5.24xlarge (NVIDIA A10G GPU x 4ea). The dataset used for instruction tuning is a sample set of the OpenOrca dataset, and the dataset used for alignment tuning is Intel's orca_dpo_pairs dataset.

References

How to Get Started with the Model

Since this model used ChatGPT's ChatML template, and tokens were added. You can use Hugging Face's chat template to create the prompt, but you can also create the prompt yourself with the code snippet below.

def create_inference_prompt(text):
     string = f"""<|im_start|>system
You are a helpful AI assistant.<|im_end|>
<|im_start|>user
{text}<|im_end|>
<|im_start|>assistant
"""
     return string

If you want to simply see the inference results, please use the code snippet below.

from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
import torch
torch.set_default_device("cuda")
model_path = "daekeun-ml/phi-2-upscaled-4B-instruct-v0.1"

model = AutoModelForCausalLM.from_pretrained(
    model_path,
    torch_dtype="auto",
    trust_remote_code=True)

tokenizer = AutoTokenizer.from_pretrained(
    model_path, 
    use_fast=True, 
    trust_remote_code=True
)

# Format prompt
message = [
    {"role": "system", "content": "You are a helpful AI assistant. Generate appropriate answers to given questions."},
    {"role": "user", "content": "What is a Large Language Model?"}
]

prompt = tokenizer.apply_chat_template(message, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False)

outputs = model.generate(**inputs, max_new_tokens=200, do_sample=True, top_p=0.9, temperature=0.5, repetition_penalty=1.2)
text = tokenizer.batch_decode(outputs)[0]
print(text)

Notes

License

Apache 2.0; The license of phi-2 is MIT, but the license of the orca dataset used for training is apache 2.0.

Caution

This model was created as a personal experiment, unrelated to the organization I work for. The model may not operate correctly because separate verification was not performed. Please be careful unless it is for personal experimentation or PoC (Proof of Concept)!