文章目錄
- Oracle 23ai Vector Search 系列之2 ONNX(Open Neural Network Exchange)
- ONNX基本概念
- ONNX(Open Neural Network Exchange)
- ONNX Runtime
- ONNX Runtime 在Oracle數據庫中的集成
- 參考
Oracle 23ai Vector Search 系列之2 ONNX(Open Neural Network Exchange)
我們在看【Oracle AI Vector Search User’s Guide】文檔時,會看到有很多地方都提到了“ONNX”,“ONNX”代表什么?
ONNX基本概念
ONNX(Open Neural Network Exchange)
- ONNX是Open Neural Network Exchange的縮寫,即開放神經網絡交換。
- ONNX是一種用于存儲和交換機器學習模型的開放標準格式,旨在實現不同深度學習框架(如PyTorch、TensorFlow、MXNet等)之間的互操作性。
- ONNX的主要功能和用途是使得AI模型可以在不同的框架和環境下交互使用,同時硬件和軟件廠商可以基于ONNX標準優化模型性能,讓所有兼容ONNX標準的框架受益。
參考:
https://github.com/onnx/onnx/tree/main
Open Neural Network Exchange (ONNX) is an open ecosystem that empowers AI developers to choose the right tools as their project evolves. ONNX provides an open source format for AI models, both deep learning and traditional ML. It defines an extensible computation graph model, as well as definitions of built-in operators and standard data types. Currently we focus on the capabilities needed for inferencing (scoring).
ONNX is widely supported and can be found in many frameworks, tools, and hardware. Enabling interoperability between different frameworks and streamlining the path from research to production helps increase the speed of innovation in the AI community. We invite the community to join us and further evolve ONNX.
ONNX就像是不同深度學習框架之間的”翻譯官”,讓模型可以在不同框架間自由轉換。
例如用PyTorch訓練了的模型(model.pt),可以轉換成ONNX格式的模型(model.onnx),然后部署運行。
ONNX Runtime
ONNX格式的模型可通過ONNX Runtime運行。
ONNX Runtime是一個跨平臺、能夠更好地利用特定硬件的機器學習模型加速器。
參考:
https://onnxruntime.ai/docs/
ONNX Runtime is a cross-platform machine-learning model accelerator, with a flexible interface to integrate hardware-specific libraries. ONNX Runtime can be used with models from PyTorch, Tensorflow/Keras, TFLite, scikit-learn, and other frameworks.
ONNX Runtime 在Oracle數據庫中的集成
我們知道Oracle Database 23ai集成了AI Vector Search等功能,支持VECTOR 數據類型,可以直接在 Oracle Database 23ai 中存儲向量。
但要想使用AI Vector Search等功能,首先將文本等信息轉換成vector,這就需要embedding模型。
作為最為強大的數據庫,Oracle也提供了各種支持。
- Oracle 23ai數據庫對ONNX Runtime 進行了集成,允許導入包括embedding模型等ONNX格式的AI模型到數據庫中使用。
- Oracle提供了Python實用程序包幫助用戶把其他預訓練模型轉換為ONNX格式的模型。
具體的ONNX格式模型轉換方法可以參考如下文檔:
Import Pretrained Models in ONNX Format
- Oracle提供了ONNX格式的嵌入生成模型all-MiniLM-L12-v2。并可以通過DBMS_VECTOR.LOAD_ONNX_MODEL加載到數據庫中。
參考:
Now Available! Pre-built Embedding Generation model for Oracle Database 23ai
參考
Oracle Machine Learning for SQL (OML4SQL) API Guide
>39.1 About ONNX
Oracle Machine Learning for Python (OML4Py) User’s Guide
Import Pretrained Models in ONNX Format
onnx
https://github.com/onnx/onnx
https://onnx.ai/index.html
https://oracle-base.com/articles/23/ai-vector-search-23