File size: 724 Bytes
a6bbf63
0c746c9
 
 
a6bbf63
 
 
 
 
0c746c9
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import TextClassificationPipeline
from utils.commons import setup_logging

logger = setup_logging("pipeline_preparer.log")

class PipelinePreparer:
    @staticmethod
    def prepare_pipeline(tokenizer, model):
        """Create text classification pipeline"""
        try:
            logger.info("Preparing text classification pipeline...")
            pipeline = TextClassificationPipeline(
                tokenizer=tokenizer,
                model=model,
                return_all_scores=True
            )
            logger.info("Pipeline prepared successfully.")
            return pipeline
        except Exception as e:
            logger.error(f"Error preparing pipeline: {e}")
            raise