mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: jina-colbert-v2 reranker fails to load and turns hybrid search off (#31532)
Choosing jinaai/jina-colbert-v2 as the reranking model failed on the current transformers release with "'HF_ColBERT' object has no attribute 'all_tied_weights_keys'", and saving the Documents settings quietly switched hybrid search back off. The ColBERT reranker now finishes loading, reranks search results and hybrid search stays on after saving. Fixes #31522
This commit is contained in:
parent
e5b57540f6
commit
bee06b08ba
1 changed files with 17 additions and 0 deletions
|
|
@ -4,12 +4,29 @@ import os
|
|||
import numpy as np
|
||||
import torch
|
||||
from colbert.infra import ColBERTConfig
|
||||
from colbert.modeling import base_colbert, hf_colbert
|
||||
from colbert.modeling.checkpoint import Checkpoint
|
||||
from open_webui.retrieval.models.base_reranker import BaseReranker
|
||||
from transformers import PretrainedConfig
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def class_factory(name_or_path: str) -> type:
|
||||
hf_colbert_class = hf_colbert.class_factory(name_or_path)
|
||||
|
||||
# colbert-ai never calls post_init, which transformers 5 needs to finish setting up the model
|
||||
class HF_ColBERT(hf_colbert_class):
|
||||
def __init__(self, config: PretrainedConfig, colbert_config: ColBERTConfig) -> None:
|
||||
super().__init__(config, colbert_config)
|
||||
self.post_init()
|
||||
|
||||
return HF_ColBERT
|
||||
|
||||
|
||||
base_colbert.class_factory = class_factory
|
||||
|
||||
|
||||
class ColBERT(BaseReranker):
|
||||
def __init__(self, name, **kwargs) -> None:
|
||||
log.info('ColBERT: Loading model %s', name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue