Coder Social home page Coder Social logo

Comments (4)

bclavie avatar bclavie commented on July 19, 2024

Hey Jo! Thank you for this, getting full Vespa compatibility is definitely something I want included very soon.

I don't think HF_ColBERT, in practice, does much more than VespaColBERT here in terms of model initialisation.

There's a potential clarity issue in inheriting BertPreTrainedModel: at the moment, all the open-source ColBERT models are BERT-based (and the attempts with RoBERta appear universally worse), but it might be an issue in the future if people initialise from better models/if a new, shinier encoder-only model appears and becomes the logical base rather than normal BERT. In practice, I don't think it'll actually hinder anything, since you're only using components that you're manually loading/overwriting.

The bert and linear property should both be easy to export, since RAGatouille uses the normal ColBERT training code, the model that gets trained will have them as they're defined features of BaseColBERT. The bert property here is a bit of misnomer, it actually stores any underlying model, even if not BERT 🤔

JaColBERT was trained with RAGatouille-like utils (although quite different back then!), and this works as expected (all models have similar, properly-initiated weights):

VespaJaColBERT = VespaColBERT.from_pretrained("bclavie/JaColBERT", dim=128)
HFColBERT = class_factory("bclavie/JaColBERT")
HFJaColBERT = HFColBERT.from_pretrained("bclavie/JaColBERT", colbert_config=ColBERTConfig(dim=128))
BaseColBERT = BaseColBERT("bclavie/JaColBERT")

assert torch.equal(HFJaColBERT.linear.weight, VespaJaColBERT.linear.weight) and \
       torch.equal(HFJaColBERT.linear.weight, BaseColBERT.linear.weight)

assert torch.equal(HFJaColBERT.bert.embeddings.word_embeddings.weight, VespaJaColBERT.bert.embeddings.word_embeddings.weight) and \
         torch.equal(HFJaColBERT.bert.embeddings.word_embeddings.weight, BaseColBERT.bert.embeddings.word_embeddings.weight)

# assert torch.equal(VespaJaColBERT.linear.weight, VespaColBERTV2.linear.weight) crashes as expected, too!

I think that adding your current exporter, mostly as-is (if you're fine with me re-using the code!) would be fine, and have a ragatouille.models.export_to_vespa function which could be called via RAGTrainer and RAGPreTrainedModel as well would make sense.

I'm also planning on adding an export_to_huggingface_hub() soon (requiring a credential as a env variable), and will make sure it has an export_vespa_onnx: bool parameter to it 😄

from ragatouille.

jobergum avatar jobergum commented on July 19, 2024

Thanks for that! having this type of utility would make it a lot easier to promote RAGatouille as a way to train ColBERT models!

I think that adding your current exporter, mostly as-is (if you're fine with me re-using the code!) would be fine, and have a ragatouille.models.export_to_vespa function which could be called via RAGTrainer and RAGPreTrainedModel as well would make sense.

Fantastic, would greatly appreciate it! I'm going to try to open a PR to upload onnx artifacts to colbert-ir/colbertv2.0, cc @okhat

from ragatouille.

bclavie avatar bclavie commented on July 19, 2024

(tentative implementation in #19)

from ragatouille.

bclavie avatar bclavie commented on July 19, 2024

Implemented in #19

from ragatouille.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.