Repository: flairNLP/flair

Issue:
nl-ner model gives AttributeError: 'CharLMEmbeddings' object has no attribute 'chars_per_chunk'
**Describe the bug**

When I try to tag a sentence with the `nl-ner` model, I get the following error message: `AttributeError: 'CharLMEmbeddings' object has no attribute 'chars_per_chunk'`

```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-38968e7669bc> in <module>
      5 
      6 # predict NER tags
----> 7 tagger.predict(sentence)
      8 
      9 # print sentence with predicted tags

~/code/flair/flair/models/sequence_tagger_model.py in predict(self, sentences, mini_batch_size, embedding_storage_mode, all_tag_prob, verbose, use_tokenizer)
    331                     continue
    332 
--> 333                 feature: torch.Tensor = self.forward(batch)
    334                 tags, all_tags = self._obtain_labels(
    335                     feature=feature,

~/code/flair/flair/models/sequence_tagger_model.py in forward(self, sentences)
    471     def forward(self, sentences: List[Sentence]):
    472 
--> 473         self.embeddings.embed(sentences)
    474 
    475         lengths: List[int] = [len(sentence.tokens) for sentence in sentences]

~/code/flair/flair/embeddings.py in embed(self, sentences, static_embeddings)
    175 
    176         for embedding in self.embeddings:
--> 177             embedding.embed(sentences)
    178 
    179     @property

~/code/flair/flair/embeddings.py in embed(self, sentences)
     94 
     95         if not everything_embedded or not self.static_embeddings:
---> 96             self._add_embeddings_internal(sentences)
     97 
     98         return sentences

~/code/flair/flair/embeddings.py in _add_embeddings_internal(self, sentences)
   2638         # get hidden states from language model
   2639         all_hidden_states_in_lm = self.lm.get_representation(
-> 2640             text_sentences, start_marker, end_marker, self.chars_per_chunk
   2641         )
   2642 

~/anaconda3/envs/flair/lib/python3.7/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
    574                 return modules[name]
    575         raise AttributeError("'{}' object has no attribute '{}'".format(
--> 576             type(self).__name__, name))
    577 
    578     def __setattr__(self, name, value):

AttributeError: 'CharLMEmbeddings' object has no attribute 'chars_per_chunk'
```

**To Reproduce**

```
from flair.models import SequenceTagger
from flair.data import Sentence

# load model
tagger = SequenceTagger.load('nl-ner')

# make Dutch sentence
sentence = Sentence('George Washington ging naar Washington .')

# predict NER tags
tagger.predict(sentence)
```

**Expected behavior**

No error when tagging a sentence.

**Environment (please complete the following information):**
 - OS [e.g. iOS, Linux]: Mac 10.15.2
 - Version [e.g. flair-0.3.2]: 0.4.4

**Additional context**

I installed flair from #1360, because otherwise I couldn't load the model using torch 1.4.0 

Searching the issues, I found #974, which might be related.



Discussion:
Hi @jvdzwaan , thanks for your report.
I fixed this bug, this bug is because of using the deprecated `CharLMEmbeddings`.
I think it will be removed in the future, So I will not push here.
You can install from [my repository](https://github.com/eurekaqq/flair/tree/fixed_deprecated_model_bug)
Thank you, that does solve the problem!

I'm just wondering why you don't push the change. What will be removed in the future? I hope it isn't the Dutch ner model...
These old models trained by class `CharLMEmbeddings` will be remove in the futrue and retrain it by class `FlairEmbeddings`.
So I do not think the CharLMEmbeddings bug needed to be pushed.
OK, I understand. Thank you for your reply!
Hello, I'm experiencing the same bug. Even after doing

`!pip install git+https://github.com/eurekaqq/flair.git ` in Google Colab, the following results in the same bug:

```
from flair.models import SequenceTagger
from flair.data import Sentence
        
# load model
tagger = SequenceTagger.load('nl-ner')

# make Dutch sentence
sentence = Sentence('George Washington ging naar Washington .')

# predict NER tagstagger.predict(sentence)
```

Am I importing the library from the Github repository in the wrong way?
Hi @NielsRogge , you can try to use 
`!pip install git+https://github.com/eurekaqq/flair.git@fixed_deprecated_model_bug` to install fixed flair.

Ok thank you, this works.
Is there any idea if this problem is going to be solved anytime soon in the master version?
Hi @stefanievonk - I'll upload some new models for Dutch shortly.

Resolving patch:
diff --git a/flair/models/sequence_tagger_model.py b/flair/models/sequence_tagger_model.py
--- a/flair/models/sequence_tagger_model.py
+++ b/flair/models/sequence_tagger_model.py
@@ -1128,7 +1128,10 @@ def _fetch_model(model_name) -> str:
             [aws_resource_path_v04, "release-fr-ner-0", "fr-ner-wikiner-0.4.pt"]
         )
         model_map["nl-ner"] = "/".join(
-            [aws_resource_path_v04, "NER-conll2002-dutch", "nl-ner-conll02-v0.1.pt"]
+            [hu_path, "dutch-ner_0", "nl-ner-bert-conll02-v0.5.pt"]
+        )
+        model_map["nl-ner-rnn"] = "/".join(
+            [hu_path, "dutch-ner-flair-0", "nl-ner-conll02-v0.5.pt"]
         )
         model_map["ml-pos"] = "https://raw.githubusercontent.com/qburst/models-repository/master/FlairMalayalamModels/malayalam-xpos-model.pt"
         model_map["ml-upos"] = "https://raw.githubusercontent.com/qburst/models-repository/master/FlairMalayalamModels/malayalam-upos-model.pt"


Test patch: