phi

Phi-2:微软研究院开发的 27 亿参数语言模型,在推理和语言理解方面展现出卓越的能力。

2.7b

379.6K 10 个月前

自述文件

Phi-2 是一款小型语言模型,能够进行常识推理和语言理解。它在参数量不到 130 亿的语言模型中展现出“最先进的性能”。

示例提示

默认情况下,phi 包含一个为多轮对话设计的聊天提示模板

% ollama run phi
>>> Hello, can you help me find my way to Toronto?
 Certainly! What is the exact location in Toronto that you are looking for?

>>> Yonge & Bloor
 Sure, Yonge and Bloor is a busy intersection in downtown Toronto. Would you like to take public transportation or drive there?

>>> Public transportation
 Great! The easiest way to get there is by taking the TTC subway. You can take Line 1, which runs along Yonge Street and passes through downtown Toronto.

使用 Ollama 的 API

curl https://127.0.0.1:11434/api/chat -d '{
  "model": "phi",
  "messages": [
    { "role": "user", "content": "why is the sky blue?" }
  ]
}'

示例提示(原始模式)

Phi 在使用 Ollama API 的 原始模式 时,对各种提示格式的响应也很好,该模式绕过了所有默认提示模板

指令

curl https://127.0.0.1:11434/api/generate -d '{
  "model": "phi",
  "prompt": "Instruct: Write a detailed analogy between mathematics and a lighthouse.\nOutput:",
  "options": {
    "stop": ["Instruct:", "Output:"]
  },
  "raw": true,
  "stream": false
}'

代码补全

curl https://127.0.0.1:11434/api/generate -d '{
  "model": "phi",
  "prompt": "def print_prime(n):\n  ",
  "raw": true,
  "stream": false
}'

文本补全

curl https://127.0.0.1:11434/api/generate -d '{
  "model": "phi",
  "prompt": "There once was a mouse named",
  "raw": true,
  "stream": false
}'

参考资料

HuggingFace

博客文章