Allow for OpenVINO models to be stored in a model subdirectory #923
+18
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR allows users to load a model from a subdirectory via just
file_name
.My goal:
Where only the modeling files are in the
openvino
subfolder.Result:
I.e. it starts exporting because it doesn't find any openvino file anywhere (because it only looks in the root directory).
For reference, this is exactly how I do it for ONNX via Optimum, and it works well there.
An alternative
So I tried using
subfolder
:But then the rest of the files outside of the subfolder can't be read, and I get:
I'm also pretty sure that I can't specify the library anywhere, so this is a dead end. Ideally, I want it to work equivalently to ONNX anyways.
The fix
The simple fix that I've applied for now is also look for openvino files in subdirectories. After all, if there's an exported openvino file anywhere, you probably want to inform the user rather than re-export a model.
After the fix, I get this:
Before submitting
Note
This issue will likely prevent me from including UKPLab/sentence-transformers#2712 into the next Sentence Transformers release, sadly. That PR adds OpenVINO and ONNX backends to Sentence Transformers, but currently it's not possible to load saved OpenVINO files due to this issue.
P.s. I have no plans to further update
sentence-transformers-testing/stsb-bert-tiny-openvino
, I'll be using it in my own tests as well.cc @echarlaix @helena-intel