### Setup Models and Runtime Source: https://context7.com/gandazgul/mnemosyne/llms.txt Downloads the necessary ONNX Runtime shared library and ML models. This is typically done automatically on first use of `add` or `search`, but can be executed manually. ```bash mnemosyne setup ``` -------------------------------- ### Mnemosyne CLI Quick Start Commands Source: https://github.com/gandazgul/mnemosyne/blob/main/README.md Common commands for building, initializing, adding, and searching documents within the Mnemosyne CLI. ```bash # Clone the repo git clone https://github.com/gandazgul/mnemosyne.git cd mnemosyne # Build task build # Run ./mnemosyne # See available commands ./mnemosyne --help # Check version ./mnemosyne version # Download ONNX Runtime and ML models (~500 MB one-time) # This also happens automatically on first 'add' or 'search'. ./mnemosyne setup # Initialize a collection (uses current directory name by default) # Note: If a collection with this name already exists elsewhere, # init will error out to prevent accidental linking. ./mnemosyne init # Add documents (triggers model download on first use if not already set up) ./mnemosyne add "Go is a statically typed programming language" ./mnemosyne add "Rust focuses on memory safety and zero-cost abstractions" ./mnemosyne add --file notes.txt ./mnemosyne add --file README.md # Automatically chunks by semantic headings # Search documents (hybrid: FTS5 + vector, fused with RRF) ./mnemosyne search "programming language" ./mnemosyne search --limit 5 "systems programming" # List documents ./mnemosyne list # Delete a document by ID ./mnemosyne delete 1 # Use a named collection (with --name or -n) ./mnemosyne init -n myproject ./mnemosyne add -n myproject "some text" ./mnemosyne search -n myproject "some query" # Use the global collection shortcut ./mnemosyne add -g "Global memory" ./mnemosyne search --global "global memory" # Delete an entire collection ./mnemosyne forget myproject ``` -------------------------------- ### Manual Setup Command Source: https://github.com/gandazgul/mnemosyne/blob/main/README.md Command to manually trigger the download of required ONNX Runtime and ML models. ```bash ./mnemosyne setup ``` -------------------------------- ### Mnemosyne Configuration Example Source: https://context7.com/gandazgul/mnemosyne/llms.txt Example YAML configuration for Mnemosyne, specifying database path, embedding model details, reranker settings, and search parameters. This configuration can be placed at `~/.config/mnemosyne/config.yaml` or managed via environment variables. ```yaml db_path: "~/.local/share/mnemosyne/mnemosyne.db" embedding: # Path to embedding model directory model_path: "~/.local/share/mnemosyne/models/snowflake-arctic-embed-m-v1.5" onnx_file: "onnx/model.onnx" dimensions: 256 max_seq_length: 512 query_prefix: "Represent this sentence for searching relevant passages: " document_prefix: "" pooling: "none" reranker: # Path to reranker model directory model_path: "~/.local/share/mnemosyne/models/ms-marco-MiniLM-L-6-v2" max_seq_length: 512 enabled: true search: rrf_k: 60 # RRF fusion constant top_k: 10 # Default result limit rerank_candidates: 50 # Candidates for reranker reranker_threshold: 0.0 # Minimum reranker score rrf_threshold: 0.01 # Minimum RRF score (when reranking disabled) ``` -------------------------------- ### Initialize Mnemosyne Collection Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne init` to create a new collection for storing documents. The command is idempotent and can use the current directory name, a specified name, or a global scope. ```bash mnemosyne init ``` ```bash mnemosyne init --name my-project ``` ```bash mnemosyne init --global ``` -------------------------------- ### Perform Database Operations in Go Source: https://context7.com/gandazgul/mnemosyne/llms.txt This Go program demonstrates opening a database, ensuring a vector table exists, creating a collection, initializing an embedder, inserting a document with its vector, listing documents, and performing both full-text and vector similarity searches. ```go package main import ( "fmt" "log" "github.com/gandazgul/mnemosyne/internal/config" "github.com/gandazgul/mnemosyne/internal/db" "github.com/gandazgul/mnemosyne/internal/embedding" ) func main() { cfg := config.Load() // Open database database, err := db.Open(cfg.DBPath) if err != nil { log.Fatal(err) } defer database.Close() // Ensure vector table exists if err := database.EnsureVectorTable(cfg.Embedding.Dimensions); err != nil { log.Fatal(err) } // Create or get collection collection, created, err := database.GetOrCreateCollection("my-project") if err != nil { log.Fatal(err) } fmt.Printf("Collection %s (created: %v)\n", collection.Name, created) // Initialize embedder embedding.InitONNXRuntime(cfg.OnnxRuntimePath) defer embedding.DestroyONNXRuntime() embedder, _ := embedding.NewONNXEmbedder(cfg.Embedding) defer embedder.Close() // Add document with vector content := "Go channels provide typed conduits for goroutine communication" vec, _ := embedder.EmbedDocument(content) metadata := `{"tags": ["golang", "concurrency"]}` doc, err := database.InsertDocumentWithVector(collection.ID, content, &metadata, vec) if err != nil { log.Fatal(err) } fmt.Printf("Inserted document %d\n", doc.ID) // List documents docs, err := database.ListDocuments(collection.ID, nil, 20) if err != nil { log.Fatal(err) } for _, d := range docs { fmt.Printf("[%d] %s\n", d.ID, d.Content[:50]) } // Search by FTS ftsResults, _ := database.SearchFTS(collection.ID, "goroutine", nil, 10) fmt.Printf("FTS found %d results\n", len(ftsResults)) // Search by vector similarity queryVec, _ := embedder.EmbedQuery("concurrent programming") vecResults, _ := database.SearchVectors(collection.ID, queryVec, nil, 10) fmt.Printf("Vector search found %d results\n", len(vecResults)) } ``` -------------------------------- ### Show Version Source: https://context7.com/gandazgul/mnemosyne/llms.txt Displays the current version of the Mnemosyne CLI. ```bash mnemosyne version ``` -------------------------------- ### Cleanup Resources Source: https://context7.com/gandazgul/mnemosyne/llms.txt Removes downloaded models and ONNX Runtime libraries. Optionally, the database can also be deleted. Use `--yes` to skip confirmation prompts. ```bash # Remove models and runtime only mnemosyne cleanup # Also delete database (irreversible) mnemosyne cleanup --db # Skip confirmation mnemosyne cleanup --yes ``` -------------------------------- ### Perform Hybrid Search with RRF Source: https://context7.com/gandazgul/mnemosyne/llms.txt Initializes the search engine, performs a hybrid search with specified options including RRF parameters, and prints the results. Ensure ONNX Runtime, database, embedder, and reranker are properly configured and initialized. ```go package main import ( "fmt" "log" "github.com/gandazgul/mnemosyne/internal/config" "github.com/gandazgul/mnemosyne/internal/db" "github.com/gandazgul/mnemosyne/internal/embedding" "github.com/gandazgul/mnemosyne/internal/reranker" "github.com/gandazgul/mnemosyne/internal/search" ) func main() { cfg := config.Load() // Initialize ONNX Runtime if err := embedding.InitONNXRuntime(cfg.OnnxRuntimePath); err != nil { log.Fatal(err) } defer embedding.DestroyONNXRuntime() // Open database database, err := db.Open(cfg.DBPath) if err != nil { log.Fatal(err) } defer database.Close() // Create embedder embedder, err := embedding.NewONNXEmbedder(cfg.Embedding) if err != nil { log.Fatal(err) } defer embedder.Close() // Create reranker (optional) rr, err := reranker.NewONNXReranker(cfg.Reranker) if err != nil { log.Fatal(err) } defer rr.Close() // Create search engine engine := search.NewEngine(database, embedder, rr) // Perform hybrid search results, err := engine.Search(search.Options{ CollectionID: 1, Query: "how do goroutines work", Limit: 5, RRFK: 60, ReRankCandidates: 50, RerankerThreshold: 0.0, RRFThreshold: 0.01, Tags: []string{"golang"}, }) if err != nil { log.Fatal(err) } for _, r := range results { fmt.Printf("[%d] %.4f: %s\n", r.DocumentID, r.RRFScore, r.Content) } } ``` -------------------------------- ### Triggering a Release Source: https://github.com/gandazgul/mnemosyne/blob/main/README.md Command to initiate a versioned release using the Task runner. ```bash task release -- v0.1.0 ``` -------------------------------- ### Available Task Runner Commands Source: https://github.com/gandazgul/mnemosyne/blob/main/README.md Development and maintenance tasks available via the Task runner. ```bash task build # Build the binary task test # Run all tests task clean # Remove build artifacts task lint # Run linter (requires golangci-lint) task download-models # Download ONNX models from HuggingFace (dev workflow) task release -- v0.1.0 # Create and push a new release tag ``` -------------------------------- ### Generate Text Embeddings with ONNX Source: https://context7.com/gandazgul/mnemosyne/llms.txt Initializes ONNX Runtime and an embedder, then generates vector embeddings for a query, a document, and a batch of texts. Ensure ONNX Runtime and the embedder configuration are valid. ```go package main import ( "fmt" "log" "github.com/gandazgul/mnemosyne/internal/config" "github.com/gandazgul/mnemosyne/internal/embedding" ) func main() { cfg := config.Load() // Initialize ONNX Runtime with library path if err := embedding.InitONNXRuntime(cfg.OnnxRuntimePath); err != nil { log.Fatal(err) } defer embedding.DestroyONNXRuntime() // Create embedder from config embedder, err := embedding.NewONNXEmbedder(cfg.Embedding) if err != nil { log.Fatal(err) } defer embedder.Close() // Embed a query (adds query prefix automatically) queryVec, err := embedder.EmbedQuery("what is concurrency in Go?") if err != nil { log.Fatal(err) } fmt.Printf("Query embedding: %d dimensions\n", len(queryVec)) // Embed a document (adds document prefix if configured) docVec, err := embedder.EmbedDocument("Go uses goroutines for lightweight concurrency") if err != nil { log.Fatal(err) } fmt.Printf("Document embedding: %d dimensions\n", len(docVec)) // Batch embedding for efficiency texts := []string{"First document", "Second document", "Third document"} vectors, err := embedder.EmbedBatch(texts) if err != nil { log.Fatal(err) } fmt.Printf("Batch embedded %d documents\n", len(vectors)) } ``` -------------------------------- ### Show Statistics Source: https://context7.com/gandazgul/mnemosyne/llms.txt Displays key statistics about the Mnemosyne database, including path, size, collection count, total documents, and configured model details. ```bash mnemosyne stats ``` -------------------------------- ### List Mnemosyne Collections Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne collections` to display all available collections, including their IDs, names, document counts, and creation timestamps. ```bash mnemosyne collections ``` -------------------------------- ### List Documents in Mnemosyne Collection Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne list` to display documents in a collection, showing IDs and content previews. Supports custom limits, tag filtering, specifying collections, and plain output format. ```bash mnemosyne list ``` ```bash mnemosyne list --limit 50 ``` ```bash mnemosyne list --tag important ``` ```bash mnemosyne list --name my-project ``` ```bash mnemosyne list --format plain ``` -------------------------------- ### Import Collections Source: https://context7.com/gandazgul/mnemosyne/llms.txt Imports collections from JSONL files previously exported by `mnemosyne export`. Raw vectors are included, eliminating the need for re-embedding. Supports importing single files or all `.jsonl` files from a directory. ```bash # Import single file mnemosyne import my-project.jsonl # Import with different collection name mnemosyne import my-project.jsonl --name new-project # Import all .jsonl files from directory mnemosyne import --dir ./backups/ ``` -------------------------------- ### Add Documents to Mnemosyne Collection Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne add` to store documents. Content can be provided directly, from a file (supports markdown chunking), or via stdin. Documents are automatically embedded and stored with vector representations. Supports specifying collection name and global scope. ```bash mnemosyne add "Go is a statically typed programming language" ``` ```bash mnemosyne add --tag core --tag language "Rust focuses on memory safety" ``` ```bash mnemosyne add --file README.md ``` ```bash echo "Important note about architecture" | mnemosyne add --stdin ``` ```bash mnemosyne add --name my-project "Document content here" ``` ```bash mnemosyne add --global "Global memory across all projects" ``` -------------------------------- ### Export Collections Source: https://context7.com/gandazgul/mnemosyne/llms.txt Exports collections to JSONL files, suitable for backup and transfer. Includes metadata and raw vector embeddings for fast, model-independent imports. Supports exporting single or all collections, with options for specifying output files or directories. ```bash # Export single collection mnemosyne export --name my-project # Export to specific file mnemosyne export --name my-project -o backup.jsonl # Export all collections mnemosyne export --all # Export all to specific directory mnemosyne export --all -o ./backups/ # Skip confirmation for --all mnemosyne export --all --yes ``` -------------------------------- ### Search Documents in Mnemosyne Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne search` for hybrid search combining full-text and vector similarity. Options include limiting results, enabling debug info, filtering by tags, disabling reranking, adjusting score thresholds, specifying collections, and choosing output format. ```bash mnemosyne search "programming language" ``` ```bash mnemosyne search --limit 5 "systems programming" ``` ```bash mnemosyne search --debug "how do goroutines work" ``` ```bash mnemosyne search --tag core "memory safety" ``` ```bash mnemosyne search --no-rerank "concurrency patterns" ``` ```bash mnemosyne search --threshold 0.5 "error handling" ``` ```bash mnemosyne search --name my-project "API design" ``` ```bash mnemosyne search --global "common patterns" ``` ```bash mnemosyne search --format plain "query text" ``` -------------------------------- ### List Tags in Collection Source: https://context7.com/gandazgul/mnemosyne/llms.txt Lists all distinct tags used within a specified collection. Use `--name` to target a specific collection, or omit it to list tags from the current collection. ```bash mnemosyne tags # List tags from specific collection mnemosyne tags --name my-project ``` -------------------------------- ### Delete Collection (Forget) Source: https://context7.com/gandazgul/mnemosyne/llms.txt Permanently deletes a collection and all its documents. Confirmation is required unless `--yes` is provided. Can target a specific collection by name or delete the collection derived from the current directory. ```bash # Delete collection with confirmation prompt mnemosyne forget --name old-project # Skip confirmation mnemosyne forget --name old-project --yes # Delete collection derived from current directory mnemosyne forget ``` -------------------------------- ### Delete Document from Mnemosyne Source: https://context7.com/gandazgul/mnemosyne/llms.txt Use `mnemosyne delete` followed by the document ID to remove a document and its associated embedding vector from the database. ```bash mnemosyne delete 1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.