o
    ॵiO	                     @   s   d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ d	gZejejejd
ejejejd
G dd	 d	eZdS )    )AnyDictOptionalUnionN)	Pipelines)Model)Pipeline)	PIPELINES)Preprocessor)	ModelFileTasksInformationExtractionPipeline)module_namec                	       s   e Zd Z					ddeeef dee dedef fd	d
Zde	ee
f de	ee
f fddZde	ee
f de	eef fddZ  ZS )r   NgpuT   modelpreprocessorconfig_filedevicec                    sf   t  j|||||d t| jtsJ dtj | jdu r,tj	| jj
fd|i|| _| j  dS )a  

        Args:
            model (str or Model): Supply either a local model dir which supported information extraction task, or a
            model id from the model hub, or a torch model instance.
            preprocessor (Preprocessor): An optional preprocessor instance, please make sure the preprocessor fits for
            the model if supplied.
            kwargs (dict, `optional`):
                Extra kwargs passed into the preprocessor's constructor.
        )r   r   r   r   auto_collatez,please check whether model config exists in Nsequence_length)super__init__
isinstancer   r   r   CONFIGURATIONr   r
   from_pretrained	model_direval)selfr   r   r   r   r   r   kwargs	__class__ l/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/nlp/information_extraction_pipeline.pyr      s&   

z&InformationExtractionPipeline.__init__inputsreturnc                 K   s@   t   | jdi ||W  d    S 1 sw   Y  d S )Nr"   )torchno_gradr   )r   r$   forward_paramsr"   r"   r#   forward:   s   
$z%InformationExtractionPipeline.forwardc                 K   s   |S )Nr"   )r   r$   postprocess_paramsr"   r"   r#   postprocess?   s   z)InformationExtractionPipeline.postprocess)NNr   Tr   )__name__
__module____qualname__r   r   strr   r
   r   r   r   r)   r+   __classcell__r"   r"   r    r#   r      s*    
#


)typingr   r   r   r   r&   modelscope.metainfor   modelscope.modelsr   modelscope.pipelines.baser   modelscope.pipelines.builderr	   modelscope.preprocessorsr
   modelscope.utils.constantr   r   __all__register_moduleinformation_extractionrelation_extractionr   r"   r"   r"   r#   <module>   s    