Phi-3CookBook
Phi-3CookBook copied to clipboard
SK + Phi-3-vision-128k-instruct-onnx-cpu => Not getting Results
Using the following local Model pulled from HF here is my code:
var modelPath =
@"C:\models\Phi-3-vision-128k-instruct-onnx-cpu\cpu-int4-rtn-block-32-acc-level-4";
#pragma warning disable SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// create kernel
var kernel = Kernel
.CreateBuilder()
.AddOnnxRuntimeGenAIChatCompletion(
modelId: "microsoft/Phi-3-vision-128k-instruct",
//modelId: "Phi-3-vision-128k-instruct-onnx-cp",
modelPath: modelPath
)
.Build();
// create chat
var chat = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory();
var testImgPath = Path.Combine(Directory.GetCurrentDirectory(), "imgs", "test.png");
// create chat collection items
var collectionItems = new ChatMessageContentItemCollection
{
new TextContent("What is the image?"),
new ImageContent(File.ReadAllBytes(testImgPath), "image/png")
};
history.AddUserMessage(collectionItems);
Console.Write($"Phi3: ");
var result = await chat.GetChatMessageContentsAsync(history);
Console.WriteLine(result[^1].Content);
Console.Read();
I keep getting responses like this: (image below)
Sorry, I cannot answer this question.
The image is not shown. This is a placeholder for a content that cannot be displayed.</s>
Is there something wrong with my code?