Vectorless RAG Framework for Go โ No embeddings, no vector DB, just LLM reasoning.
Inspired by PageIndex
TreeIndex ๆฏไธไธช็บฏ Go ๅฎ็ฐ็ RAG๏ผๆฃ็ดขๅขๅผบ็ๆ๏ผๆกๆถใๅฎไธไฝฟ็จๅ้ๆฐๆฎๅบ๏ผไธๅๆๆฌๅ็๏ผ่ๆฏๅฐๆๆกฃๆๅปบไธบๅฑ็บงๆ ็ดขๅผ๏ผ็ถๅ็จ LLM ๆจ็ๆฅๅฎไฝๅๆฃ็ดข็ธๅ ณไฟกๆฏใ
ไผ ็ป RAG: ๆๆกฃ โ ๅ็ โ ๅ้ๅตๅ
ฅ โ ็ธไผผๅบฆๆ็ดข โ ้กถ้จ็ปๆ
TreeIndex: ๆๆกฃ โ ๆ ็ดขๅผ โ LLM ๆจ็ๅฏผ่ช โ ็ฒพ็กฎๅ
ๅฎนๆๅ
ไธบไปไนไธ็จๅ้๏ผ
- ๅ้ๆ็ดขไพ่ต embedding ๆจกๅ็่ดจ้
- ๅฐๆๆกฃ/ไธไธ้ขๅ embedding ๆๆๅทฎ
- ้่ฆ้ขๅค้จ็ฝฒๅ้ๆฐๆฎๅบ๏ผPinecone/Chroma/Milvus๏ผ
- LLM ๆฌ่บซ็ๆจ็่ฝๅ่ถณๅคๅ็ฒพๅๅฎไฝ
- ๐ถ ้ถๅค้จไพ่ต โ ไป ไฝฟ็จ Go ๆ ๅๅบ + net/http ่ฐ LLM API
- ๐ณ ๅฑ็บงๆ ็ดขๅผ โ ๆๆกฃ็ปๆ่ช็ถๆ ๅฐไธบๆ
- ๐ง ๆจ็ๅผๆฃ็ดข โ LLM ่ฏปๆ โ ๅฎไฝ โ ๆๅ๏ผไธๆฏๅ้ๅน้
- ๐ ๅคๆ ผๅผๆฏๆ โ PDFใMarkdown
- ๐ค ๅค LLM ๆฏๆ โ OpenAIใAnthropic๏ผไปปๆๅ ผๅฎน API๏ผ
- ๐ฆ ๅไบ่ฟๅถ โ
go buildๅณๅฏ้จ็ฝฒ - ๐พ ็ดขๅผๆไน ๅ โ JSON ๆไปถๅญๅจ๏ผ้ๆถๅ ่ฝฝๆฅ่ฏข
# ็ผ่ฏ
go build -o treeindex ./cmd/treeindex
# ๅฟซ้ๆฅ็ๆๆกฃๆ ๏ผไธ้่ฆ LLM๏ผ
./treeindex tree document.md
# ๆๅปบ็ดขๅผ๏ผ้่ฆ LLM API key๏ผ
export OPENAI_API_KEY=sk-xxx
./treeindex index document.pdf
# ๆฅ่ฏข
./treeindex query document.treeindex.json "What is the main conclusion?"
# ไนๆฏๆ Anthropic
export ANTHROPIC_AUTH_TOKEN=sk-ant-xxx
./treeindex index document.md --provider anthropic| ๅฝไปค | ่ฏดๆ |
|---|---|
treeindex index <file> |
ๆๅปบๆ ็ดขๅผ๏ผๅซ LLM ๆ่ฆ๏ผ |
treeindex tree <file> |
ๅฟซ้ๆฅ็ๆๆกฃๆ ๏ผไธ้่ฆ LLM๏ผ |
treeindex query <index> <query> |
ๆฅ่ฏข็ดขๅผๆๆกฃ |
treeindex show <index> |
ๆพ็คบๅฎๆดๆ ็ปๆ |
| ๆ ๅฟ | ่ฏดๆ | ้ป่ฎคๅผ |
|---|---|---|
--no-summarize |
่ทณ่ฟ LLM ๆ่ฆ็ๆ | false |
--merge <len> |
ๅๅนถๅฐ่๏ผ< len ๅญ็ฌฆ๏ผ | 200 |
--top <n> |
่ฟๅ็ปๆๆฐ้ | 5 |
--provider <p> |
LLM ๆไพๅ | openai |
--format <f> |
่พๅบๆ ผๅผ (text/json) | text |
package main
import (
"github.com/seastarbot/treeindex-go/internal/indexer"
"github.com/seastarbot/treeindex-go/internal/llm"
"github.com/seastarbot/treeindex-go/internal/retriever"
)
func main() {
// ๅๅปบ LLM provider
provider, _ := llm.NewProvider(nil)
// ๆๅปบ็ดขๅผ
idx := indexer.New(provider, true)
tree, _ := idx.IndexFile("document.pdf")
tree.SaveToFile("index.json")
// ๆฅ่ฏข
ret := retriever.New(provider)
results, _ := ret.Retrieve(tree, "What is the conclusion?", 5)
answer, _ := ret.Answer("What is the conclusion?", results)
fmt.Println(answer)
}โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Parser โโโโโถโ Indexer โโโโโถโ Tree โ
โ PDF/MD โ โ LLMๆ่ฆ โ โ JSONๅญๅจ โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโ
โ Retrieverโ
โ LLMๆจ็ โ
โโโโโโโโโโโโ
MIT License
TreeIndex is a pure Go implementation of a RAG (Retrieval-Augmented Generation) framework. Instead of vector embeddings and similarity search, it builds a hierarchical tree index from documents and uses LLM reasoning to navigate and retrieve relevant content.
Traditional RAG: Document โ Chunks โ Embeddings โ Vector Search โ Top-K
TreeIndex: Document โ Tree Index โ LLM Reasoning โ Precise Extraction
Why skip vectors?
- Vector search depends heavily on embedding model quality
- Small documents and domain-specific content get poor embeddings
- Requires deploying a vector database (Pinecone/Chroma/Milvus)
- LLMs are already good at understanding document structure and finding information
- ๐ถ Zero dependencies โ Go stdlib + net/http only
- ๐ณ Hierarchical tree index โ Document structure naturally maps to a tree
- ๐ง Reasoning retrieval โ LLM reads the tree โ locates โ extracts
- ๐ Multi-format โ PDF, Markdown
- ๐ค Multi-LLM โ OpenAI, Anthropic (any compatible API)
- ๐ฆ Single binary โ Just
go buildand deploy - ๐พ Persistent indexes โ JSON file storage, load and query anytime
# Build
go build -o treeindex ./cmd/treeindex
# Quick tree view (no LLM needed)
./treeindex tree document.md
# Build index (requires LLM API key)
export OPENAI_API_KEY=sk-xxx
./treeindex index document.pdf
# Query
./treeindex query document.treeindex.json "What is the main conclusion?"
# Also supports Anthropic
export ANTHROPIC_AUTH_TOKEN=sk-ant-xxx
./treeindex index document.md --provider anthropic| Command | Description |
|---|---|
treeindex index <file> |
Build tree index (with LLM summaries) |
treeindex tree <file> |
Quick tree view (no LLM needed) |
treeindex query <index> <query> |
Query an indexed document |
treeindex show <index> |
Display full tree structure |
| Flag | Description | Default |
|---|---|---|
--no-summarize |
Skip LLM summary generation | false |
--merge <len> |
Merge small sections (< len chars) | 200 |
--top <n> |
Number of results to return | 5 |
--provider <p> |
LLM provider (openai/anthropic) | openai |
--format <f> |
Output format (text/json) | text |
package main
import (
"github.com/seastarbot/treeindex-go/internal/indexer"
"github.com/seastarbot/treeindex-go/internal/llm"
"github.com/seastarbot/treeindex-go/internal/retriever"
)
func main() {
// Create LLM provider
provider, _ := llm.NewProvider(nil)
// Build index
idx := indexer.New(provider, true)
tree, _ := idx.IndexFile("document.pdf")
tree.SaveToFile("index.json")
// Query
ret := retriever.New(provider)
results, _ := ret.Retrieve(tree, "What is the conclusion?", 5)
answer, _ := ret.Answer("What is the conclusion?", results)
fmt.Println(answer)
}โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Parser โโโโโถโ Indexer โโโโโถโ Tree โ
โ PDF/MD โ โ LLM Summ.โ โ JSON โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโ
โ Retrieverโ
โ LLM Rsn. โ
โโโโโโโโโโโโ
MIT License