Welcome to the Phi-3 samples using C#. This repository contains a set of demo projects that showcases how to integrate the powerful different versions of Phi-3 models in a .NET environment.
Before running the sample, ensure you have the following installed:
-
.NET 8: Make sure you have the latest version of .NET installed on your machine.
-
(Optional) Visual Studio or Visual Studio Code: You will need an IDE or code editor capable of running .NET projects. Visual Studio or Visual Studio Code are recommended.
-
Using git, clone locally one of the available Phi-3 versions from Hugging Face.
-
Download the phi3-mini-4k-instruct-onnx model to your local machine:
# navigate to the folder to store the models cd c:\phi3\models # add support for lfs git lfs install # clone and download mini 4K instruct model git clone https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-onnx # clone and download vision 128K model git clone https://huggingface.co/microsoft/Phi-3-vision-128k-instruct-onnx-cpu
Important: The current demos are designed to use the ONNX versions of the model. The previous steps clone the following models.
You can learn more about Phi-3 in Hugging Face.
The main solution have several sample projects that demonstrates the capabilities of the Phi-3 models.
Project | Description | Location |
---|---|---|
LabsPhi301 | This is a sample project that uses a local phi3 model to ask a question. The project load a local ONNX Phi-3 model using the Microsoft.ML.OnnxRuntime libraries. |
.\src\LabsPhi301\ |
LabsPhi303 | This is a sample project that uses a local phi3 vision model to analyze images.. The project load a local ONNX Phi-3 Vision model using the Microsoft.ML.OnnxRuntime libraries. |
.\src\LabsPhi303\ |
LabsPhi304 | This is a sample project that uses a local phi3 vision model to analyze images.. The project load a local ONNX Phi-3 Vision model using the Microsoft.ML.OnnxRuntime libraries. The project also presents a menu with different options to interacti with the user. |
.\src\LabsPhi304\ |
Project | Description | Location |
---|---|---|
LabsPhi3_sk01 | This is a sample project that uses a local phi3 model to ask a question. The project uses Semantic Kernel and SemanticKernel.Connectors.OnnxRuntimeGenAI to load a local Phi-3 model and implement a console chat. | .\src\LabsPhi3_sk01\ |
LabsPhi3_sk02 | This is a sample project that uses a local phi3 model to ask a question. The project uses Semantic Kernel and a local copy of the source code and project SemanticKernel.Connectors.OnnxRuntimeGenAI to load a local Phi-3 model and implement a console chat. | .\src\LabsPhi3_sk02\ |
LabsPhi3_sk03 | The project uses Semantic Kernel and the local copy of the source code and project SemanticKernel.Connectors.OnnxRuntimeGenAI to load a local Phi-3 Vision model and analyzes and describes an image. | .\src\LabsPhi3_sk03\ |
To run the projects, follow these steps:
-
Clone the repository to your local machine.
-
Open a terminal and navigate to the desired project. In example, let's run
LabsPhi301
.cd .\src\LabsPhi301\
-
Run the project with the command
dotnet run
-
The sample project ask for a user input and replies using the local mode.
The running demo is similar to this one:
Note: there is a typo in the 1st question, Phi-3 is cool enough to share the correct answer!
-
The project
LabsPhi304
ask for the user to select different options, and then process the request. In example, analyzing a local image.The running demo is similar to this one:
👤 Bruno Capuano
- Website: https://elbruno.com
- Twitter: @elbruno
- Github: @elbruno
- LinkedIn: @elbruno
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2024 Bruno Capuano.
This project is MIT licensed.