Views
No views yet
1import { InferenceSession, Tensor } from 'onnxruntime-web';
2
3// Load the model
4const session = await InferenceSession.create('./onnx/model.onnx', {
5 executionProviders: ['webgpu', 'wasm']
6});
7
8// Run inference
9const inputIds = new Tensor('int64', [2, 818, 5279, 529, 7001, 563], [1, 6]);
10const attentionMask = new Tensor('int64', [1, 1, 1, 1, 1, 1], [1, 6]);
11
12const results = await session.run({
13 input_ids: inputIds,
14 attention_mask: attentionMask
15});
16
17const logits = results.logits; // Shape: [1, 6, 262144]1import onnxruntime as ort
2import numpy as np
3
4# Load the model
5session = ort.InferenceSession('onnx/model.onnx')
6
7# Prepare inputs
8input_ids = np.array([[2, 818, 5279, 529, 7001, 563]], dtype=np.int64)
9attention_mask = np.array([[1, 1, 1, 1, 1, 1]], dtype=np.int64)
10
11# Run inference
12outputs = session.run(None, {
13 'input_ids': input_ids,
14 'attention_mask': attention_mask
15})
16
17logits = outputs[0] # Shape: (1, 6, 262144)onnx/model.onnx - FP16 ONNX model file (symlink to model_fp32_fp16.onnx)onnx/model_fp32_fp16.onnx - FP16 ONNX model fileonnx/model_fp32.onnx - Original FP32 ONNX model file (for comparison)config.json - Model configurationtokenizer.json - Fast tokenizertokenizer.model - SentencePiece tokenizergeneration_config.json - Generation parameters1@misc{gemma3,
2 title={Gemma 3: Advancing Open Language Models},
3 author={Google DeepMind},
4 year={2024},
5 url={https://huggingface.co/google/gemma-3-270m-it}
6}