Comments (3)
Hello @LaurentMazare ,
Thank you very much for the heads up and opportunity to have a look before the merge. I think this is a great change, and if my understanding is correct this will expose some functions that until now were not available in the Rust bindings to Libtorch. I agree the name is now far more meaningful. The cost is a slightly stronger deviation to Pytorch (but closer to Libtorch) and potentially more verbose code. I believe this should not affect readability to a large extend.
I had a look at the example refactored already, and noted 2 main cases where multiple version of functions exists:
- Different input type (e.g.
g_sub1
) - Additional arguments (e.g.
arange1
,squeeze1
,mean1
)
For the second case, it would be great to keep the default version (corresponding to the minimum number of arguments?) the same, and adding additional inputs to the function name for other version. This would mean that arange
remains arange
, but arange1
becomes arange_start
. This helps a lot disambiguating, and allows exposing additional methods in the Rust bindings. I believe this is the current proposal and think this is a great change!
For the first case (different types of inputs), I find the change to be at times a bit inconvenient, especially for scalars that also take 0-dimension tensor as an input (which are in the vast majority of cases used with scalars), e.g.
fill_
->fill_scalar_
masked_fill
->masked_fill_scalar
I am wondering if there is not a more elegant way to handle a fixed number of inputs, but of various type. I am thinking of Rust generics which are typically used for this, but I have no experience using them in the context of bindings. Maybe you could create combinations of generic types (e.g.SCALAR_TENSOR
) and have an implementation forgt
of the form:
fn gt<T: SCALAR_TENSOR> {
self.f_gt(other).unwrap()
}
from rust-bert.
Thanks, that's some great ideas.
For (1) I just pushed some changes that should preserve the old non-indexed functions most of the time, and it indeed makes the amount of changes quite smaller.
Re (2) this indeed seems like the idiomatic way to handle parameters having multiple possible types in rust. That said the implementation is a bit tedious so I'll probably punt on this for the moment.
from rust-bert.
The 1.9 update to tch-rs has now been merged, thanks again for the feedback (and don't hesitate if you see any way we can make tch-rs better).
from rust-bert.
Related Issues (20)
- Fine-tuning Marian model can't use pipeline doing translate task HOT 2
- When label mapping aren't provided - we get a crash HOT 1
- Zeroshot with DeBerta v2 vs BART - is it worth it? HOT 2
- Can I use this lib with onnx but without libtorch? HOT 1
- how to use Cross-Encoder for MS Marco by rust-bert?
- Seek Assistance and Support for DeBERTa Model HOT 2
- Is multilabel prediction correct? HOT 1
- Evaluation fails when trying to extract keywords from a specific sentence HOT 2
- Please expose tonekizer params on models where `forward_t` is exposed
- Downloading a model to a local Directory HOT 4
- Question: Configuring ZeroShotClassificationModel with DeBERTaV2 - Documentation HOT 1
- Upgrade Cargo dependencies HOT 2
- GPT-2 text generation throws an unexpected error HOT 4
- Any plan to release a new version? HOT 2
- Question: is it ok to continue after OOM error from `encode`
- update to be working with torch 2.2.0
- support for huggingface access token
- Error on running example in Linux
- RemoteResource doesn't allow loading safetensors models
- linking with `cc` failed: exit status: 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bert.