Qdrant Vector Store

Creating a Qdrant client

import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
import qdrant_client
client = qdrant_client.QdrantClient(
    # you can use :memory: mode for fast and light-weight experiments,
    # it does not require to have Qdrant deployed anywhere
    # but requires qdrant-client >= 1.1.1
    location=":memory:"

    # otherwise set Qdrant instance address with:
    # uri="http://<host>:<port>"

    # set API KEY for Qdrant Cloud
    # api_key="<qdrant-api-key>",
)

Load documents, build the GPTQdrantIndex

try:
    from llama_index import GPTQdrantIndex, SimpleDirectoryReader
except ImportError:
    from llama_index import GPTQdrantIndex, SimpleDirectoryReader

from IPython.display import Markdown, display
# load documents
documents = SimpleDirectoryReader('../paul_graham_essay/data').load_data()
index = GPTQdrantIndex.from_documents(documents, client=client, collection_name="paul_graham")
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
Token indices sequence length is longer than the specified maximum sequence length for this model (3383 > 1024). Running this sequence through the model will result in indexing errors
INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total LLM token usage: 0 tokens
> [build_index_from_nodes] Total LLM token usage: 0 tokens
INFO:llama_index.token_counter.token_counter:> [build_index_from_nodes] Total embedding token usage: 17617 tokens
> [build_index_from_nodes] Total embedding token usage: 17617 tokens

Query Index

# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do growing up?")
INFO:llama_index.token_counter.token_counter:> [query] Total LLM token usage: 4082 tokens
> [query] Total LLM token usage: 4082 tokens
INFO:llama_index.token_counter.token_counter:> [query] Total embedding token usage: 8 tokens
> [query] Total embedding token usage: 8 tokens
display(Markdown(f"<b>{response}</b>"))

The author grew up writing short stories, programming on an IBM 1401, and building a computer kit with a friend. They also wrote programs for a TRS-80 computer, such as games, a program to predict model rocket flight, and a word processor. In college, they studied philosophy and AI, and wrote a book about Lisp hacking. They also took art classes and applied to art schools, and while a student at the Accademia, they started painting still lives in their bedroom at night. These paintings were tiny, because the room was, and because they painted them on leftover scraps of canvas, which was all they could afford at the time. They also arrived at an arrangement with the faculty whereby the students wouldn’t require the faculty to teach anything, and in return the faculty wouldn’t require the students to learn anything. They even had a little stove, fed with kindling, that you see in 19th century studio paintings, and a nude model sitting as close to it as possible without getting burned. The author also painted the model, while the other students spent their time chatting or occasionally trying to imitate things they’d seen in American art magazines. The model turned out to live just down the street from the author, and made a living from a

# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine()
response = query_engine.query("What did the author do after his time at Y Combinator?")
INFO:llama_index.token_counter.token_counter:> [query] Total LLM token usage: 4066 tokens
> [query] Total LLM token usage: 4066 tokens
INFO:llama_index.token_counter.token_counter:> [query] Total embedding token usage: 14 tokens
> [query] Total embedding token usage: 14 tokens
display(Markdown(f"<b>{response}</b>"))

After his time at Y Combinator, the author continued to write essays and work on various projects. He wrote a book called Hackers & Painters, worked on spam filters, did some painting, and bought a building in Cambridge to use as an office. He also started Hacker News, a news aggregator for startup founders, and wrote all of Y Combinator’s internal software in Arc. He continued to work hard on Y Combinator, and even offered unsolicited advice to Robert Morris. After receiving advice from Robert Morris to make sure Y Combinator wasn’t the last cool thing he did, the author gradually realized that he should quit and pursue other projects. He eventually left Y Combinator and went on to found several other successful startups.