File size: 794 Bytes
6c945f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# -*-coding:utf-8 -*-
from langchain.vectorstores import FAISS
from langchain.embeddings import HuggingFaceEmbeddings, CohereEmbeddings
from key import CoherenceKey
## MPNET
model = HuggingFaceEmbeddings()
db = FAISS.load_local('./output/半导体', model)
docs = db.similarity_search('东吴证券观点')
print(docs[0].page_content)
docs = db.similarity_search('德邦证券')
print(docs[0].page_content)
## Coherence
model = CohereEmbeddings(cohere_api_key=CoherenceKey)
db = FAISS.load_local('./output/半导体', model)
docs = db.similarity_search('半导体指数行情')
print(docs[0].page_content)
docs = db.similarity_search('关于行业光刻胶相关新闻')
print(docs[0].page_content)
docs = db.similarity_search('2023年GDP增速预测')
print(docs[0].page_content)
|