File size: 1,102 Bytes
40c3ade
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# %%

from utils import retrieve_collections, get_chroma_client


from load_model import load_embedding

#retrieve_collections()

client = get_chroma_client()

# %%
client.reset()
# %%
collections = tuple( [collection.name for collection in client.list_collections()] )  ##Keine Embedding function in der Collection angelegt...

ef = load_embedding("hkunlp/instructor-large")
collection="heikostest2"
client.create_collection(collection, embedding_function=ef, metadata={"loaded_docs":[]}) 


# %%
my_col = client.list_collections()

# %%
my_col.embedding_function

# %%
from langchain.vectorstores import Chroma
import load_model

from load_model import load_embedding

persist_directory = load_model.persist_directory

ef = load_embedding("hkunlp/instructor-large")
vectorstore = Chroma(
            collection_name="papers",
            embedding_function=ef,
            persist_directory=persist_directory,
        )

# %%
query = "What did the president say about Ketanji Brown Jackson"
docs = vectorstore.similarity_search(query)


# %% 
docs
# %%
vectorstore.similarity_search_with_score(query)