Oracle 23ai Vector Search 系列之2 ONNX(Open Neural Network Exchange)
文章目录
- Oracle 23ai Vector Search 系列之2 ONNX(Open Neural Network Exchange)
- ONNX基本概念
- ONNX(Open Neural Network Exchange)
- ONNX Runtime
- ONNX Runtime 在Oracle数据库中的集成
- 参考
Windows 环境图形化安装 Oracle 23ai
Oracle 23ai Vector Search 系列之1 架构基础
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