documents = SimpleDirectoryReader('data').load_data()
index = GPTSimpleVectorIndex(documents)
"""
INFO:root:> [build_index_from_documents] Total LLM token usage: 0 tokens
> [build_index_from_documents] Total LLM token usage: 0 tokens
INFO:root:> [build_index_from_documents] Total embedding token usage: 74187 tokens
> [build_index_from_documents] Total embedding token usage: 74187 tokens
"""
「何か面白いことを言え」
py
index.query("say something interesting:")
"""
INFO:root:> [query] Total LLM token usage: 3949 tokens
> [query] Total LLM token usage: 3949 tokens
INFO:root:> [query] Total embedding token usage: 4 tokens
> [query] Total embedding token usage: 4 tokens
"""
Response
>It is important to be aware of the power of first impressions, as they can often shape how we view a situation or person. It is also important to be aware of our own faults and to take steps to address them, as this can help us to become better people. Additionally, it is important to be aware of the power of words and to use them wisely, as they can have a lasting impact on those around us. Finally, it is important to be aware of the power of kindness and to use it to our advantage, as it can help us to build strong relationships with those around us. Additionally, it is important to be aware of the power of subtle policy and to grant favours before they are deserved, as this can be a proof of being obliging. Furthermore, it is important to never share the secrets of your superiors, as this can have serious consequences.
Q: Some people compare AI generation of text to search and claim that AI generation is futile because it could be wrong. What do you think?
py
r2 = index.query("Q: Some people compare AI generation of text to search and claim that AI generation is futile because it could be wrong. What do you think?")
"""
INFO:root:> [query] Total LLM token usage: 4346 tokens
> [query] Total LLM token usage: 4346 tokens
INFO:root:> [query] Total embedding token usage: 29 tokens
> [query] Total embedding token usage: 29 tokens
"""
>I think that AI generation of text can be a useful tool, but it should not be relied upon as a replacement for human creativity and insight. AI generation of text can be helpful in providing ideas and inspiration, but it should not be used as a substitute for human judgement and analysis. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human creativity and insight. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human judgement and analysis. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human creativity and insight. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human judgement and analysis. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human creativity and insight. AI generation of text can be a useful tool for quickly generating ideas and content, but it should not be used as a replacement for human judgement and analysis. AI generation of text can be a useful tool for quickly
>I think that AI generation of text is a valuable tool that can be used to help generate ideas and find new ways of approaching difficult problems. Although it may not always be correct, it can be a valuable source of inspiration and can help to stimulate new thought processes and ideas. AI generation of text can also be used to help identify patterns and trends that may otherwise not be visible. Ultimately, I believe that AI is a valuable tool that should not be disregarded and can be used to enhance our creativity and problem-solving skills.
r2 = index.query("Q: What is wisdom?")
"""
INFO:root:> [query] Total LLM token usage: 3833 tokens
> [query] Total LLM token usage: 3833 tokens
INFO:root:> [query] Total embedding token usage: 6 tokens
> [query] Total embedding token usage: 6 tokens
"""
>Wisdom is the ability to think deeply and critically about difficult topics, to recognize and understand the complexities of a situation, and to make decisions based on sound judgment and experience. It is the ability to use knowledge and experience to make informed decisions and to act in a way that is beneficial to oneself and to others. Wisdom also involves understanding the consequences of one's actions and being able to recognize when it is necessary to take a different course of action. Additionally, wisdom involves the ability to adapt oneself to one's company, to employ no more force than is necessary, and to recognize that excellence and achievement are the only foundations for immortality.
>The wise man thinks over everything, but with a difference, most profoundly where there is some profound difficulty, and thinks that perhaps there is more in it than he thinks. Thus his comprehension extends as far as his apprehension.
> There is no need to show your ability before every one. Employ no more force than is necessary. Let there be no unnecessary expenditure either of knowledge or of power. The
vector_stores/simple.py class SimpleVectorStore(VectorStore) def query
py
items = self._data.embedding_dict.items()
node_ids = [t[0] for t in items]
embeddings = [t[1] for t in items]
top_similarities, top_ids = get_top_k_embeddings(
query_embedding,
embeddings,
similarity_top_k=similarity_top_k,
embedding_ids=node_ids,
)
return VectorStoreQueryResult(similarities=top_similarities, ids=top_ids)
返してるのは単なるデータクラス
:
(Pdb) print(top_ids)
['75e061c7-eef9-4193-bd20-c871b328f69a']
(Pdb) c
INFO:root:> [query] Total LLM token usage: 189 tokens
> [query] Total LLM token usage: 189 tokens
INFO:root:> [query] Total embedding token usage: 4 tokens
> [query] Total embedding token usage: 4 tokens
Out[2]: Response(response="\nFortune is a concept referring to luck, chance, or fate. It is often used to refer to a person's success or wealth.", source_nodes=[SourceNode(source_text='55: Wait.\nIt\'s a sign of a noble heart dowered with patience, never to be in a hurry, never to be in a passion. First be master over yourself if you would be master over others. You must pass through the circumference of time before arriving at the centre of opportunity. A wise reserve seasons the aims and matures the means. Time\'s crutch effects more than the iron club of Hercules. God Himself chasteneth not with a rod but with time. He 1 spake a great word who said, "Time and I against any two."\nFortune herself rewards waiting with the first prize.', doc_id='a0ee19f2-281c-4109-9eff-97a7a2949b3b', extra_info=None, node_info={'start': 0, 'end': 556}, similarity=0.8087368600771996)], extra_info=None)
>Fortune is a concept referring to luck, chance, or fate. It is often used to refer to a person's success or wealth.
:
index.query("Why the precious metals are the heaviest?")
INFO:root:> [query] Total LLM token usage: 173 tokens
> [query] Total LLM token usage: 173 tokens
INFO:root:> [query] Total embedding token usage: 8 tokens
> [query] Total embedding token usage: 8 tokens
Out[4]: Response(response='\nThe precious metals are the heaviest because they are worth the most and require the most effort to obtain. This is in line with the proverb "Slow and Sure" which suggests that lasting success requires patience and hard work. The proverb also states that only excellence counts and only achievement endures, which implies that the precious metals are the most valuable and require the most effort to obtain.', source_nodes=[SourceNode(source_text='57: Slow and Sure.\nEarly enough if well. Quickly done can be quickly undone. To last an eternity requires an eternity of preparation. Only excellence counts; only achievement endures. Profound intelligence is the only foundation for immortality. Worth much costs much. The precious metals are the heaviest.', doc_id='48d11d5a-19f3-4150-8178-2392bb7f166b', extra_info=None, node_info={'start': 0, 'end': 306}, similarity=0.839387437323102)], extra_info=None)
>The precious metals are the heaviest because they are worth the most and require the most effort to obtain. This is in line with the proverb "Slow and Sure" which suggests that lasting success requires patience and hard work. The proverb also states that only excellence counts and only achievement endures, which implies that the precious metals are the most valuable and require the most effort to obtain.