Dmitry Chaplinsky commited on
Commit
53a9a92
1 Parent(s): f49bb16

Another try to deploy

Browse files
Files changed (1) hide show
  1. pipeline.py +5 -4
pipeline.py CHANGED
@@ -1,4 +1,4 @@
1
- import gensim
2
  from typing import List, Dict
3
 
4
 
@@ -6,8 +6,9 @@ class PreTrainedPipeline:
6
  def __init__(self, path=""):
7
  from huggingface_hub import hf_hub_download
8
 
9
- self.model = gensim.models.Word2Vec.load(
10
- hf_hub_download(repo_id="lang-uk/word2vec-uk", filename="ubercorpus.cased.tokenized.300d")
 
11
  )
12
 
13
  def __call__(self, inputs: str) -> List[Dict]:
@@ -19,4 +20,4 @@ class PreTrainedPipeline:
19
  A :obj:`str`
20
  """
21
  inputs = inputs.strip()
22
- return [{"generated_text": str(self.model.wv.most_similar(inputs))}]
 
1
+ from gensim.models import KeyedVectors
2
  from typing import List, Dict
3
 
4
 
 
6
  def __init__(self, path=""):
7
  from huggingface_hub import hf_hub_download
8
 
9
+ self.model = KeyedVectors.load_word2vec_format(
10
+ hf_hub_download(repo_id="lang-uk/word2vec-uk", filename="ubercorpus.cased.tokenized.300d"),
11
+ binary=False
12
  )
13
 
14
  def __call__(self, inputs: str) -> List[Dict]:
 
20
  A :obj:`str`
21
  """
22
  inputs = inputs.strip()
23
+ return [{"generated_text": str(self.model.most_similar(inputs, topn=30))}]