Instructions to use unity/inference-engine-phi-1_5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- unity-sentis
How to use unity/inference-engine-phi-1_5 with unity-sentis:
string modelName = "[Your model name here].sentis"; Model model = ModelLoader.Load(Application.streamingAssetsPath + "/" + modelName); IWorker engine = WorkerFactory.CreateWorker(BackendType.GPUCompute, model); // Please see provided C# file for more details
- Notebooks
- Google Colab
- Kaggle
Update RunPhi15.cs
Browse filesFixed Load Vocabulary() issue on Mac and Linux. (line 142)
The original line was:
merges = mergesAsset.text.Split("\r\n");
Replaced with code that splits on '\n', trims any '\r', and skips the #version header line (lines 140–148 in the current file).
The original code (Split("\r\n")) only worked on Windows. The current fix is cross-platform.
- RunPhi15.cs +14 -4
RunPhi15.cs
CHANGED
|
@@ -13,9 +13,11 @@ public class RunPhi15 : MonoBehaviour
|
|
| 13 |
|
| 14 |
const BackendType backend = BackendType.GPUCompute;
|
| 15 |
|
| 16 |
-
|
| 17 |
-
string outputString = "
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
// This is how many tokens you want. It can be adjusted.
|
| 20 |
const int maxTokens = 100;
|
| 21 |
|
|
@@ -135,7 +137,15 @@ public class RunPhi15 : MonoBehaviour
|
|
| 135 |
tokens[item.Value] = item.Key;
|
| 136 |
}
|
| 137 |
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
// Translates encoded special characters to Unicode
|
|
|
|
| 13 |
|
| 14 |
const BackendType backend = BackendType.GPUCompute;
|
| 15 |
|
| 16 |
+
string outputString = "Write a detailed analogy between mathematics and a lighthouse.";
|
| 17 |
+
// string outputString = "Create a list of the first 10 even numbers using list comprehension";
|
| 18 |
+
// string outputString = "# Python function to compute the nth Fibonacci number using recursion\ndef fibonacci(n):\nif n <= 1:";
|
| 19 |
+
// string outputString = "One day an alien came down from Mars. It saw a chicken";
|
| 20 |
+
|
| 21 |
// This is how many tokens you want. It can be adjusted.
|
| 22 |
const int maxTokens = 100;
|
| 23 |
|
|
|
|
| 137 |
tokens[item.Value] = item.Key;
|
| 138 |
}
|
| 139 |
|
| 140 |
+
var allMerges = mergesAsset.text.Split('\n');
|
| 141 |
+
var mergeList = new List<string>();
|
| 142 |
+
foreach (var line in allMerges)
|
| 143 |
+
{
|
| 144 |
+
var trimmed = line.TrimEnd('\r');
|
| 145 |
+
if (trimmed.Length > 0 && trimmed[0] != '#')
|
| 146 |
+
mergeList.Add(trimmed);
|
| 147 |
+
}
|
| 148 |
+
merges = mergeList.ToArray();
|
| 149 |
}
|
| 150 |
|
| 151 |
// Translates encoded special characters to Unicode
|