Vector Store Utilities¶
- Code for loading data into the vector store.
What to look for¶
DataLoader
: If you want to modify chunkingDocumentProcessor
: If you want to modify how the unique documents are obtained and/or add other methodsVectorStoreManager
: If you want to modify how the documents are embedded and loaded to the vector store
DataLoader
¶
Description: Used to chunk data
Source code in backend/modules/vector_store_utils.py
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 |
|
load_and_process_data()
¶
Description: Recursively chunk data before embedding
Source code in backend/modules/vector_store_utils.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
DocumentProcessor
¶
Description: Used to generate unique documents based on text content to prevent duplicates during embedding
Source code in backend/modules/vector_store_utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
generate_unique_documents(documents, db)
staticmethod
¶
Description: Sometimes the text content of the data is the same, this ensures that does not happen by computing a string matching
Source code in backend/modules/vector_store_utils.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
VectorStoreManager
¶
Description: Manages the Vector store (chromadb) and takes care of data ingestion, loading the embedding model and embedding the data before adding it to the vector store
Source code in backend/modules/vector_store_utils.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
add_df_chunks_to_db(metadata_df)
¶
Description: Add chunks from a dataframe for use with chroma metadata saving
Source code in backend/modules/vector_store_utils.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
add_documents_to_db(db, unique_docs, unique_ids, bs=512)
staticmethod
¶
Description: Add documents to Chroma DB in batches of bs
Source code in backend/modules/vector_store_utils.py
158 159 160 161 162 163 164 165 166 167 |
|
chunk_dataframe(df, chunk_size)
¶
Description: Chunk dataframe for use with chroma metadata saving
Source code in backend/modules/vector_store_utils.py
93 94 95 96 97 98 |
|
create_vector_store(metadata_df)
¶
Description: Load embeddings, get chunked data, subset if needed , find unique, and then finally add to ChromaDB
Source code in backend/modules/vector_store_utils.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
get_collection_name()
¶
Description: Fixes some collection names. (workaround from OpenML API)
Source code in backend/modules/vector_store_utils.py
132 133 134 135 136 137 138 |
|
load_model()
¶
Description: Load a model from Hugging face for embedding
Source code in backend/modules/vector_store_utils.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
load_vector_store(embeddings, collection_name)
¶
Description: Persist directory. If does not exist, cannot be served
Source code in backend/modules/vector_store_utils.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|