Upload 4 files
Browse files- README.md +3 -3
- exampleEmbed.py +7 -0
- params.txt +5 -0
- verifyResults.py +23 -0
README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 1 |
+
No claims are made about the copyright or license of contained materials. We assume no responsibilty for and are not liable under any circumstances for damages. Use at your own risk.
|
| 2 |
+
|
| 3 |
+
Good luck, have fun.
|
exampleEmbed.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from InstructorEmbedding import INSTRUCTOR
|
| 2 |
+
|
| 3 |
+
model = INSTRUCTOR('hkunlp/instructor-xl')
|
| 4 |
+
sentence = "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train."
|
| 5 |
+
instruction = "Represent the Research Paper abstract for retrieval; Input:"
|
| 6 |
+
embeddings = model.encode([[instruction,sentence]])
|
| 7 |
+
print(embeddings)
|
params.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
prompt: Represent the Research Paper abstract for retrieval; Input:
|
| 2 |
+
type: abstract
|
| 3 |
+
time string: 20230518-180240
|
| 4 |
+
model: InstructorXL
|
| 5 |
+
version: 2.0
|
verifyResults.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import glob
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def load_parquet(parquet_path):
|
| 8 |
+
return pd.read_parquet(parquet_path)
|
| 9 |
+
|
| 10 |
+
def print_parquet_data(data):
|
| 11 |
+
for _, row in data.iterrows():
|
| 12 |
+
print("Abstract:", row['abstract'])
|
| 13 |
+
print("Embedding:", row['embeddings'])
|
| 14 |
+
print("DOI:", row['doi'])
|
| 15 |
+
print()
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
print("Starting...")
|
| 19 |
+
directory_path = os.path.dirname(os.path.abspath(__file__))
|
| 20 |
+
for file_path in glob.glob(os.path.join(directory_path, 'abstracts_*.parquet')):
|
| 21 |
+
print("Loading and printing parquet file:", file_path)
|
| 22 |
+
data = load_parquet(file_path)
|
| 23 |
+
print_parquet_data(data)
|