mirror of
https://github.com/hanzoai/engine.git
synced 2026-11-20 14:17:52 +00:00
2.9 KiB
2.9 KiB
Phi 3.5 MoE Model: microsoft/Phi-3.5-MoE-instruct
The Phi 3.5 MoE model is a 16x3.8B parameter decoder-only text-to-text mixture of expert LLM.
- Context length of 128k tokens
- Trained on 4.9T tokens
- 16 experts (16x3.8B parameters) with 6.6B active parameters
- Expect inference performance of a 7B model
Note
This model supports MoQE which can be activated in the ISQ organization parameter within the various APIs, as demonstrated below.
Quick Start
hanzo run -m microsoft/Phi-3.5-MoE-instruct --isq 4 -i "Tell me a story about the Rust type system."
With MoQE:
hanzo run -m microsoft/Phi-3.5-MoE-instruct --isq 4 --isq-organization moqe -i "Tell me a story about the Rust type system."
HTTP API
- Start the server
hanzo serve -m microsoft/Phi-3.5-MoE-instruct --isq 4 -p 1234
- Send a request
from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")
completion = client.chat.completions.create(
model="default",
messages=[
{
"role": "user",
"content": "Tell me a story about the Rust type system.",
},
],
max_tokens=256,
)
print(completion.choices[0].message.content)
Python SDK
from hanzo import Runner, Which, ChatCompletionRequest, Architecture
runner = Runner(
which=Which.Plain(
model_id="microsoft/Phi-3.5-MoE-instruct",
arch=Architecture.Phi3_5MoE,
),
)
res = runner.send_chat_completion_request(
ChatCompletionRequest(
model="default",
messages=[
{"role": "user", "content": "Tell me a story about the Rust type system."}
],
max_tokens=256,
)
)
print(res.choices[0].message.content)
print(res.usage)
Rust SDK
You can find this example here.
use anyhow::Result;
use hanzo::{
IsqType, PagedAttentionMetaBuilder, TextMessageRole, TextMessages, TextModelBuilder,
};
#[tokio::main]
async fn main() -> Result<()> {
let model = TextModelBuilder::new("microsoft/Phi-3.5-MoE-instruct")
.with_isq(IsqType::Q4K)
.with_logging()
.with_paged_attn(|| PagedAttentionMetaBuilder::default().build())?
.build()
.await?;
let messages = TextMessages::new()
.add_message(
TextMessageRole::System,
"You are an AI agent with a specialty in programming.",
)
.add_message(
TextMessageRole::User,
"Hello! How are you? Please write generic binary search function in Rust.",
);
let response = model.send_chat_request(messages).await?;
println!("{}", response.choices[0].message.content.as_ref().unwrap());
dbg!(
response.usage.avg_prompt_tok_per_sec,
response.usage.avg_compl_tok_per_sec
);
Ok(())
}