Blog Post

Educator Developer Blog
2 MIN READ

Small Language Models with Phi-3 Cookbook: A Guide

Lee_Stott's avatar
Lee_Stott
Icon for Microsoft rankMicrosoft
May 27, 2024

Small Language Models and Phi-3: A Guide 

Small language models (SLMs) are a powerful tool that has gained significant attention in recent years. They are used to generate text, images, and other forms of content with great precision. In this blog post, we will explore the concept of small language models and how you can use them using the Phi-3 cookbook.

 

What are Small Language Models?

Small language models are a type of neural network that is trained on a large corpus of text data. They are designed to generate new text that is similar to the training data, but they can also be used for tasks like image generation and more.


How do Small Language Models Work?

Small language models work by predicting the next word in a sequence based on the previous words. This process is known as autoregressive prediction. The model learns to generate text by repeatedly predicting the next word in a sequence and comparing its predictions with the actual word.

The Phi-3 Cookbook



 

The Phi-3 cookbook is an open-source repository that provides a collection of code examples for working with small language models. It includes tutorials, recipes, and other resources that will help you learn how to use these powerful models in your own projects.


What can you Learn from the Phi-3 Cookbook?

 

The Phi-3 cookbook is a great resource for technical students who want to learn more about small language models. Here are some of the things you can learn from it:


Generating Text with Small Language Models

You can use the Phi-3 cookbook to generate text using small language models. You can learn how to train your own model on a specific dataset, or you can use one of the pre-trained models that is included in the repository. Once you have generated some text, you can use it for tasks like summarization, machine translation, and more.

Analysing Images with Small Language Models

You can also use small language models to analyze images and text. The Phi-3 cookbook provides examples of how to use these models to Analyze images from text descriptions. This is a great way to learn about computer vision and image generation.

Applying Small Language Models in Real-World Scenarios

The Phi-3 cookbook includes examples of how small language models can be applied in real-world scenarios. You can learn about how these models are used in applications like chatbots, virtual assistants, and more. This will give you a better understanding of the practical applications of this technology.

Conclusion

Small language models are a powerful tool that is becoming increasingly popular in the tech industry. The Phi-3 cookbook is an excellent resource for technical students who want to learn more about these models and how they can be used in their own projects. By working through the recipes and tutorials in this repository, you will gain valuable knowledge and skills that will help you succeed in your future career.

Updated Jun 02, 2024
Version 3.0
  • atcarter714's avatar
    atcarter714
    Copper Contributor

    This is wonderful! I got a Phi-3 mini model and used the Cookbook for hints on how to set up a C# project and was able to get Phi running with DirectML, which is becoming my favorite execution provider now (long-time DirectX/3D developer!). After fixing a couple confusing errors due to NuGet packages I got it running and chatting in the terminal. Now I'm integrating it more properly into a WinUI 3 application with some abstractions that enable any part(s) of the app to consume "AI services" without caring about technical specifics of each model and variant or where it's located (i.e., local, cloud, web server, LAN, etc).

     

    I'm already a bit "off the grid" in terms of documented workflows with established best practices, which is fun and gives one a chance to explore and be innovative and inventive, but I find myself wanting/needing to know more about how all these cool emerging NuGet packages and toys are meant to fit and work together insofar as the wider "ML.NET" ecosystem and these special packages for supporting ONNX, DirectML/CUDA, etc. There's a growing number of NuGet packages for this stuff now, often with similar-looking names and fatal consequences (to your app) for picking the wrong one or having a mismatch. I would propose that a great article (which could be updated time to time) would be a guide to the complex packages ecosystem for ML in the .NET universe and help us all understand better what things do and don't go together, with helpful tips/tricks and warnings about particular combinations of things that are either really useful or invalid/bad. It's a tricky landscape to navigate purely on your experience with .NET and best instincts!