💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Fix incompatibility with ONNX models and transformers>=4.41.0, closes #720
davidmezzettic4080a348a2f
diff --git a/src/python/txtai/models/onnx.py b/src/python/txtai/models/onnx.pyindex 5c2ea0c9..4abba63a 100644--- a/src/python/txtai/models/onnx.py+++ b/src/python/txtai/models/onnx.py@@ -48,6 +48,17 @@ class OnnxModel(PreTrainedModel):# Add references for this class to supported AutoModel classesRegistry.register(self)+ @property+ def device(self):+ """+ Returns model device id.++ Returns:+ model device id+ """++ return -1+def providers(self):"""Returns a list of available and usable providers.diff --git a/test/python/testpipeline/testonnx.py b/test/python/testpipeline/testonnx.pyindex 15e76db7..3658d64a 100644--- a/test/python/testpipeline/testonnx.py+++ b/test/python/testpipeline/testonnx.py@@ -13,6 +13,7 @@ from sklearn.linear_model import LogisticRegressionfrom sklearn.pipeline import Pipelinefrom txtai.embeddings import Embeddings+from txtai.models import OnnxModelfrom txtai.pipeline import HFOnnx, HFTrainer, Labels, MLOnnx, Questions@@ -41,6 +42,9 @@ class TestOnnx(unittest.TestCase):# Validate model has dataself.assertGreater(len(model), 0)+ # Validate model device properly works+ self.assertEqual(OnnxModel(model).device, -1)+def testClassification(self):"""Test exporting a classification model to ONNX and running inference