Skip to content

Commit ab390ee

Browse files
antalikegithub-actions[bot]
authored andcommitted
chore(i18n): auto translate content for commit bc9f8ab [skip ci]
1 parent bc9f8ab commit ab390ee

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

content/en/open_source/modules/memories/tree_textual_memory.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
2-
title: "TreeTextMemory: Structured Hierarchical Textual Memory"
2+
title: "TreeTextMemory: Tree-Structured Plain Text Memory"
33
desc: >
4-
Lets build your first **graph-based, tree-structured memory** in MemOS!
4+
Let's build your first **graph-based, tree-structured plain text memory** in MemOS!
55
<br>
6-
**TreeTextMemory** helps you organize, link, and retrieve memories with rich context and explainability.
6+
**TreeTextMemory** supports organizing, associating, and retrieving memories in a structured way while preserving rich contextual information and good interpretability.
77
<br>
8-
[Neo4j](/open_source/modules/memories/neo4j_graph_db) is the current backend, with support for additional graph stores planned in the future.
8+
MemOS currently uses [Neo4j](/open_source/modules/memories/neo4j_graph_db) as the backend, with plans to support more graph databases in the future.
99
---
1010

11-
1211
## Table of Contents
1312

1413
- [What You’ll Learn](#what-youll-learn)
@@ -32,6 +31,7 @@ desc: >
3231
## What You’ll Learn
3332

3433
By the end of this guide, you will:
34+
3535
- Extract structured memories from raw text or conversations.
3636
- Store them as **nodes** in a graph database.
3737
- Link memories into **hierarchies** and semantic graphs.
@@ -42,6 +42,7 @@ By the end of this guide, you will:
4242
### Memory Structure
4343

4444
Every node in your `TreeTextMemory` is a `TextualMemoryItem`:
45+
4546
- `id`: Unique memory ID (auto-generated if omitted).
4647
- `memory`: the main text.
4748
- `metadata`: includes hierarchy info, embeddings, tags, entities, source, and status.
@@ -64,7 +65,6 @@ Every node in your `TreeTextMemory` is a `TextualMemoryItem`:
6465
| `usage` | `list[str]` | Usage history |
6566
| `background` | `str` | Additional context |
6667

67-
6868
::note
6969
**Best Practice**<br>
7070
Use meaningful tags and background — they help organize your graph for
@@ -77,16 +77,12 @@ When you run this example, your workflow will:
7777

7878
1. **Extract:** Use an LLM to pull structured memories from raw text.
7979

80-
8180
2. **Embed:** Generate vector embeddings for similarity search.
8281

83-
8482
3. **Store & Link:** Add nodes to your graph database (Neo4j) with relationships.
8583

86-
8784
4. **Search:** Query by vector similarity, then expand results by graph hops.
8885

89-
9086
::note
9187
**Hint**<br>Graph links help retrieve context that pure vector search might miss!
9288
::
@@ -134,7 +130,9 @@ This file contains a JSON structure with `nodes` and `edges`. It can be reloaded
134130
::steps{}
135131

136132
### Create TreeTextMemory Config
133+
137134
Define:
135+
138136
- your embedder (to create vectors),
139137
- your graph DB backend (Neo4j),
140138
- and your extractor LLM (optional).
@@ -145,7 +143,6 @@ from memos.configs.memory import TreeTextMemoryConfig
145143
config = TreeTextMemoryConfig.from_json_file("examples/data/config/tree_config.json")
146144
```
147145

148-
149146
### Initialize TreeTextMemory
150147

151148
```python
@@ -312,23 +309,27 @@ print(f"✓ Extracted and added {len(mixed_memories)} memories from mixed conten
312309

313310
::note
314311
**MultiModal Reader Advantages**<br>
312+
315313
- **Smart Routing**: Automatically identifies content type (image/URL/file) and selects appropriate parser<br>
314+
316315
- **Format Support**: Supports PDF, DOCX, Markdown, HTML, images, and more<br>
317316
- **URL Parsing**: Automatically extracts web content (including GitHub, documentation sites, etc.)<br>
318317
- **Large File Handling**: Automatically chunks oversized files to avoid token limits<br>
319318
- **Context Preservation**: Uses sliding window to maintain context continuity between chunks
320319
::
321-
322320
::note
323321
**Configuration Tips**<br>
324-
- Use the `direct_markdown_hostnames` parameter to specify which domains should return Markdown format<br>
322+
323+
::note
324+
**Configuration Tip**<br>
325+
325326
- Supports both `mode="fast"` and `mode="fine"` extraction modes; fine mode extracts more details<br>
326327
- See complete examples: `/examples/mem_reader/multimodal_struct_reader.py`
327328
::
328-
329329
### Search Memories
330330

331331
Try a vector + graph search:
332+
332333
```python
333334
results = tree_memory.search("Talk about the garden", top_k=5)
334335
for i, node in enumerate(results):
@@ -394,10 +395,10 @@ Alternatively, you can configure the `internet_retriever` field directly in the
394395

395396
With this setup, when you call `tree_memory.search(query)`, the system will automatically trigger an internet search (via BochaAI, Google, or Bing), and merge the results with local memory nodes in a unified ranked list — no need to manually call `retriever.retrieve_from_internet`.
396397

397-
398398
### Replace Working Memory
399399

400400
Replace your current `WorkingMemory` nodes with new ones:
401+
401402
```python
402403
tree_memory.replace_working_memory(
403404
[{
@@ -408,15 +409,16 @@ tree_memory.replace_working_memory(
408409
```
409410

410411
### Backup & Restore
412+
411413
Dump your entire tree structure to disk and reload anytime:
414+
412415
```python
413416
tree_memory.dump("tmp/tree_memories")
414417
tree_memory.load("tmp/tree_memories")
415418
```
416419

417420
::
418421

419-
420422
### Full Code Example
421423

422424
This combines all the steps above into one end-to-end example — copy & run!
@@ -490,12 +492,12 @@ my_tree_textual_memory.drop()
490492

491493
- **Structured Hierarchy:** Organize memories like a mind map — nodes can
492494
have parents, children, and cross-links.
495+
493496
- **Graph-Style Linking:** Beyond pure hierarchy — build multi-hop reasoning
494497
chains.
495498
- **Semantic Search + Graph Expansion:** Combine the best of vectors and
496499
graphs.
497500
- **Explainability:** Trace how memories connect, merge, or evolve over time.
498-
499501
::note
500502
**Try This**<br>Add memory nodes from documents or web content. Link them
501503
manually or auto-merge similar nodes!
@@ -505,11 +507,13 @@ manually or auto-merge similar nodes!
505507

506508
- **Know more about [Neo4j](/open_source/modules/memories/neo4j_graph_db):** TreeTextMemory is powered by a graph database backend.
507509
Understanding how Neo4j handles nodes, edges, and traversal will help you design more efficient memory hierarchies, multi-hop reasoning, and context linking strategies.
510+
508511
- **Add [Activation Memory](/open_source/modules/memories/kv_cache_memory):**
509512
Experiment with
510513
runtime KV-cache for session
511514
state.
512515
- **Explore Graph Reasoning:** Build workflows for multi-hop retrieval and answer synthesis.
513516
- **Go Deep:** Check the [API Reference](/api-reference/search-memories) for advanced usage, or run more examples in `examples/`.
514-
515517
Now your agent remembers not just facts — but the connections between them!
518+
519+
Now your Agent can not only remember facts but also the connections between them!

0 commit comments

Comments
 (0)