osanseviero
commited on
Commit
•
c044e77
1
Parent(s):
2914602
Add fasttext model
Browse files- README.md +17 -0
- cc.en.300.bin +3 -0
- pipeline.py +18 -0
- requirements.txt +1 -0
README.md
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- feature-extraction
|
4 |
+
library_name: generic
|
5 |
+
---
|
6 |
+
|
7 |
+
# Pretrained FastText word vector for English
|
8 |
+
|
9 |
+
https://github.com/facebookresearch/fastText
|
10 |
+
|
11 |
+
Usage
|
12 |
+
|
13 |
+
```
|
14 |
+
import fasttext.util
|
15 |
+
ft = fasttext.load_model('cc.en.300.bin')
|
16 |
+
ft.get_word_vector('hello')
|
17 |
+
```
|
cc.en.300.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:14c7167b130056944cbdc37b7451f055867fe9a4e3fed3bbc1ecc0e74f6763ca
|
3 |
+
size 7237176312
|
pipeline.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fasttext.util
|
2 |
+
|
3 |
+
class PreTrainedPipeline():
|
4 |
+
def __init__(self, path=""):
|
5 |
+
"""
|
6 |
+
Initialize model
|
7 |
+
"""
|
8 |
+
self.model = fasttext.load_model(os.path.join(path, 'cc.en.300.bin'))
|
9 |
+
|
10 |
+
def __call__(self, inputs: str) -> List[float]:
|
11 |
+
"""
|
12 |
+
Args:
|
13 |
+
inputs (:obj:`str`):
|
14 |
+
a string to get the features of.
|
15 |
+
Return:
|
16 |
+
A :obj:`list` of floats: The features computed by the model.
|
17 |
+
"""
|
18 |
+
return self.model.get_sentence_vector(inputs)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fasttext===0.9.2
|