Last active
November 24, 2023 10:44
-
-
Save khaerulumam42/241712c67534ed632ff355c8e4ed5b7c to your computer and use it in GitHub Desktop.
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
from langchain.vectorstores.pgvector import PGVector, DistanceStrategy | |
from langchain.embeddings import HuggingFaceEmbeddings | |
model = 'bert-base-uncased' | |
embedding_model = HuggingFaceEmbeddings(model_name=model) | |
COLLECTION_NAME = 'top_10_dataset' | |
CONNECTION_STRING = PGVector.connection_string_from_db_params( | |
driver='psycopg2', | |
host=os.environ.get('PGVECTOR_HOST'), | |
port=int(os.environ.get('PGVECTOR_PORT')), | |
database=os.environ.get('PGVECTOR_DATABASE'), | |
user=os.environ.get('PGVECTOR_USER'), | |
password=os.environ.get('PGVECTOR_PASSWORD'), | |
) | |
pgvector = PGVector( | |
collection_name=COLLECTION_NAME, | |
embedding=embedding_model, | |
connection_string=CONNECTION_STRING, | |
distance_strategy=DistanceStrategy.COSINE | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment