-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/sod_bgee_integration' into relea…
…se/515 # Conflicts: # nlu/universe/annotator_class_universe.py
- Loading branch information
Showing
11 changed files
with
1,227 additions
and
0 deletions.
There are no files selected for viewing
1,157 changes: 1,157 additions & 0 deletions
1,157
examples/colab/component_examples/sentence_embeddings/NLU_BGE_sentence_embeddings.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
nlu/components/embeddings/sentence_bge/BGESentenceEmbedding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sparknlp | ||
from sparknlp.annotator import BGEEmbeddings | ||
|
||
|
||
class BGE: | ||
@staticmethod | ||
def get_default_model(): | ||
return BGEEmbeddings.pretrained() \ | ||
.setInputCols(["document"]) \ | ||
.setOutputCol("bge_embeddings") | ||
sparknlp.start() | ||
@staticmethod | ||
def get_pretrained_model(name, language, bucket=None): | ||
return BGEEmbeddings.pretrained(name,language,bucket) \ | ||
.setInputCols(["document"]) \ | ||
.setOutputCol("bge_embeddings") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/nlu_core_tests/component_tests/embed_tests/sentence_embeddings/sentence_bge_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
|
||
from nlu import * | ||
|
||
|
||
class TestBGESentenceEmbeddings(unittest.TestCase): | ||
def test_bge_embeds(self): | ||
pipe = nlu.load("en.embed_sentence.bge_small", verbose=True) | ||
res = pipe.predict( | ||
"query: how much protein should a female eat", | ||
output_level="document" | ||
) | ||
for c in res: | ||
print(res[c]) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |