This is an unofficial ONNX export of SmolLM2-360M-Instruct by Hugging Face, for Unity Inference Engine and the Unity package tools.doji.transformers. The model file is a modified version of the original weights: it is exported to ONNX with standard operators only (opset 17), with float32 weights. The original Apache License 2.0 terms apply.
The weights take 1.52 GiB. AI Model Hub converts the model to a .sentis file when it imports it. To skip the conversion, use julienkay/SmolLM2-360M-Instruct-sentis-float16, which has the same model as a float16 .sentis file. The configs and tokenizer files are the ones of the original model.
tools/causal_lm/make_models.py export HuggingFaceTB/SmolLM2-360M-Instruct in tools.doji.transformers exported the model.
input_ids, attention_mask, position_ids and past_key_values.{i}.key/value in, logits and present.{i}.key/value out.onnx/model.onnx of the original repository uses com.microsoft contrib operators (GroupQueryAttention, RotaryEmbedding, SkipSimplifiedLayerNormalization), which Unity Inference Engine cannot import. This export uses none.Add the repository to the project's AI Model Hub manifest (Project Settings > Doji > AI > AI Model Hub), then:
using Doji.AI.Transformers;
var tokenizer = await AutoTokenizer.FromPretrainedAsync("julienkay/SmolLM2-360M-Instruct-onnx");
using var model = await AutoModelForCausalLM.FromPretrainedAsync("julienkay/SmolLM2-360M-Instruct-onnx");
string prompt = tokenizer.ApplyChatTemplate(new[] { ChatMessage.User("What is the capital of France?") });
int[] inputIds = tokenizer.Encode(prompt, addSpecialTokens: false).InputIds.ToArray();
var streamer = new TextStreamer(tokenizer, text => Debug.Log(text), skipPrompt: true);
await model.GenerateAsync(inputIds, new GenerationConfig { MaxNewTokens = 64 }, streamer);
Other versions:
HuggingFaceTB/SmolLM2-360M-Instruct