Skip to content
Snippets Groups Projects
Commit 4ae69061 authored by Logan Markewich's avatar Logan Markewich
Browse files

flesh out more

parent dc74b40c
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 24 deletions
--- ---
sidebar_position: 4 sidebar_position: 5
--- ---
# Advanced Features # Advanced Features
...@@ -21,3 +21,7 @@ npx ts-node subquestion.ts ...@@ -21,3 +21,7 @@ npx ts-node subquestion.ts
SubQuestionQueryEngine is implemented with Tools. The basic idea of Tools is that they are executable options for the large language model. In this case, our SubQuestionQueryEngine relies on QueryEngineTool, which as you guessed it is a tool to run queries on a QueryEngine. This allows us to give the model an option to query different documents for different questions for example. You could also imagine that the SubQuestionQueryEngine could use a Tool that searches for something on the web or gets an answer using Wolfram Alpha. SubQuestionQueryEngine is implemented with Tools. The basic idea of Tools is that they are executable options for the large language model. In this case, our SubQuestionQueryEngine relies on QueryEngineTool, which as you guessed it is a tool to run queries on a QueryEngine. This allows us to give the model an option to query different documents for different questions for example. You could also imagine that the SubQuestionQueryEngine could use a Tool that searches for something on the web or gets an answer using Wolfram Alpha.
You can learn more about Tools by taking a look at the LlamaIndex Python documentation https://gpt-index.readthedocs.io/en/latest/core_modules/agent_modules/tools/root.html You can learn more about Tools by taking a look at the LlamaIndex Python documentation https://gpt-index.readthedocs.io/en/latest/core_modules/agent_modules/tools/root.html
## ListIndexLLMRetriever
Todo: Insert text.
label: "API" label: "API"
position: 4 position: 6
\ No newline at end of file \ No newline at end of file
---
sidebar_position: 3
---
# End to End Examples # End to End Examples
We include several end-to-end examples using LlamaIndex.TS in the repository We include several end-to-end examples using LlamaIndex.TS in the repository
......
label: "Modules" label: "Modules"
collapsed: false collapsed: false
position: 3 position: 4
\ No newline at end of file \ No newline at end of file
--- ---
sidebar_position: 3 sidebar_position: 4
--- ---
# ChatEngine # ChatEngine
\ No newline at end of file
The chat engine is a quick and simple way to chat with the data in your index.
```typescript
const retriever = index.asRetriever();
const chatEngine = new ContextChatEngine({ retriever });
// start chatting
const response = await chatEngine.chat(query);
```
--- ---
sidebar_position: 1 sidebar_position: 2
--- ---
# Index # Index
\ No newline at end of file
An index is the basic container and organization for your data. LlamaIndex.TS supports two indexes:
- `ListIndex` - will send every `Node` in the index to the LLM in order to generate a response
- `VectorStoreIndex` - will send the top-k `Node`s to the LLM when generating a response. The default top-k is 2.
```typescript
import {
Document,
VectorStoreIndex,
} from "llamaindex";
const document = new Document({ text: "test" });
const index = await VectorStoreIndex.fromDocuments(
[document]
);
```
\ No newline at end of file
---
sidebar_position: 1
---
# Reader / Loader
LlamaIndex.TS supports easy loading of files from folders using the `SimpleDirectoryReader` class. Currently, `.txt` and `.pdf` files are supported, with more planned in the future!
```typescript
import { SimpleDirectoryReader } from "llamaindex";
documents = new SimpleDirectoryReader().loadData("./data");
```
...@@ -6,8 +6,8 @@ sidebar_position: 0 ...@@ -6,8 +6,8 @@ sidebar_position: 0
`Document`s and `Node`s are the basic building blocks of any index. While the API for these objects is similar, `Document` objects represent entire files, while `Node`s are smaller pieces of that original document, that are suitable for an LLM and Q&A. `Document`s and `Node`s are the basic building blocks of any index. While the API for these objects is similar, `Document` objects represent entire files, while `Node`s are smaller pieces of that original document, that are suitable for an LLM and Q&A.
## Usage Pattern
```typescript ```typescript
import { Document } from "llamaindex";
``` document = new Document({ text: "text", metadata: { "key": "val" }});
\ No newline at end of file ```
--- ---
sidebar_position: 2 sidebar_position: 3
--- ---
# QueryEngine # QueryEngine
\ No newline at end of file
A query engine wraps a `Retriever` and a `ResponseSynthesizer` into a pipeline, that will use the query string to fetech nodes and then send them to the LLM to generate a response.
```typescript
const queryEngine = index.asQueryEngine();
const response = queryEngine.query("query string");
```
\ No newline at end of file
...@@ -8,6 +8,8 @@ LlamaIndex.TS offers several core modules, seperated into high-level modules for ...@@ -8,6 +8,8 @@ LlamaIndex.TS offers several core modules, seperated into high-level modules for
- **Node**: The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM. - **Node**: The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
- **Reader/Loader**: A reader or loader is something that takes in a document in the real world and transforms into a Document class that can then be used in your Index and queries. We currently support plain text files and PDFs with many many more to come.
- **Indexes**: indexes store the Nodes and the embeddings of those nodes. - **Indexes**: indexes store the Nodes and the embeddings of those nodes.
- **QueryEngine**: Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected nodes from your Index to give the LLM the context it needs to answer your query. - **QueryEngine**: Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected nodes from your Index to give the LLM the context it needs to answer your query.
...@@ -22,8 +24,6 @@ LlamaIndex.TS offers several core modules, seperated into high-level modules for ...@@ -22,8 +24,6 @@ LlamaIndex.TS offers several core modules, seperated into high-level modules for
- **Embedding**: An embedding is represented as a vector of floating point numbers. OpenAI's text-embedding-ada-002 is our default embedding model and each embedding it generates consists of 1,536 floating point numbers. Another popular embedding model is BERT which uses 768 floating point numbers to represent each Node. We provide a number of utilities to work with embeddings including 3 similarity calculation options and Maximum Marginal Relevance - **Embedding**: An embedding is represented as a vector of floating point numbers. OpenAI's text-embedding-ada-002 is our default embedding model and each embedding it generates consists of 1,536 floating point numbers. Another popular embedding model is BERT which uses 768 floating point numbers to represent each Node. We provide a number of utilities to work with embeddings including 3 similarity calculation options and Maximum Marginal Relevance
- **Reader/Loader**: A reader or loader is something that takes in a document in the real world and transforms into a Document class that can then be used in your Index and queries. We currently support plain text files and PDFs with many many more to come.
- **TextSplitter**: Text splitting strategies are incredibly important to the overall efficacy of the embedding search. Currently, while we do have a default, there's no one size fits all solution. Depending on the source documents, you may want to use different splitting sizes and strategies. Currently we support spliltting by fixed size, splitting by fixed size with overlapping sections, splitting by sentence, and splitting by paragraph. - **TextSplitter**: Text splitting strategies are incredibly important to the overall efficacy of the embedding search. Currently, while we do have a default, there's no one size fits all solution. Depending on the source documents, you may want to use different splitting sizes and strategies. Currently we support spliltting by fixed size, splitting by fixed size with overlapping sections, splitting by sentence, and splitting by paragraph.
- **Retriever**: The Retriever is what actually chooses the Nodes to retrieve from the index. Here, you may wish to try retrieving more or fewer Nodes per query, changing your similarity function, or creating your own retriever for each individual use case in your application. For example, you may wish to have a separate retriever for code content vs. text content. - **Retriever**: The Retriever is what actually chooses the Nodes to retrieve from the index. Here, you may wish to try retrieving more or fewer Nodes per query, changing your similarity function, or creating your own retriever for each individual use case in your application. For example, you may wish to have a separate retriever for code content vs. text content.
......
---
sidebar_position: 2
---
# Reader / Loader
\ No newline at end of file
...@@ -2,4 +2,16 @@ ...@@ -2,4 +2,16 @@
sidebar_position: 1 sidebar_position: 1
--- ---
# Embedding # Embedding
\ No newline at end of file
The embedding model in LlamaIndex is responsible for creating numerical representations of text. By default, LlamaIndex will use the `text-embedding-ada-002` model from OpenAI.
This can be explicitly set in the `ServiceContext` object.
```typescript
import { OpenAIEmbedding, ServiceContext } from "llamaindex";
const openaiEmbeds = new OpenAIEmbedding();
const serviceContext = new ServiceContext({ embedModel: openaiEmbeds });
```
\ No newline at end of file
...@@ -2,4 +2,16 @@ ...@@ -2,4 +2,16 @@
sidebar_position: 0 sidebar_position: 0
--- ---
# LLM # LLM
\ No newline at end of file
The LLM is responsible for reading text and generating natural language responses to queries. By default, LlamaIndex.TS uses `gpt-3.5-turbo`.
The LLM can be explicitly set in the `ServiceContext` object.
```typescript
import { ChatGPTLLMPredictor, ServiceContext } from "llamaindex";
const openaiLLM = new ChatGPTLLMPredictor({ model: "gpt-3.5-turbo" });
const serviceContext = new ServiceContext({ llmPredictor: openaiLLM });
```
...@@ -2,4 +2,14 @@ ...@@ -2,4 +2,14 @@
sidebar_position: 5 sidebar_position: 5
--- ---
# Retriever # Retriever
\ No newline at end of file
A retriever in LlamaIndex is what is used to fetch `Node`s from an index using a query string. For example, a `ListIndexRetriever` will fetch all nodes no matter the query. Meanwhile, a `VectorIndexRetriever` will only fetch the top-k most similar nodes.
```typescript
const retriever = vector_index.asRetriever()
retriever.similarityTopK = 3;
// Fetch nodes!
const nodes = await retriever.aretrieve("query string");
```
...@@ -3,3 +3,5 @@ sidebar_position: 4 ...@@ -3,3 +3,5 @@ sidebar_position: 4
--- ---
# SimplePrompt # SimplePrompt
Prompts are the basic inputs to an LLM. These can contain variables that get filled in later, or just plain text that is sent as-is to a model.
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
sidebar_position: 6 sidebar_position: 6
--- ---
# Storage # Storage
\ No newline at end of file
Todo: Find out how this works.
\ No newline at end of file
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
sidebar_position: 3 sidebar_position: 3
--- ---
# TextSplitter # TextSplitter
\ No newline at end of file
Todo: Talk about text splitter. Alternatively, replace this with node parser? Or combine them?
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment