Giter Club home page Giter Club logo

finetuner's Introduction



Finetuner logo: Finetuner helps you to create experiments in order to improve embeddings on search tasks. It accompanies you to deliver the last mile of performance-tuning for neural search applications.

Task-oriented finetuning for better embeddings on neural search

PyPI Codecov branch PyPI - Downloads from official pypistats

Fine-tuning is an effective way to improve performance on neural search tasks. However, setting up and performing fine-tuning can be very time-consuming and resource-intensive.

Jina AI's Finetuner makes fine-tuning easier and faster by streamlining the workflow and handling all the complexity and infrastructure in the cloud. With Finetuner, you can easily enhance the performance of pre-trained models, making them production-ready without extensive labeling or expensive hardware.

🎏 Better embeddings: Create high-quality embeddings for semantic search, visual similarity search, cross-modal text<->image search, recommendation systems, clustering, duplication detection, anomaly detection, or other uses.

Low budget, high expectations: Bring considerable improvements to model performance, making the most out of as little as a few hundred training samples, and finish fine-tuning in as little as an hour.

📈 Performance promise: Enhance the performance of pre-trained models so that they deliver state-of-the-art performance on domain-specific applications.

🔱 Simple yet powerful: Easy access to 40+ mainstream loss functions, 10+ optimizers, layer pruning, weight freezing, dimensionality reduction, hard-negative mining, cross-modal models, and distributed training.

All-in-cloud: Train using our GPU infrastructure, manage runs, experiments, and artifacts on Jina AI Cloud without worrying about resource availability, complex integration, or infrastructure costs.

Pretrained Text Embedding Models

name parameter dimension Huggingface
jina-embedding-t-en-v1 14m 312 link
jina-embedding-s-en-v1 35m 512 link
jina-embedding-b-en-v1 110m 768 link
jina-embedding-l-en-v1 330m 1024 link

Benchmarks

Model Task Metric Pretrained Finetuned Delta Run it!
BERT Quora Question Answering mRR 0.835 0.967 15.8%

Open In Colab

Recall 0.915 0.963 5.3%
ResNet Visual similarity search on TLL mAP 0.110 0.196 78.2%

Open In Colab

Recall 0.249 0.460 84.7%
CLIP Deep Fashion text-to-image search mRR 0.575 0.676 17.4%

Open In Colab

Recall 0.473 0.564 19.2%
M-CLIP Cross market product recommendation (German) mRR 0.430 0.648 50.7%

Open In Colab

Recall 0.247 0.340 37.7%
PointNet++ ModelNet40 3D Mesh Search mRR 0.791 0.891 12.7%

Open In Colab

Recall 0.154 0.242 57.1%

All metrics were evaluated for k@20 after training for 5 epochs using the Adam optimizer with learning rates of 1e-4 for ResNet, 1e-7 for CLIP and 1e-5 for the BERT models, 5e-4 for PointNet++

Install

Make sure you have Python 3.8+ installed. Finetuner can be installed via pip by executing:

pip install -U finetuner

If you want to submit a fine-tuning job on the cloud, please use

pip install "finetuner[full]"

⚠️ Starting with version 0.5.0, Finetuner computing is performed on Jina AI Cloud. The last local version is 0.4.1. This version is still available for installation via pip. See Finetuner git tags and releases.

Articles about Finetuner

Check out our published blogposts and tutorials to see Finetuner in action!

If you find Jina Embeddings useful in your research, please cite the following paper:

@misc{günther2023jina,
      title={Jina Embeddings: A Novel Set of High-Performance Sentence Embedding Models}, 
      author={Michael Günther and Louis Milliken and Jonathan Geuter and Georgios Mastrapas and Bo Wang and Han Xiao},
      year={2023},
      eprint={2307.11224},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Support

Join Us

Finetuner is backed by Jina AI and licensed under Apache-2.0.

We are actively hiring AI engineers and solution engineers to build the next generation of open-source AI ecosystems.

finetuner's People

Contributors

alexcg1 avatar azayz avatar bwanglzu avatar catstark avatar deepankarm avatar florian-hoenicke avatar gmastrapas avatar guenthermi avatar gvondulong avatar hanxiao avatar j-geuter avatar jemmyshin avatar jina-bot avatar jupyterjazz avatar lmmilliken avatar makram93 avatar mapleeit avatar maximilianwerk avatar nan-wang avatar nomagick avatar numb3r3 avatar roshanjossey avatar scott-martens avatar shazhou2015 avatar shubhamsaboo avatar slettner avatar tadejsv avatar violenil avatar winstonww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finetuner's Issues

Tailor vision transformer (DINO)

Hi there!
I am trying to tailor a vision transformer (DINO) adding a projection layer on top of the whole transformer arquitecture.

When I run finetuner.tailor.to_embedding_model(model,output_dim=100, input_size=(3, 224, 224)) I get the following error.

image

I get the model from vits8 = torch.hub.load('facebookresearch/dino:main', 'dino_vits8')

code snippet to reproduce error

import torch
import finetuner

vits8 = torch.hub.load('facebookresearch/dino:main', 'dino_vits8')

finetuner.tailor.to_embedding_model(vits8,output_dim=100, input_size=(3, 224, 224))

UI: Integration test

Use labeler UI to mimic user interactions, make sure that it's working end-to-end.

This will give us more confidence that the changes we make doesn't break existing functionality.

I'm thinking about using https://www.cypress.io/ for this.

UI: Make keyboard shortcuts configurable.

We have shortcuts for selecting matches (0 - 9), inverting selection (i), submitting changes (space)

It'd be good to make this configurable.

It would be something like configuration changes we see in games
image

The difference I want to make in UI is to use the UI itself rather than text. I'll paste a mockup later

Allow specifying distance

There is no reason we should bind euclidian distance to TripletLayer and cosine to CosineLayer - there should be a parameter in the fit() function to allow setting the distance function to use

Labeler only allows to label all the data once

Currently the labeler does the following:

            let end_idx = app.labeler_config.start_idx + (app.labeler_config.example_per_view - app.cur_batch.length)
            if (end_idx === app.labeler_config.start_idx) {
                return
            }
            let start_idx = app.labeler_config.start_idx
            app.labeler_config.start_idx = end_idx

Thus, when I only have 2 queries but a bigger catalog, I only get labelable data once.

In my opinion, the choosing of new data should be done in the backend and not in the frontend.

tailor: unify all test models

  1. unify all test models, make sure the model as exactly the same structure, including dense, simple_cnn, vgg and lstm, add bert to test models.
  2. more robust test on lstm.
  3. given the same test models produced by 1, make sure three tailors produce exactly the same output model.

Customize interactive labeler

Currently interactive labeler only support Image and Text, is there some kind of middle layer API or similar so that I can modify to allow Audio interactive labeling?

I want to label similar speaker based on audio clip.

Thanks

Allow modifying optimizer parameters

At the very least, learning rate should be customizable.

We should also consider supporting multiple optimizers, e.g. Adam (which should be the default, as it is the most commonly used one), AdamW (used for transformers) and SGD, and setting their parameters.

Best way to do this is not clear - either we have some selection of optimizers that users can choose from, and we implement it in all frameworks, or we allow passing the optimizer object.

minor issues observed using labeler

  1. working should log as loading data at very first stage.
  2. epochs is not passed into the front-end
  3. when user using labeler and mime_type starts with img/, i expect finetuner automatically fill the datauri/do the conversion.
  4. not sure after some manual label work how to save the tuned model.
  5. sometimes labeler hangs, after a while looks as below:

6293118D-20D4-4CCE-AC53-A8DE9666463B

Add save button

Add a save button to the frontend and enable the saving of the model via the Flow.

Provide .plot() function that leverages mermaid as in Core

Provide a .plot() function that leverages mermaid.js and keras.summary , paddle.summary , torchinfor.summary (pytorch has no native summary function, this is 3rd party; inspired by it we have already reimplemented our own similar thing in tailor). This will provide the same look & feel as in Jina Core.

Error when using `fit(interactive=False)`

This example (adapted from documentation) will crash

import torch

import finetuner
from finetuner.toydata import generate_fashion_match

embed_model = torch.nn.Sequential(
    torch.nn.Flatten(),
    torch.nn.Linear(
        in_features=28 * 28,
        out_features=128,
    ),
    torch.nn.ReLU(),
    torch.nn.Linear(in_features=128, out_features=32),
)

finetuner.fit(embed_model, train_data=generate_fashion_match, interactive=False)
Traceback (most recent call last):
  File "/home/tadej/projects/finetuner/test.py", line 16, in <module>
    finetuner.fit(embed_model, train_data=generate_fashion_match, interactive=False)
  File "/home/tadej/projects/finetuner/finetuner/__init__.py", line 66, in fit
    return fit(*args, **kwargs)
TypeError: fit() got an unexpected keyword argument 'interactive'

This is because of this

else:
from .tuner.fit import fit
return fit(*args, **kwargs)

here interactive should be removed. Will create a PR

Tagging of specific class based on seed instance.

Say I want to quickly label many examples of a single class. Is there a way I can use a seed example of that class and use a combination of the nearest neighbour technique and my input to quickly label several 100?

add docstrings

We have very few docstrings right now - would be good to have more

  • Tuner
  • Tailor
  • Labeler
  • Helper

Refactor Pipeline

Refactor Pipeline as suggested in Tadej slides

below new refers to dataset without tuples/triplets, old refers to user manually creates tuples/triplets

  • refactor Dataset, support new and old style dataset. - @tadejsv
  • add sampler, take N items as batch from Dataset. - @tadejsv
  • adjust get embedding (use model extract embeddings from batch of data given by sampler). - @tadejsv
  • add miner, create pairs/triplets given batch of embeddings and labels. @bwanglzu
  • adjust loss functions. - @bwanglzu
  • transformer based text pre-processing support

we start from pytorch, then go to paddle and keras, finish by making abstraction classes.

UI: Refactor matches elements to separate vue components

Currently, we have image and text matches tables.

If we want to extend this to more mimetypes, we should make sure that it doesn't get hard to maintain the HTML file as a whole. Refactoring out components for them could be a good way to simplify it.

Evaluation functions

Have an evaluation function with the following interface

def get_evaluation(queries: DocumentSequence, catalog: Union[DocumentArray, DocumentArrayMemmap], model: AnyDNN, metrics: List[str] = None):

where

  • queries are the to-be-scored Documents with either positive results as matches or class informations,
  • catalog are the potential results,
  • model is any model and
  • metrics the names of the metrics, where None means all.

The evaluation function should compute the embeddings and compute/output requested metrics.

Furthermore, we should have a demo evaluation for the FMNIST dataset as an integration test (potentially sub-sampled for faster execution).

full finetuner use experience on celeba dataset

  1. use celeba dataset
  2. use ResNet as base model
  3. use labeler to add new dataset to see if results being improve at every batch.
  4. user experience (such as given different input size, the front-end shows correctly, training time , loss decrease, train accuracy improve etc).

Create Evaluation Example

We want an evaluation pipeline, that measures the quality

  • independent of current building blocks
  • input: model, data, potentially catalog
  • output some evaluation metric like NDCG, MRR
  • accompanied by a dataset (e.g. totally looky like, CELEBA)
  • give the tuner 5/10/15 minutes

refactor(tailor): make sure summary and module names are aligned

currently the implementation for paddle and pytorch is error-prone, we get names from model and we apply hooks to modules, and we zip(names, summary based on the assumption that they should be identical.

a better choice is rename module in the hook directly.

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.