1+ {
2+ "cells" : [
3+ {
4+ "cell_type" : " markdown" ,
5+ "id" : " 468831db" ,
6+ "metadata" : {
7+ "id" : " 468831db"
8+ },
9+ "source" : [
10+ " # Phi-3.5 Mini Conversational Example"
11+ ]
12+ },
13+ {
14+ "cell_type" : " markdown" ,
15+ "id" : " ecb80fe2" ,
16+ "metadata" : {
17+ "id" : " ecb80fe2"
18+ },
19+ "source" : [
20+ " **Description:**\n " ,
21+ " \n " ,
22+ " Demonstrates lightweight inference using Phi-3.5 Mini, suitable for smaller hardware and educational use cases."
23+ ]
24+ },
25+ {
26+ "cell_type" : " markdown" ,
27+ "source" : [
28+ " [](https://colab.research.google.com/github/DhivyaBharathy-web/PraisonAI/blob/main/examples/cookbooks/Phi_3_5_Mini_Conversational.ipynb)\n "
29+ ],
30+ "metadata" : {
31+ "id" : " S1erg7-JP6n3"
32+ },
33+ "id" : " S1erg7-JP6n3"
34+ },
35+ {
36+ "cell_type" : " markdown" ,
37+ "id" : " 0822161c" ,
38+ "metadata" : {
39+ "id" : " 0822161c"
40+ },
41+ "source" : [
42+ " **Dependencies**\n " ,
43+ " \n " ,
44+ " ```python\n " ,
45+ " !pip install transformers accelerate\n " ,
46+ " !pip install torch\n " ,
47+ " ```"
48+ ]
49+ },
50+ {
51+ "cell_type" : " markdown" ,
52+ "id" : " 0df5580b" ,
53+ "metadata" : {
54+ "id" : " 0df5580b"
55+ },
56+ "source" : [
57+ " **Tools Used**\n " ,
58+ " \n " ,
59+ " - HuggingFace Transformers\n " ,
60+ " - PyTorch"
61+ ]
62+ },
63+ {
64+ "cell_type" : " markdown" ,
65+ "id" : " 9d6df43d" ,
66+ "metadata" : {
67+ "id" : " 9d6df43d"
68+ },
69+ "source" : [
70+ " **YAML Prompt**\n " ,
71+ " \n " ,
72+ " ```yaml\n " ,
73+ " system: You are a helpful assistant.\n " ,
74+ " user: Explain what an AI model is.\n " ,
75+ " ```"
76+ ]
77+ },
78+ {
79+ "cell_type" : " code" ,
80+ "execution_count" : null ,
81+ "id" : " 0e775593" ,
82+ "metadata" : {
83+ "id" : " 0e775593"
84+ },
85+ "outputs" : [],
86+ "source" : [
87+ " from transformers import AutoTokenizer, AutoModelForCausalLM\n " ,
88+ " \n " ,
89+ " tokenizer = AutoTokenizer.from_pretrained(\" microsoft/phi-3.5-mini\" )\n " ,
90+ " model = AutoModelForCausalLM.from_pretrained(\" microsoft/phi-3.5-mini\" )\n " ,
91+ " \n " ,
92+ " inputs = tokenizer(\" What is an AI model?\" , return_tensors=\" pt\" )\n " ,
93+ " outputs = model.generate(**inputs, max_new_tokens=40)\n " ,
94+ " print(tokenizer.decode(outputs[0], skip_special_tokens=True))"
95+ ]
96+ },
97+ {
98+ "cell_type" : " markdown" ,
99+ "id" : " 187fe354" ,
100+ "metadata" : {
101+ "id" : " 187fe354"
102+ },
103+ "source" : [
104+ " **Output**\n " ,
105+ " \n " ,
106+ " The model gives a basic explanation of what AI models do.\n " ,
107+ " \n " ,
108+ " What is an AI model?\n " ,
109+ " An AI model is a computer program that is trained on large amounts of data to perform tasks that normally require human intelligence.\n "
110+ ]
111+ }
112+ ],
113+ "metadata" : {
114+ "colab" : {
115+ "provenance" : []
116+ }
117+ },
118+ "nbformat" : 4 ,
119+ "nbformat_minor" : 5
120+ }
0 commit comments