Update README.md
Browse files
README.md
CHANGED
@@ -4,4 +4,46 @@ language:
|
|
4 |
- en
|
5 |
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
6 |
---
|
7 |
-
This is plain vanilla exported as onnx. I am researching the offline use of various models, and thought might come in handy for the commmunity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
- en
|
5 |
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
6 |
---
|
7 |
+
This is plain vanilla exported as onnx. I am researching the offline use of various models, and thought might come in handy for the commmunity
|
8 |
+
Example use
|
9 |
+
#0. download and unzip the package into a subfolder in you project folder
|
10 |
+
|
11 |
+
#1. Create a new python environment
|
12 |
+
python -m venv llama_env
|
13 |
+
|
14 |
+
#2. activate the environment
|
15 |
+
llama_env\Scripts\activate
|
16 |
+
|
17 |
+
#3. Install onnx runtime
|
18 |
+
pip install onnx onnxruntime-gpu
|
19 |
+
|
20 |
+
#4. Install transformers and py/torch
|
21 |
+
pip install transformers
|
22 |
+
pip install torch
|
23 |
+
pip install pytorch
|
24 |
+
|
25 |
+
#I had to run this when I had a conflic
|
26 |
+
python -m pip install --upgrade pip
|
27 |
+
python -m pip install "numpy<2"
|
28 |
+
|
29 |
+
#I use VSCode, so if you'd like:
|
30 |
+
#Install Jupyter and create notebook
|
31 |
+
pip install jupyter
|
32 |
+
code #run vscode
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
import onnxruntime as ort
|
37 |
+
import torch
|
38 |
+
import numpy as np
|
39 |
+
|
40 |
+
# Load the ONNX model
|
41 |
+
onnx_model_path = "payhTo/llama3.1.onnx"
|
42 |
+
session = ort.InferenceSession(onnx_model_path)
|
43 |
+
|
44 |
+
# Check the model's input and output names and shapes
|
45 |
+
for input_meta in session.get_inputs():
|
46 |
+
print(f"Input Name: {input_meta.name}, Shape: {input_meta.shape}, Type: {input_meta.type}")
|
47 |
+
|
48 |
+
for output_meta in session.get_outputs():
|
49 |
+
print(f"Output Name: {output_meta.name}, Shape: {output_meta.shape}, Type: {output_meta.type}")
|