Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:Document
objects. You can load data either manually or through a data loader. Here's an example of how to load data from a directory:from llama_index import SimpleDirectoryReader documents = SimpleDirectoryReader('./data').load_data()
from llama_index import Document text_list = [text1, text2, ...] documents = [Document(text=t) for t in text_list]
VectorStoreIndex
.from llama_index.indices.document_summary import DocumentSummaryIndexRetriever retriever = DocumentSummaryIndexRetriever(doc_summary_index) retrieved_nodes = retriever.retrieve("What are the sports teams in Toronto?")
from llama_index import ListIndex, Document index = ListIndex([]) text_chunks = ['text_chunk_1', 'text_chunk_2', 'text_chunk_3'] doc_chunks = [Document(text=t, id_=f"doc_id_{i}") for i, t in enumerate(text_chunks)] for doc_chunk in doc_chunks: index.insert(doc_chunk)
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:# set number of output tokens num_output = 256
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:MockLLM
in LlamaIndex, the max_tokens
parameter is used to set a "worst case" prediction for the number of tokens in each LLM response. Here's the relevant code snippet:from llama_index.llms import MockLLM llm = MockLLM(max_tokens=256)
max_tokens
is set to 256, meaning each LLM response will contain exactly that number of tokens. If max_tokens
is not specified, then it will simply predict back the prompt.Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon: