Update README.md
Browse files
README.md
CHANGED
@@ -6,6 +6,9 @@ tags:
|
|
6 |
- sentence-similarity
|
7 |
datasets:
|
8 |
- biu-nlp/abstract-sim
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
A model for mapping abstract sentence descriptions to sentences that fit the descriptions. Trained on Wikipedia. Use ```load_finetuned_model``` to load the query and sentence encoder, and ```encode_batch()``` to encode a sentence with the model.
|
@@ -14,6 +17,7 @@ A model for mapping abstract sentence descriptions to sentences that fit the des
|
|
14 |
|
15 |
from transformers import AutoTokenizer, AutoModel
|
16 |
import torch
|
|
|
17 |
|
18 |
def load_finetuned_model():
|
19 |
|
@@ -25,7 +29,7 @@ def load_finetuned_model():
|
|
25 |
return tokenizer, query_encoder, sentence_encoder
|
26 |
|
27 |
|
28 |
-
def encode_batch(model, tokenizer, sentences, device):
|
29 |
input_ids = tokenizer(sentences, padding=True, max_length=512, truncation=True, return_tensors="pt",
|
30 |
add_special_tokens=True).to(device)
|
31 |
features = model(**input_ids)[0]
|
|
|
6 |
- sentence-similarity
|
7 |
datasets:
|
8 |
- biu-nlp/abstract-sim
|
9 |
+
widgets:
|
10 |
+
- sentence-similarity
|
11 |
+
- feature-extraction
|
12 |
---
|
13 |
|
14 |
A model for mapping abstract sentence descriptions to sentences that fit the descriptions. Trained on Wikipedia. Use ```load_finetuned_model``` to load the query and sentence encoder, and ```encode_batch()``` to encode a sentence with the model.
|
|
|
17 |
|
18 |
from transformers import AutoTokenizer, AutoModel
|
19 |
import torch
|
20 |
+
from typing import List
|
21 |
|
22 |
def load_finetuned_model():
|
23 |
|
|
|
29 |
return tokenizer, query_encoder, sentence_encoder
|
30 |
|
31 |
|
32 |
+
def encode_batch(model, tokenizer, sentences: List[str], device: str):
|
33 |
input_ids = tokenizer(sentences, padding=True, max_length=512, truncation=True, return_tensors="pt",
|
34 |
add_special_tokens=True).to(device)
|
35 |
features = model(**input_ids)[0]
|