Commit 
							
							·
						
						bd03818
	
1
								Parent(s):
							
							7dcee0c
								
Update README.md
Browse files
    	
        README.md
    CHANGED
    
    | 
         @@ -1,3 +1,62 @@ 
     | 
|
| 1 | 
         
             
            ---
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 2 | 
         
             
            license: mit
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 3 | 
         
             
            ---
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
             
            ---
         
     | 
| 2 | 
         
            +
            language: 
         
     | 
| 3 | 
         
            +
              - en
         
     | 
| 4 | 
         
            +
             
     | 
| 5 | 
         
            +
            tags:
         
     | 
| 6 | 
         
            +
            - pytorch
         
     | 
| 7 | 
         
            +
            - ner
         
     | 
| 8 | 
         
            +
            - text generation
         
     | 
| 9 | 
         
            +
            - seq2seq
         
     | 
| 10 | 
         
            +
             
     | 
| 11 | 
         
            +
            inference: false
         
     | 
| 12 | 
         
            +
             
     | 
| 13 | 
         
             
            license: mit
         
     | 
| 14 | 
         
            +
             
     | 
| 15 | 
         
            +
            datasets:
         
     | 
| 16 | 
         
            +
            - conll2003
         
     | 
| 17 | 
         
            +
             
     | 
| 18 | 
         
            +
            metrics:
         
     | 
| 19 | 
         
            +
            - f1
         
     | 
| 20 | 
         
             
            ---
         
     | 
| 21 | 
         
            +
            # t5-base-qa-ner-conll
         
     | 
| 22 | 
         
            +
             
     | 
| 23 | 
         
            +
            Unofficial implementation of [InstructionNER](https://arxiv.org/pdf/2203.03903v1.pdf).
         
     | 
| 24 | 
         
            +
            t5-base model tuned on conll2003 dataset.
         
     | 
| 25 | 
         
            +
             
     | 
| 26 | 
         
            +
            https://github.com/ovbystrova/InstructionNER 
         
     | 
| 27 | 
         
            +
             
     | 
| 28 | 
         
            +
            ## Inference 
         
     | 
| 29 | 
         
            +
            ```shell
         
     | 
| 30 | 
         
            +
            git clone https://github.com/ovbystrova/InstructionNER 
         
     | 
| 31 | 
         
            +
            cd InstructionNER
         
     | 
| 32 | 
         
            +
            ```
         
     | 
| 33 | 
         
            +
             
     | 
| 34 | 
         
            +
            ```python
         
     | 
| 35 | 
         
            +
            from instruction_ner.model import Model
         
     | 
| 36 | 
         
            +
             
     | 
| 37 | 
         
            +
            model = Model(
         
     | 
| 38 | 
         
            +
                model_path_or_name="olgaduchovny/t5-base-ner-mit-restaurant",
         
     | 
| 39 | 
         
            +
                tokenizer_path_or_name="olgaduchovny/t5-base-mit-restaurant"
         
     | 
| 40 | 
         
            +
            )
         
     | 
| 41 | 
         
            +
             
     | 
| 42 | 
         
            +
            options = ["LOC", "PER", "ORG", "MISC"]
         
     | 
| 43 | 
         
            +
             
     | 
| 44 | 
         
            +
            instruction = "please extract entities and their types from the input sentence, " \
         
     | 
| 45 | 
         
            +
                          "all entity types are in options"
         
     | 
| 46 | 
         
            +
             
     | 
| 47 | 
         
            +
            text = "any asian cuisine around"
         
     | 
| 48 | 
         
            +
             
     | 
| 49 | 
         
            +
            generation_kwargs = {
         
     | 
| 50 | 
         
            +
                "num_beams": 2,
         
     | 
| 51 | 
         
            +
                "max_length": 128
         
     | 
| 52 | 
         
            +
            }
         
     | 
| 53 | 
         
            +
             
     | 
| 54 | 
         
            +
            pred_spans = model.predict(
         
     | 
| 55 | 
         
            +
                text=text,
         
     | 
| 56 | 
         
            +
                generation_kwargs=generation_kwargs,
         
     | 
| 57 | 
         
            +
                instruction=instruction,
         
     | 
| 58 | 
         
            +
                options=options
         
     | 
| 59 | 
         
            +
            )
         
     | 
| 60 | 
         
            +
             
     | 
| 61 | 
         
            +
            >>> [(4, 9, 'Cuisine'), (18, 24, 'Location')]
         
     | 
| 62 | 
         
            +
            ```
         
     |