Skip to content

models microsoft phi 2

github-actions[bot] edited this page May 9, 2024 · 27 revisions

microsoft-phi-2

Overview

Microsoft Phi-2

The phi-2 is a language model with 2.7 billion parameters. The phi-2 model was trained using the same data sources as phi-1, augmented with a new data source that consists of various NLP synthetic texts and filtered websites (for safety and educational value). When assessed against benchmarks testing common sense, language understanding, and logical reasoning, the phi-2 showcased a nearly state-of-the-art performance among models with less than 10 billion parameters.

Our model hasn't been fine-tuned through reinforcement learning from human feedback. The intention behind crafting this open-source model is to provide the research community with a non-restricted small model to explore vital safety challenges, such as reducing toxicity, understanding societal biases, enhancing controllability, and more.

Intended Uses

Given the nature of the training data, the phi-2 model is best suited for prompts using the QA format, the chat format, and the code format.

Out of scope

  • The phi-2 model is intended for QA, chat, and code purposes.. The model-generated text/code should be treated as a starting point rather than a definitive solution for potential use cases. Users should be cautious when employing these models in their applications.
  • Direct adoption for production tasks without evaluation is out of scope of this project. As a result, the phi-2 model has not been tested to ensure that it performs adequately for any production-level application. Please refer to the limitation sections of this document for more details.

Loading the model locally

You can download the source code and model weights from the Artifacts tab. Please refer to the data/load_model.ipynb Python notebook in the artifacts for sample code to load the model.

Limitations

  • Generate Inaccurate Code and Facts: The model may produce incorrect code snippets and statements. Users should treat these outputs as suggestions or starting points, not as definitive or accurate solutions.

  • Limited Scope for code: Majority of phi-2 training data is based in Python and use common packages such as "typing, math, random, collections, datetime, itertools". If the model generates Python scripts that utilize other packages or scripts in other languages, we strongly recommend users manually verify all API uses.

  • Unreliable Responses to Instruction: The model has not undergone instruction fine-tuning. As a result, it may struggle or fail to adhere to intricate or nuanced instructions provided by users.

  • Language Limitations: The model is primarily designed to understand standard English. Informal English, slang, or any other languages might pose challenges to its comprehension, leading to potential misinterpretations or errors in response.

  • Potential Societal Biases: phi-2 is not entirely free from societal biases despite efforts in assuring trainig data safety. There's a possibility it may generate content that mirrors these societal biases, particularly if prompted or instructed to do so. We urge users to be aware of this and to exercise caution and critical thinking when interpreting model outputs.

  • Toxicity: Despite being trained with carefully selected data, the model can still produce harmful content if explicitly prompted or instructed to do so. We chose to release the model to help the open-source community develop the most effective ways to reduce the toxicity of a model directly after pretraining.

  • Verbosity: Phi-2 being a base model often produces irrelevant or extra text and responses following its first answer to user prompts within a single turn. This is due to its training dataset being primarily textbooks, which results in textbook-like responses.

Training:

Model

  • Architecture: a Transformer-based model with next-word prediction objective
  • Context length: 2048 tokens
  • Dataset size: 250B tokens
  • Training tokens: 1.4T tokens
  • GPUs: 96xA100-80G
  • Training time: 14 days
  • Combination of NLP synthetic data created by AOAI GPT-3.5 and filtered web data from Falcon RefinedWeb and SlimPajama, which was assessed by AOAI GPT-4.

Software

License:

The model is licensed under the MIT license.

Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Sample inputs and outputs (for real-time inference)

Sample Question-Answering input

{
	  "input_data": {
	    "input_string": [
	      "Instruct: What is a fermi paradox?\nOutput:"
	    ],
	    "parameters": {
	      "top_p": 0.1,
	      "temperature": 0.1,
	      "max_new_tokens": 100,
	      "do_sample": true
	    }
	  }
}

Sample output

[
    {
        "0": "Instruct: What is a fermi paradox?\nOutput: A fermi paradox is a paradox that arises from the observation that the universe is so vast and empty that it should be teeming with intelligent life, yet we have not encountered any evidence of such life. The paradox asks why we are alone in the universe, or why we have not received any signals or messages from other civilizations.\n"
    }
]

Sample Chat input

{
  "input_data": {
    "input_string": [
      "Alice: What is a fermi paradox?"
    ],
    "parameters": {
      "top_p": 0.9,
      "temperature": 0.6,
      "max_new_tokens": 100,
      "do_sample": true
    }
  }
}

Sample output

[
    {
        "0": "Alice: What is a fermi paradox?\n\nBob: The fermi paradox is a question about the existence of extraterrestrial life. It asks why we haven't discovered any signs of intelligent life despite the vastness of the universe.\n\nAlice: That's a fascinating question. It raises the possibility that there might be other civilizations out there.\n\nBob: Indeed. The search for extraterrestrial intelligence is an active area of research, with scientists using various methods to detect signals from distant planets.\n\nAlice: It's"
    }
]

Sample Code input

{
  "input_data": {
    "input_string": [
      "def is_prime("
    ],
    "parameters": {
      "top_p": 0.9,
      "temperature": 0.6,
      "max_new_tokens": 100,
      "do_sample": true
    }
  }
}

Sample output

[
    {
        "0":"def is_prime(n: int) -> bool:\n        if n < 2:\n            return False\n        for i in range(2, int(math.sqrt(n))+1):\n            if n % i == 0:\n                return False\n        return True\n\n    return [n for n in li if is_prime(n)]\n\n"
    }
]

Version: 19

Tags

Preview SharedComputeCapacityEnabled license : mit author : microsoft task : text-generation hiddenlayerscanned evaluation_compute_allow_list : ['Standard_DS5_v2', 'Standard_NC6s_v3', 'Standard_NC12s_v3', 'Standard_NC24s_v3', 'Standard_NC24rs_v3', 'Standard_ND40rs_v2', 'Standard_ND96asr_v4', 'Standard_ND96amsr_A100_v4'] finetune_compute_allow_list : ['Standard_ND40rs_v2', 'Standard_NC24ads_A100_v4', 'Standard_NC48ads_A100_v4', 'Standard_NC96ads_A100_v4', 'Standard_ND96asr_v4', 'Standard_ND96amsr_A100_v4'] inference_compute_allow_list : ['Standard_NC4as_T4_v3', 'Standard_NC6s_v3', 'Standard_NC8as_T4_v3', 'Standard_NC12s_v3', 'Standard_NC16as_T4_v3', 'Standard_NC24s_v3', 'Standard_NC64as_T4_v3', 'Standard_NC24ads_A100_v4', 'Standard_NC48ads_A100_v4', 'Standard_NC96ads_A100_v4', 'Standard_ND96asr_v4', 'Standard_ND96amsr_A100_v4', 'Standard_ND40rs_v2'] inference_supported_envs : ['vllm'] model_specific_defaults : ordereddict({'apply_deepspeed': 'true', 'deepspeed_stage': 2, 'apply_lora': 'true', 'apply_ort': 'false', 'precision': 16, 'max_seq_length': 2048})

View in Studio: https://ml.azure.com/registries/azureml/models/microsoft-phi-2/version/19

License: mit

Properties

SharedComputeCapacityEnabled: True

SHA: b10c3eba545ad279e7208ee3a5d644566f001670

datasets: StackOverflow, Stackv1.2, CodeContests, gpt-3.5-turbo-0301

inference-min-sku-spec: 4|1|28|64

inference-recommended-sku: Standard_NC4as_T4_v3, Standard_NC6s_v3, Standard_NC8as_T4_v3, Standard_NC12s_v3, Standard_NC16as_T4_v3, Standard_NC24s_v3, Standard_NC64as_T4_v3, Standard_NC24ads_A100_v4, Standard_NC48ads_A100_v4, Standard_NC96ads_A100_v4, Standard_ND96asr_v4, Standard_ND96amsr_A100_v4, Standard_ND40rs_v2

languages: en

evaluation-min-sku-spec: 6|0|56|112

evaluation-recommended-sku: Standard_DS5_v2, Standard_NC6s_v3, Standard_NC12s_v3, Standard_NC24s_v3, Standard_NC24rs_v3, Standard_ND40rs_v2, Standard_ND96asr_v4, Standard_ND96amsr_A100_v4

finetuning-tasks: text-generation

finetune-min-sku-spec: 24|1|220|64

finetune-recommended-sku: Standard_ND40rs_v2, Standard_NC24ads_A100_v4, Standard_NC48ads_A100_v4, Standard_NC96ads_A100_v4, Standard_ND96asr_v4, Standard_ND96amsr_A100_v4

Clone this wiki locally