Skip to content

Commit

Permalink
black and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelFay committed Aug 21, 2024
1 parent 1497772 commit c5d573c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 29 deletions.
4 changes: 3 additions & 1 deletion colpali_engine/dataset/hard_neg_collator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from random import randint

from datasets import Dataset, DatasetDict
from transformers import PreTrainedTokenizer, ProcessorMixin
from random import randint

from .custom_collator import CustomCollator


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

from colpali_engine.interpretability.plot_utils import plot_patches
from colpali_engine.interpretability.processor import ColPaliProcessor
from colpali_engine.interpretability.torch_utils import \
normalize_attention_map_per_query_token
from colpali_engine.interpretability.torch_utils import normalize_attention_map_per_query_token
from colpali_engine.interpretability.vit_configs import VIT_CONFIG
from colpali_engine.models.paligemma_colbert_architecture import ColPali

Expand Down
14 changes: 10 additions & 4 deletions colpali_engine/models/colbert_architectures.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from torch import nn
from transformers import (BertModel, BertPreTrainedModel, CamembertModel,
CamembertPreTrainedModel, LlamaModel,
LlamaPreTrainedModel, XLMRobertaModel,
XLMRobertaPreTrainedModel)
from transformers import (
BertModel,
BertPreTrainedModel,
CamembertModel,
CamembertPreTrainedModel,
LlamaModel,
LlamaPreTrainedModel,
XLMRobertaModel,
XLMRobertaPreTrainedModel,
)


class ColCamembert(CamembertPreTrainedModel):
Expand Down
3 changes: 1 addition & 2 deletions colpali_engine/models/paligemma_colbert_architecture.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch
from torch import nn
from transformers.models.paligemma.modeling_paligemma import (
PaliGemmaForConditionalGeneration, PaliGemmaPreTrainedModel)
from transformers.models.paligemma.modeling_paligemma import PaliGemmaForConditionalGeneration, PaliGemmaPreTrainedModel


class BiPaliLast(PaliGemmaPreTrainedModel):
Expand Down
17 changes: 9 additions & 8 deletions colpali_engine/utils/train_colpali_engine_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
from torch.utils.data import DataLoader
from tqdm import tqdm
from transformers import (AutoTokenizer, Idefics2Processor, PreTrainedModel,
PreTrainedTokenizer, TrainingArguments)
from transformers import AutoTokenizer, Idefics2Processor, PreTrainedModel, PreTrainedTokenizer, TrainingArguments

from colpali_engine.dataset.custom_collator import CustomCollator
from colpali_engine.dataset.hard_neg_collator import HardNegCollator
from colpali_engine.loss.colbert_loss import (BiEncoderLoss, BiPairwiseCELoss,
ColbertLoss,
ColbertPairwiseCELoss,
ColbertPairwiseNegativeCELoss)
from colpali_engine.trainer.contrastive_trainer import (
ContrastiveNegativeTrainer, ContrastiveTrainer)
from colpali_engine.loss.colbert_loss import (
BiEncoderLoss,
BiPairwiseCELoss,
ColbertLoss,
ColbertPairwiseCELoss,
ColbertPairwiseNegativeCELoss,
)
from colpali_engine.trainer.contrastive_trainer import ContrastiveNegativeTrainer, ContrastiveTrainer
from colpali_engine.trainer.retrieval_evaluator import CustomEvaluator
from colpali_engine.utils.gpu_stats import print_gpu_utilization, print_summary

Expand Down
27 changes: 16 additions & 11 deletions colpali_engine/utils/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import importlib

from colpali_engine.models.clip_baselines import ColSigLIP, SigLIP
from colpali_engine.models.colbert_architectures import (BiBERT, BiXLMRoBERTa,
ColBERT, ColCamembert,
ColLlama,
ColXLMRoBERTa)
from colpali_engine.models.idefics_colbert_architecture import (BiIdefics,
ColIdefics)
from colpali_engine.models.paligemma_colbert_architecture import (BiNewSiglip,
BiPaliLast,
BiPaliMean,
ColNewSiglip,
ColPali)
from colpali_engine.models.colbert_architectures import (
BiBERT,
BiXLMRoBERTa,
ColBERT,
ColCamembert,
ColLlama,
ColXLMRoBERTa,
)
from colpali_engine.models.idefics_colbert_architecture import BiIdefics, ColIdefics
from colpali_engine.models.paligemma_colbert_architecture import (
BiNewSiglip,
BiPaliLast,
BiPaliMean,
ColNewSiglip,
ColPali,
)

if importlib.util.find_spec("transformers") is not None:
from transformers import AutoProcessor, AutoTokenizer
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = 'colpali_engine'
# dynamic = ["version"]
version = '0.0.1'
version = '0.1.0'
description = 'This repository centralizes ressources for the ColPali project.'
authors = [
{ name = 'Manuel Faysse', email = '[email protected]' },
Expand Down

0 comments on commit c5d573c

Please sign in to comment.