collection_name
in Qdrant, as used in LlamaIndex, refers to the name of the Qdrant collection where embeddings and documents are stored. This parameter is used in both the QdrantVectorStore
and QdrantReader
classes in LlamaIndex.QdrantVectorStore
class, the collection_name
is a required parameter that specifies the name of the Qdrant collection where the vector store will store its embeddings and documents. During query time, the index uses Qdrant to query for the top k most similar nodes in this collection. source ()QdrantReader
class, the collection_name
is a parameter in the load_data
method, which is used to specify the Qdrant collection from which to load data. source ()collection_name
is used in code:vector_store = QdrantVectorStore(client=client, collection_name="paul_graham")
QdrantVectorStore
is being created with the collection_name
set to "paul_graham". This means that the vector store will store its embeddings and documents in the Qdrant collection named "paul_graham"..persist()
method of the StorageContext
associated with your index. This method writes all the data to disk at the location specified. Here's an example:index.storage_context.persist(persist_dir="<persist_dir>")
<persist_dir>
is the directory where you want to store your data. If you don't specify a directory, the data will be stored in a directory named ./storage
by default (source ()).load_index_from_storage
function from the llama_index
module. Here's an example:from llama_index import StorageContext, load_index_from_storage # rebuild storage context storage_context = StorageContext.from_defaults(persist_dir="<persist_dir>") # load index index = load_index_from_storage(storage_context)
<persist_dir>
is the directory where you stored your data. The load_index_from_storage
function will load the index from this directory, and you can then use this index for querying (source ()).``
In this example, you can replace
"data" with the path to your data, and
./storage` with the path to the directory where you want to store your data (source ()).import os from llama_index import ( VectorStoreIndex, SimpleDirectoryReader, StorageContext, load_index_from_storage, ) # Define your data directory and persist directory DATA_DIR = "<path_to_your_data>" PERSIST_DIR = "<path_to_your_persist_directory>" # Check if storage already exists if not os.path.exists(PERSIST_DIR): # Load the documents and create the index documents = SimpleDirectoryReader(DATA_DIR).load_data() index = VectorStoreIndex.from_documents(documents) # Store it for later index.storage_context.persist(persist_dir=PERSIST_DIR) else: # Load the existing index storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR) index = load_index_from_storage(storage_context) # Now you can use the index for querying response = index.query("What did the author do growing up?") print(response)
<path_to_your_data>
with the path to your data and <path_to_your_persist_directory>
with the path to the directory where you want to store your data. This script will check if the storage already exists. If it does, it will load the existing index. If it doesn't, it will load the documents from your data directory, create a new index, and store it in the persist directory. After that, you can use the index for querying.