### Install system dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Install wget using apt-get. ```bash ! sudo apt-get install wget ``` -------------------------------- ### Start Lumo Server via Binary Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Launch the server using the installed binary, which defaults to port 8080. ```bash # Start the server (default port: 8080) lumo-server ``` -------------------------------- ### Install Qdrant Client Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Install the required Python package for Qdrant integration. ```bash pip install qdrant-client ``` -------------------------------- ### Install Weaviate Client Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Install the required Python package for Weaviate integration. ```bash pip install weaviate-client ``` -------------------------------- ### Install EmbedAnything Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/embed-anything.md Install the standard version of the library via pip. ```bash pip install embed-anythin ``` -------------------------------- ### Install Dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/colpali.ipynb Install the required GPU-accelerated embedding library and table formatting tool. ```bash !pip install embed-anything-gpu ``` ```bash !pip install tabulate ``` -------------------------------- ### Install EmbedAnything and Dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/Qwen3_Reranker.md Install the core library and the required ONNX runtime for inference. ```bash pip install embed-anything ``` ```bash pip install onnxruntime # For ONNX inference ``` -------------------------------- ### Install Milvus Client Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Install the required Python package for Milvus integration. ```bash pip install pymilvus ``` -------------------------------- ### Start the Server Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/actix_server.md Command to launch the Actix-based server in release mode. ```bash cargo run -p server --release ``` -------------------------------- ### Install Pinecone Client Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Install the required Python package for Pinecone integration. ```bash pip install pinecone ``` -------------------------------- ### Build Video Support on Linux Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/video.md Install FFmpeg via apt and build the project with the video feature enabled. ```bash sudo apt-get update sudo apt-get install -y ffmpeg cargo build --features video # Python (maturin) maturin develop --features "extension-module,video" ``` -------------------------------- ### Install Tesseract on Ubuntu Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/ocr.md Install Tesseract OCR and its development headers using the apt package manager. ```bash sudo apt install tesseract-ocr sudo apt install libtesseract-dev ``` -------------------------------- ### Run the EmbedAnything Server Source: https://github.com/starlightsearch/embedanything/blob/main/server/README.md Commands to navigate to the server directory and start the application. ```bash cd server cargo run ``` -------------------------------- ### Install Dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/EmbedAnything_X_smolagent.ipynb Installs the required libraries including lancedb, embed-anything-gpu, datasets, huggingface_hub, and smolagents. ```python %%capture !pip install lancedb embed-anything-gpu datasets huggingface_hub smolagents ``` -------------------------------- ### Install embed-anything library Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Installs the specific version of the embed-anything package required for the project. ```python !pip install embed-anything==0.4.15 ``` -------------------------------- ### Install Elasticsearch adapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Install the required Python package for Elasticsearch integration. ```bash pip install elasticsearch ``` -------------------------------- ### Install Lumo Server Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Install the Lumo server binary directly from the Git repository with MCP features enabled. ```bash cargo install --git https://github.com/StarlightSearch/lumo.git --branch new-updates --features mcp lumo-server ``` -------------------------------- ### Install Poppler on Ubuntu Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/ocr.md Install poppler-utils using the apt package manager to support PDF processing. ```bash sudo apt install poppler-utils ``` -------------------------------- ### Build Video Support on macOS Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/video.md Install FFmpeg and build the project with the video feature enabled. ```bash brew install ffmpeg cargo build --features video # Python (maturin) maturin develop --features "extension-module,video" ``` -------------------------------- ### Install EmbedAnything and dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/colpali.md Install the GPU-accelerated version of EmbedAnything along with required Python packages. ```bash pip install embed-anything-gpu tabulate openai ``` -------------------------------- ### Install poppler-utils for PDF processing Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/colpali.md Install the necessary system dependency for converting PDFs to images on different operating systems. ```bash apt install poppler-utils ``` ```bash brew install poppler ``` -------------------------------- ### Install Tesseract on MacOS Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/ocr.md Use Homebrew to install the Tesseract OCR engine on macOS systems. ```bash brew install tesseract ``` -------------------------------- ### Install Package via Pip Source: https://github.com/starlightsearch/embedanything/blob/main/python/README.md Alternative method to install the package in editable mode using pip. ```bash pip install -e . ``` -------------------------------- ### Install Poppler on MacOS Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/ocr.md Use Homebrew to install the Poppler PDF rendering library on macOS systems. ```bash brew install poppler ``` -------------------------------- ### Build and Install with Maturin Source: https://github.com/starlightsearch/embedanything/blob/main/python/README.md Commands to build the extension from the repository root using maturin for development or distribution. ```bash # From repository root maturin develop # build and install in the current environment (editable) # or maturin build # build a wheel ``` -------------------------------- ### Example similarity results table Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/colpali.md A sample output format showing the file name and page number of retrieved documents. ```markdown +----------------------------------------+---------------+ | File Name | Page Number | +========================================+===============+ | EmbedAnything/test_files/attention.pdf | 6 | +----------------------------------------+---------------+ | EmbedAnything/test_files/attention.pdf | 9 | +----------------------------------------+---------------+ | EmbedAnything/test_files/linear.pdf | 34 | +----------------------------------------+---------------+ | EmbedAnything/test_files/attention.pdf | 3 | +----------------------------------------+---------------+ | EmbedAnything/test_files/attention.pdf | 15 | +----------------------------------------+---------------+ ``` -------------------------------- ### Runtime Error Traceback Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Example of a runtime error encountered during document loading. ```text Error (truncated): ---> 57 raise RuntimeError(f"Error loading {self.file_path}") from e  59 metadata = {"source": self.file_path}  60 return [Document(page_content=text, metadata=metadata)] RuntimeError: Error loading michael_jackson.txt ``` -------------------------------- ### Install Modern Python via Homebrew Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/troubleshooting.md Use a Homebrew-installed Python version, which is built against the current system SDK, to resolve compatibility issues. ```bash brew install python@3.13 /opt/homebrew/opt/python@3.13/bin/python3.13 -m venv .venv source .venv/bin/activate pip install embed-anything ``` -------------------------------- ### Trigger Dashboard Update Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/tracing_in_lumo.md Use this keyboard shortcut after starting the Lumo CLI or server to register the instance with the dashboard. ```text CTRL + C ``` -------------------------------- ### API Interaction with curl Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/actix_server.md Examples for creating embeddings, uploading PDFs, and checking server health using curl. ```bash # Create embeddings curl -X POST http://localhost:8080/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "model": "sentence-transformers/all-MiniLM-L12-v2", "input": ["Hello world", "How are you?"] }' # Upload PDF files for embeddings curl -X POST http://localhost:8080/v1/pdf_embeddings/upload \ -F "model=sentence-transformers/all-MiniLM-L12-v2" \ -F "files=@document1.pdf" \ -F "files=@document2.pdf" # Health check curl http://localhost:8080/health_check ``` -------------------------------- ### Log Research Iteration Status Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Gemini-Agent.md Example log output showing the current step, queries used, and the completion flag. ```text Step Number: 1 Searching with queries: Key architectural differences between SSM models and transformer models Computational efficiency comparison between SSM models and transformer models When to use SSM models versus transformer models Done: False ``` -------------------------------- ### Initialize and Use Qdrant Adapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Configure the Qdrant adapter, create an index, and stream file embeddings to the database. ```python import embed_anything from embed_anything import EmbeddingModel, WhichModel from embed_anything.vectordb import QdrantAdapter # Initialize Qdrant adapter qdrant_adapter = QdrantAdapter( url="http://localhost:6333", # Qdrant server URL api_key=None # Optional: API key for cloud Qdrant ) # Create a collection qdrant_adapter.create_index( dimension=384, metric="cosine", index_name="documents" ) # Load model and embed model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Stream to Qdrant data = embed_anything.embed_file( "test_files/document.pdf", embedder=model, adapter=qdrant_adapter ) ``` -------------------------------- ### Initialize and Use Weaviate Adapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Configure the Weaviate adapter, create an index, and stream directory embeddings. ```python import embed_anything from embed_anything import EmbeddingModel, WhichModel from embed_anything.vectordb import WeaviateAdapter # Initialize Weaviate adapter weaviate_adapter = WeaviateAdapter( url="http://localhost:8080", # Weaviate instance URL api_key=None # Optional: API key for cloud Weaviate ) # Create a collection (index) weaviate_adapter.create_index( dimension=384, metric="cosine", index_name="Documents" ) # Load model and embed model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Stream embeddings to Weaviate data = embed_anything.embed_directory( "test_files/", embedder=model, adapter=weaviate_adapter ) ``` -------------------------------- ### Build Docker Image from Source Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Instructions for building a custom Docker image using the provided server.Dockerfile. ```bash docker build -f server.Dockerfile -t embedanything-server . docker run -p 8080:8080 embedanything-server ``` -------------------------------- ### Initialize and Use Milvus Adapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Configure the Milvus adapter, create an index, and stream directory embeddings to the database. ```python import embed_anything from embed_anything import EmbeddingModel, WhichModel from embed_anything.vectordb import MilvusAdapter # Initialize Milvus adapter milvus_adapter = MilvusAdapter( host="localhost", # Milvus host port=19530, # Milvus port user=None, # Optional: username password=None # Optional: password ) # Create a collection milvus_adapter.create_index( dimension=384, metric="cosine", index_name="documents" ) # Load model and embed model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Stream to Milvus data = embed_anything.embed_directory( "test_files/", embedder=model, adapter=milvus_adapter ) ``` -------------------------------- ### Initialize and use Elasticsearch adapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/adapters.md Configure the Elasticsearch adapter, create an index, and stream file embeddings directly to the database. ```python import embed_anything import os from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig from embed_anything.vectordb import ElasticAdapter # Initialize Elasticsearch adapter es_adapter = ElasticAdapter( url="http://localhost:9200", # Elasticsearch URL api_key=None # Optional: API key for cloud Elasticsearch ) # Create an index es_adapter.create_index( dimension=384, # Embedding dimension metric="cosine", # Similarity metric index_name="documents" ) # Load embedding model model = EmbeddingModel.from_pretrained_hf( model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Embed files and stream to Elasticsearch config = TextEmbedConfig(chunk_size=1000, batch_size=32) data = embed_anything.embed_file( "test_files/document.pdf", embedder=model, config=config, adapter=es_adapter # Streams directly to Elasticsearch ) ``` -------------------------------- ### Initialize and Embed Documents with Qwen3 Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/Qwen.md Demonstrates loading the Qwen3-Embedding model from Hugging Face and processing a PDF file into embeddings using a specified configuration. ```python from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig, Dtype import numpy as np # Initialize Qwen3 embedding model model = EmbeddingModel.from_pretrained_hf( model_id="Qwen/Qwen3-Embedding-0.6B", dtype=Dtype.F32 # Use float32 for best quality, F16 for faster inference ) # Configure embedding parameters config = TextEmbedConfig( chunk_size=1000, batch_size=2, splitting_strategy="sentence" ) # Embed a document data = model.embed_file("test_files/document.pdf", config=config) # Access embeddings for item in data: print(f"Text: {item.text[:200]}...") print(f"Embedding dimension: {len(item.embedding)}") ``` -------------------------------- ### Initialize and Use PineconeAdapter Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/adapter-development-guide.md Demonstrates how to configure the Pinecone adapter, manage indices, and perform file or directory embedding operations. ```python # Initialize the PineconeEmbedder class api_key = os.environ.get("PINECONE_API_KEY") index_name = "anything" pinecone_adapter = PineconeAdapter(api_key) # Delete existing index if it exists try: pinecone_adapter.delete_index("anything") except: pass # Create a new index pinecone_adapter.create_index(dimension=512, metric="cosine") # Initialize the embedding model model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Embed a PDF file data = embed_anything.embed_file( "test-file", embedder=model, adapter=pinecone_adapter, ) # Embed all images in a directory data = embed_anything.embed_image_directory( "test_files", embedder=model, adapter=pinecone_adapter ) print(data) ``` -------------------------------- ### Download benchmark document Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Download a PDF file for benchmarking purposes. ```bash !wget https://www.biorxiv.org/content/10.1101/2025.01.23.634433v1.full.pdf -O EmbedAnything/bench/medicine.pdf ``` -------------------------------- ### GET /health_check Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Checks the operational status of the server. ```APIDOC ## GET /health_check ### Description Returns a 200 OK status if the server is running. ### Method GET ### Endpoint /health_check ``` -------------------------------- ### Build Video Support on Windows Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/video.md Set the FFMPEG_BIN environment variable and build the project with the video feature enabled. ```powershell $env:FFMPEG_BIN = "C:\path\to\ffmpeg.exe" ``` ```powershell cargo build --features video # Python (maturin) maturin develop --features "extension-module,video" ``` -------------------------------- ### GET /health_check Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Checks the health status of the Lumo server. ```APIDOC ## GET /health_check ### Description Performs a health check to verify the server is running. ### Method GET ### Endpoint http://localhost:8080/health_check ``` -------------------------------- ### Initialize and Use Qwen3 Reranker Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/Qwen3_Reranker.md Initialize the reranker and process documents for a query using specific formatting requirements. ```python from embed_anything import Reranker, Dtype # Qwen3 Reranker requires additional formatting def format_query(query: str, instruction=None): """You may add instruction to get better results in specific fields.""" if instruction is None: instruction = "Given a web search query, retrieve relevant passages that answer the query" return f": {instruction}\n: {query}\n" def format_document(doc: str): return f": {doc}" # Initialize the Qwen3 reranker reranker = Reranker.from_pretrained( "zhiqing/Qwen3-Reranker-0.6B-ONNX", dtype=Dtype.F32 ) # Rerank documents for a query query = ["What is machine learning?"] documents = [ "Machine learning is a subset of AI.", "The weather is sunny today.", "ML algorithms can learn from data.", "Pizza is a popular food." ] # Format query and documents query = [format_query(x) for x in query] documents = [format_document(x) for x in documents] results = reranker.rerank(query, documents, top_k=2) # Display results for result in results: print(f"Query: {result.query}") for doc in result.documents: print(f" Rank {doc.rank}: {doc.document}") print(f" Score: {doc.relevance_score:.4f}") ``` -------------------------------- ### Generate Embeddings with Python Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Example using the requests library to interact with the EmbedAnything API. ```python import requests # Create embeddings response = requests.post( "http://localhost:8080/v1/embeddings", json={ "model": "sentence-transformers/all-MiniLM-L12-v2", "input": ["The quick brown fox jumps over the lazy dog"] } ) if response.status_code == 200: data = response.json() print(f"Generated {len(data['data'])} embeddings") print(f"First embedding dimension: {len(data['data'][0]['embedding'])}") else: print(f"Error: {response.json()}") ``` -------------------------------- ### Initialize SingleStoreDB Vector Store Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Initializes a vector database from documents using LangChain and OpenAI embeddings. ```python # import openai # from langchain.text_splitter import CharacterTextSplitter # from langchain_community.document_loaders import TextLoader # from langchain_community.embeddings import OpenAIEmbeddings # from langchain_community.vectorstores.singlestoredb import SingleStoreDB # from openai import OpenAI # import os # import pandas as pd # # Load and process documents # loader = TextLoader("michael_jackson.txt") # use your own document # documents = loader.load() # text_splitter = CharacterTextSplitter(chunk_size=2000, chunk_overlap=0) # docs = text_splitter.split_documents(documents) # # Generate embeddings and create a document search database # embeddings = OpenAIEmbeddings(api_key=OPENAI_KEY) # # Create Vector Database # vector_database = SingleStoreDB.from_documents(docs, embeddings, table_name="mjackson") # create your own table # query = "How old was Michael Jackson when he died?" # docs = vector_database.similarity_search(query) # print(docs[0].page_content) ``` -------------------------------- ### Load documents and create vector database Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Load a PDF document, split it into chunks, and ingest into SingleStoreDB. ```python from langchain_community.vectorstores.singlestoredb import SingleStoreDB from langchain_community.document_loaders import PyPDFLoader from langchain.text_splitter import CharacterTextSplitter loader = PyPDFLoader("EmbedAnything/bench/medicine.pdf") # use your own document documents = loader.load() text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) docs = text_splitter.split_documents(documents) vector_database = SingleStoreDB.from_documents(docs, embedding= embedding_fn, table_name = "demo_med") # create your own table ``` -------------------------------- ### List benchmark files Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Verify the presence of downloaded files in the benchmark directory. ```bash !cd EmbedAnything/bench && ls ``` -------------------------------- ### Embeddings API Request and Response Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Example JSON payload for the /v1/embeddings endpoint and the corresponding response structure. ```json { "model": "sentence-transformers/all-MiniLM-L12-v2", "input": ["The quick brown fox jumps over the lazy dog"] } ``` ```json { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.0023064255, -0.009327292, ...] } ], "model": "sentence-transformers/all-MiniLM-L12-v2", "usage": { "prompt_tokens": 9, "total_tokens": 9 } } ``` -------------------------------- ### Initialize and Embed Data with EmbedAnything Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/memory_leak.md Demonstrates initializing a HuggingFace model and using it to process files and image directories for vector storage. ```python # Initialize the embedding model model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # Embed a PDF file data = embed_anything.embed_file( "test-file", embedder=model, adapter=pinecone_adapter, ) # Embed all images in a directory data = embed_anything.embed_image_directory( "test_files", embedder=model, adapter=pinecone_adapter ) ``` -------------------------------- ### Initialize and Run Agent Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/EmbedAnything_X_smolagent.ipynb Initializes a CodeAgent with the custom retriever tools and executes a multi-domain query. ```python import datasets from smolagents import Tool import lancedb import embed_anything from embed_anything import EmbeddingModel, WhichModel, ONNXModel from uuid import uuid4 from smolagents import CodeAgent, OpenAIServerModel, TransformersModel, DuckDuckGoSearchTool from google.colab import userdata api_key = os.environ.get('OPENAI_API_KEY') # Get the key from environment variables retriever_tool = RetrieverTool("downloaded_docs") medical_tool = MedicalRetrieverTool("medical_docs") # medical_tool = RetrieverTool("downloaded_docs") agent = CodeAgent( tools=[retriever_tool, medical_tool], model=OpenAIServerModel(model_id = "gpt-4o-mini", api_base = "https://api.openai.com/v1/", api_key = api_key), verbosity_level=2, ) agent_output = agent.run("What are the different policies for indian manufacturing and what are the medical risks of radiotherapy?") print("Final output:") print(agent_output) ``` -------------------------------- ### Initialize Qwen 3 Embedding Model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load the Qwen 3 embedding model. ```python # Initialize the model once model:EmbeddingModel = EmbeddingModel.from_pretrained_hf( WhichModel.Qwen3, model_id="Qwen/Qwen3-Embedding-0.6B" ) ``` -------------------------------- ### Embed Files and Directories Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/embed-anything.md Initialize a pre-trained HuggingFace model and embed a file using a specific configuration. ```python model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="model link from huggingface" ) config = TextEmbedConfig(chunk_size=200, batch_size=32) data = embed_anything.embed_file("file_address", embedder=model, config=config) ``` -------------------------------- ### Configure Text Embedding Strategies Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/config.md Demonstrates how to initialize different TextEmbedConfig objects for semantic, late, and simple sentence-based chunking. ```python # Basic semantic chunking configuration semantic_encoder = EmbeddingModel.from_pretrained_hf( WhichModel.Jina, model_id="jinaai/jina-embeddings-v2-small-en" ) config_semantic = TextEmbedConfig( chunk_size=1000, batch_size=16, splitting_strategy="semantic", semantic_encoder=semantic_encoder ) # Late chunking configuration for complex documents config_late_chunking = TextEmbedConfig( chunk_size=1500, batch_size=8, splitting_strategy="sentence", late_chunking=True ) # Simple sentence-based chunking config_simple = TextEmbedConfig( chunk_size=800, batch_size=24, splitting_strategy="sentence" ) ``` -------------------------------- ### Deploy Lumo Server with Docker Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Build and run the Lumo server container, ensuring all necessary API keys are provided as environment variables. ```bash # Build the image docker build -f server.Dockerfile -t lumo-server . # Run the container with required API keys docker run -p 8080:8080 \ -e OPENAI_API_KEY=your-openai-key \ -e GOOGLE_API_KEY=your-google-key \ -e GROQ_API_KEY=your-groq-key \ -e ANTHROPIC_API_KEY=your-anthropic-key \ -e EXA_API_KEY=your-exa-key \ lumo-server ``` ```bash docker pull akshayballal95/lumo-server:latest ``` -------------------------------- ### Initialize and Run Smolagent Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Smolagent.md Sets up a CodeAgent with multiple retrieval tools and an OpenAI model to process complex, multi-part queries. ```python retriever_tool = RetrieverTool("downloaded_docs") medical_tool = MedicalRetrieverTool("medical_docs") agent = CodeAgent( tools=[retriever_tool, medical_tool], model=OpenAIServerModel(model_id = "gpt-4o-mini", api_base = "https://api.openai.com/v1/", api_key = api_key), verbosity_level=2, ) agent_output = agent.run("What are the different policies for indian manufacturing and what are the medical risks of radiotherapy?") ``` -------------------------------- ### Embed PDF Files with ColPali Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/colpali.md Demonstrates loading the ColPali model and embedding PDF files from a directory. ```python from embed_anything import ColpaliModel import numpy as np from pathlib import Path # Load ColPali model (Candle backend) model = ColpaliModel.from_pretrained("vidore/colpali-v1.2-merged", None) # Or load ONNX model for faster inference # model = ColpaliModel.from_pretrained_onnx( # "starlight-ai/colpali-v1.2-merged-onnx", # None # ) # Get all PDF files in a directory directory = Path("test_files") files = list(directory.glob("*.pdf")) # Embed all PDF files file_embed_data = [] for file in files: try: # Embed each file (returns page-level embeddings) embedding = model.embed_file(str(file), batch_size=1) file_embed_data.extend(embedding) except Exception as e: print(f"Error embedding file {file}: {e}") print(f"Total pages embedded: {len(file_embed_data)}") ``` -------------------------------- ### POST /run Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Executes a task using the specified model and tools. ```APIDOC ## POST /run ### Description Submits a task to the Lumo server for execution by an agent. ### Method POST ### Endpoint http://localhost:8080/run ### Parameters #### Request Body - **task** (string) - Required - The task to execute - **model** (string) - Required - Model ID (e.g., "gpt-4", "qwen2.5", "gemini-2.0-flash") - **base_url** (string) - Required - Base URL for the API - **tools** (array) - Optional - Array of tool names to use - **max_steps** (integer) - Optional - Maximum number of steps to take - **agent_type** (string) - Optional - Type of agent to use ("function-calling" or "mcp") - **history** (array) - Optional - Array of previous messages for context ### Request Example { "task": "What are the files in the folder?", "model": "gpt-4o-mini", "base_url": "https://api.openai.com/v1/chat/completions", "tools": ["DuckDuckGo", "VisitWebsite"], "max_steps": 5, "agent_type": "mcp" } ``` -------------------------------- ### Initialize and Use Reranker Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load a reranker model and perform reranking on query-document pairs. ```python reranker = Reranker.from_pretrained("jinaai/jina-reranker-v1-turbo-en", dtype=Dtype.F16) results: list[RerankerResult] = reranker.rerank(["What is the capital of France?"], ["France is a country in Europe.", "Paris is the capital of France."], 2) ``` -------------------------------- ### Initialize Custom Hugging Face Model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load a model from Hugging Face using the from_pretrained_hf method and configure embedding parameters. ```python model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="model link from huggingface" ) config = TextEmbedConfig(chunk_size=1000, batch_size=32) data = embed_anything.embed_file("file_address", embedder=model, config=config) ``` -------------------------------- ### Clone the EmbedAnything repository Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/colpali.md Downloads the repository containing test PDF files for the demonstration. ```python if not os.path.exists("EmbedAnything"): !git clone https://github.com/StarlightSearch/EmbedAnything.gi ``` -------------------------------- ### Optimize Qwen3 performance with precision and batching Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/Qwen.md Configure the model with F16 precision for faster inference and adjust batch size to improve GPU throughput. ```python from embed_anything import EmbeddingModel, WhichModel, Dtype # Use F16 for faster inference with minimal quality loss model = EmbeddingModel.from_pretrained_hf( WhichModel.Qwen3, model_id="Qwen/Qwen3-Embedding-0.6B", dtype=Dtype.F16 # Half precision for 2x speedup ) # Increase batch size for better throughput config = TextEmbedConfig( chunk_size=1000, batch_size=8, # Larger batch for better GPU utilization splitting_strategy="sentence" ) ``` -------------------------------- ### Assert package versions Source: https://github.com/starlightsearch/embedanything/blob/main/docs/superpowers/plans/2026-07-10-0.7.1-release.md Use jq to filter and display the version of specific workspace packages. ```bash cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "embed_anything" or .name == "processors-rs" or .name == "embed_anything_python" or .name == "server") | "\(.name) \(.version)"' ``` -------------------------------- ### Define the PineconeAdapter class structure Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/adapter-development-guide.md Initializes the adapter by inheriting from the base Adapter class and setting up the Pinecone client. ```python from embed_anything import EmbedData, EmbeddingModel, WhichModel, TextEmbedConfig class PineconeAdapter(Adapter): """ Adapter class for interacting with Pinecone, a vector database service. """ def __init__(self, api_key: str): """ Initializes a new instance of the PineconeAdapter class. Args: api_key (str): The API key for accessing the Pinecone service. """ super().__init__(api_key) self.pc = Pinecone(api_key=self.api_key) self.index_name = None ``` -------------------------------- ### Initialize cloud-based embedding models Source: https://github.com/starlightsearch/embedanything/blob/main/README.md Configure cloud models like Cohere for high-quality embeddings without local deployment. Requires setting the appropriate API key in the environment variables. ```python import embed_anything from embed_anything import EmbeddingModel, WhichModel import os # Set your API key os.environ["COHERE_API_KEY"] = "your-api-key-here" # Initialize the cloud model model = EmbeddingModel.from_pretrained_cloud( WhichModel.CohereVision, model_id="embed-v4.0" ) # Use it like any other model data = embed_anything.embed_file("test_files/document.pdf", embedder=model) ``` -------------------------------- ### Verify Python distribution Source: https://github.com/starlightsearch/embedanything/blob/main/docs/superpowers/plans/2026-07-10-0.7.1-release.md Build the Python wheel to confirm the version is correctly applied to the distribution. ```bash maturin build --manifest-path python/Cargo.toml --release --out /tmp/embedanything-0.7.1-dist ``` -------------------------------- ### Integrate AWS S3 with EmbedAnything Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Demonstrates fetching files from S3 and embedding them using either explicit credentials or environment variables. ```python from embed_anything import S3Client, EmbeddingModel, WhichModel, TextEmbedConfig # Create S3Client with credentials s3_client = S3Client( access_key_id="your-access-key-id", secret_access_key="your-secret-access-key", region="us-east-1" ) # Fetch a file from S3 file = s3_client.get_file_from_s3( bucket_name="your-bucket-name", key="path/to/your/file.txt" ).save_file() # Embed the file embedder = EmbeddingModel.from_pretrained_hf( model_id="jinaai/jina-embeddings-v2-small-en" ) embeddings = embedder.embed_file( file, config=TextEmbedConfig( chunk_size=1000, batch_size=32, splitting_strategy="sentence" ) ) ``` ```python from embed_anything import S3Client # Create S3Client from environment variables # Reads from: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION s3_client = S3Client.from_env() # Fetch and use files as above file = s3_client.get_file_from_s3( bucket_name="your-bucket-name", key="path/to/your/file.pdf" ).save_file() ``` -------------------------------- ### Verify workspace metadata Source: https://github.com/starlightsearch/embedanything/blob/main/docs/superpowers/plans/2026-07-10-0.7.1-release.md Check the current workspace package configuration and versioning. ```bash cargo metadata --no-deps --format-version 1 ``` -------------------------------- ### Import Langchain vector store and embedding utilities Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Imports the necessary classes for OpenAI embeddings and SingleStoreDB vector storage integration. ```python from langchain_community.embeddings import OpenAIEmbeddings from langchain_core.embeddings import Embeddings from langchain_community.vectorstores.singlestoredb import SingleStoreDB ``` -------------------------------- ### Initialize Splade Models Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load a SparseBert model for Splade-based embeddings. ```python model = EmbeddingModel.from_pretrained_hf( WhichModel.SparseBert, "prithivida/Splade_PP_en_v1" ) ``` -------------------------------- ### Configure Video Embedding Parameters Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/video.md Initialize VideoEmbedConfig to control frame sampling frequency, maximum frame count, and batch size. ```python from embed_anything import VideoEmbedConfig config = VideoEmbedConfig(frame_step=30, max_frames=300, batch_size=16) ``` -------------------------------- ### Verify Python SDK Version Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/troubleshooting.md Check the minimum OS version (minos) and SDK version of the current Python interpreter using otool. ```bash otool -l "$(python -c 'import sys; print(sys.executable)')" | grep -A3 LC_BUILD_VERSION ``` -------------------------------- ### Initialize ColPali and Process PDFs Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/colpali.ipynb Load the ColPali model from a pre-trained ONNX source and define a function to embed PDF files. ```python import base64 from embed_anything import EmbedData, ColpaliModel import numpy as np from tabulate import tabulate from pathlib import Path from PIL import Image import io import torch model: ColpaliModel = ColpaliModel.from_pretrained_onnx("starlight-ai/colpali-v1.2-merged-onnx", None) def process_pdf(files, model:ColpaliModel): file_embed_data: list[EmbedData] = [] for file in files: try: embedding: list[EmbedData] = model.embed_file(str(file), batch_size=1) file_embed_data.extend(embedding) except Exception as e: print(f"Error embedding file {file}: {e}") return file_embed_data ``` -------------------------------- ### Configure TextEmbedConfig for different performance profiles Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/config.md Adjust chunk size, batch size, and splitting strategies to balance resource usage and processing speed. ```python # Conservative approach for limited resources config = TextEmbedConfig(chunk_size=1000, batch_size=8, splitting_strategy="sentence") # Aggressive approach for high-performance systems config = TextEmbedConfig(chunk_size=1000, batch_size=32, splitting_strategy="semantic") ``` -------------------------------- ### Initialize Cohere cloud embedding model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/ReleaseNotes5-5.md Use the cloud-based Cohere Vision model for handling large documents and multimodal inputs. ```python # Initialize the model once model: EmbeddingModel = EmbeddingModel.from_pretrained_cloud( WhichModel.CohereVision, model_id="embed-v4.0" ) ``` -------------------------------- ### Load the ColPali ONNX model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/colpali.md Initializes the ColPali model using the ONNX format. Note that this process may take time as it involves downloading model weights. ```python model: ColpaliModel = ColpaliModel.from_pretrained_onnx("starlight-ai/colpali-v1.2-merged-onnx", None) ``` -------------------------------- ### Embed files with custom configuration Source: https://github.com/starlightsearch/embedanything/blob/main/README.md Load a Hugging Face model and embed a file using specific chunking and batching parameters. ```python import embed_anything from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig # Load model model = EmbeddingModel.from_pretrained_hf( model_id="jinaai/jina-embeddings-v2-small-en" ) # Configure embedding parameters config = TextEmbedConfig( chunk_size=1000, # Characters per chunk batch_size=32, # Process 32 chunks at once buffer_size=64, # Buffer size for streaming splitting_strategy="sentence" # Split by sentences ) # Embed with custom configuration data = embed_anything.embed_file( "test_files/document.pdf", embedder=model, config=config ) # Process embeddings for item in data: print(f"Chunk: {item.text}") print(f"Metadata: {item.metadata}") ``` -------------------------------- ### Expected version output Source: https://github.com/starlightsearch/embedanything/blob/main/docs/superpowers/plans/2026-07-10-0.7.1-release.md The expected output format for package versions. ```text embed_anything 0.7.1 processors-rs 0.7.1 embed_anything_python 0.7.1 server 0.7.1 ``` -------------------------------- ### Pull and Run Prebuilt Docker Image Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/Release Notes 0.7.md Commands to pull the latest server image from Docker Hub and execute it on port 8080. ```bash docker pull starlightsearch/embedanything-server:latest ``` ```bash docker run -p 8080:8080 starlightsearch/embedanything-server:latest ``` -------------------------------- ### Initialize Colpali Model and PDF Processing Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/colpali.ipynb Sets up the Colpali model and defines a function to embed PDF files into a list of EmbedData objects. ```python import base64 from embed_anything import EmbedData, ColpaliModel import numpy as np from tabulate import tabulate from pathlib import Path from PIL import Image import io import torch model: ColpaliModel = ColpaliModel.from_pretrained("vidore/colpali-v1.2-merged", None) def process_pdf(files, model:ColpaliModel): file_embed_data: list[EmbedData] = [] for file in files: try: embedding: list[EmbedData] = model.embed_file(str(file), batch_size=1) file_embed_data.extend(embedding) except Exception as e: print(f"Error embedding file {file}: {e}") return file_embed_data ``` -------------------------------- ### Import LangChain dependencies Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/SingleStoreDB.ipynb Import necessary modules for document processing and vector storage. ```python import os import openai from langchain.text_splitter import CharacterTextSplitter from langchain_community.document_loaders import TextLoader from langchain_community.embeddings import OpenAIEmbeddings from langchain_community.vectorstores.singlestoredb import SingleStoreDB from openai import OpenAI ``` -------------------------------- ### Initialize ONNX BERT Model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load a BERT model using the ONNX runtime. ```python model = EmbeddingModel.from_pretrained_onnx( WhichModel.Bert, model_id="onnx_model_link" ) ``` -------------------------------- ### Use SigLip for Image Embedding Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/images.md Demonstrates loading a SigLip model, which can be used interchangeably with CLIP models in the library. ```python from embed_anything import EmbeddingModel # Load SigLip model model = EmbeddingModel.from_pretrained_hf( model_id="google/siglip-base-patch16-224" ) # Use it the same way as CLIP data = embed_anything.embed_image_directory("test_files", embedder=model) ``` -------------------------------- ### Authenticate with Private Models Source: https://github.com/starlightsearch/embedanything/blob/main/README.md Loads private or gated repositories by providing a Hugging Face access token. If omitted, the library defaults to the HF_TOKEN environment variable or local CLI credentials. ```python from embed_anything import EmbeddingModel model = EmbeddingModel.from_pretrained_hf( model_id="google/embeddinggemma-300m", token="hf_your_access_token", # or set the HF_TOKEN environment variable ) ``` -------------------------------- ### Perform Query Retrieval with Qwen3 Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/Qwen.md Shows how to embed a query and calculate cosine similarity against document embeddings to retrieve the most relevant chunks. ```python from embed_anything import EmbeddingModel, WhichModel, TextEmbedConfig, Dtype import numpy as np # Load model model = EmbeddingModel.from_pretrained_hf( WhichModel.Qwen3, model_id="Qwen/Qwen3-Embedding-0.6B", dtype=Dtype.F32 ) # Embed documents config = TextEmbedConfig(chunk_size=1000, batch_size=2, splitting_strategy="sentence") data = model.embed_file("test_files/document.pdf", config=config) # Embed a query query = "Which GPU is used for training" query_embedding = np.array(model.embed_query([query])[0].embedding) # Calculate similarities embedding_array = np.array([e.embedding for e in data]) similarities = np.matmul(query_embedding, embedding_array.T) # Get top 5 most relevant chunks top_5_indices = np.argsort(similarities)[-5:][::-1] print("Top 5 most relevant results:") for i, idx in enumerate(top_5_indices, 1): print(f"\n{i}. Score: {similarities[idx]:.4f}") print(f" Text: {data[idx].text[:200]}...") ``` -------------------------------- ### Comparing Chunking Strategies Source: https://github.com/starlightsearch/embedanything/blob/main/docs/guides/semantic.md Shows the configuration difference between standard sentence-based splitting and semantic splitting. ```python config = TextEmbedConfig( chunk_size=1000, splitting_strategy="sentence" # Simple sentence splitting ) ``` ```python config = TextEmbedConfig( chunk_size=1000, splitting_strategy="semantic", semantic_encoder=semantic_encoder ) ``` -------------------------------- ### Configure Semantic Chunking Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Set up a semantic encoder and configuration for semantic splitting strategies. ```python model = EmbeddingModel.from_pretrained_hf( WhichModel.Bert, model_id="sentence-transformers/all-MiniLM-L12-v2" ) # with semantic encoder semantic_encoder = EmbeddingModel.from_pretrained_hf(WhichModel.Jina, model_id = "jinaai/jina-embeddings-v2-small-en") config = TextEmbedConfig(chunk_size=1000, batch_size=32, splitting_strategy = "semantic", semantic_encoder=semantic_encoder) ``` -------------------------------- ### Initialize Embedding Model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/vector-streaming.md Configures the CLIP model for image embedding tasks. ```python import embed_anything import WhichModel model = embed_anything.EmbeddingModel.from_pretrained_hf( embed_anything.WhichModel.Clip, model_id="openai/clip-vit-base-patch16", # revision="refs/pr/15", ) ``` -------------------------------- ### Initialize and Use ONNX Colbert Model Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Load a Colbert model via ONNX and perform embedding on a list of sentences. ```python sentences = [ "The quick brown fox jumps over the lazy dog", "The cat is sleeping on the mat", "The dog is barking at the moon", "I love pizza", "The dog is sitting in the park"] model = ColbertModel.from_pretrained_onnx("jinaai/jina-colbert-v2", path_in_repo="onnx/model.onnx") embeddings = model.embed(sentences, batch_size=2) ``` -------------------------------- ### Configure MCP Servers Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/lumo.md Define MCP server configurations in the platform-specific YAML file to enable agent tool usage. ```text Linux: ~/.config/lumo-cli/servers.yaml macOS: ~/Library/Application Support/lumo-cli/servers.yaml Windows: %APPDATA%\Roaming\lumo\lumo-cli\servers.yaml ``` ```yaml exa-search: command: npx args: - "exa-mcp-server" env: EXA_API_KEY: "your-api-key" fetch: command: uvx args: - "mcp_server_fetch" system_prompt: |- You are a powerful agentic AI assistant... ``` -------------------------------- ### Execute Search and Visualize Results Source: https://github.com/starlightsearch/embedanything/blob/main/examples/notebooks/colpali.ipynb Runs the PDF processing and query pipeline, then displays the top matching pages using matplotlib. ```python # Get all PDF files in the directory directory = Path("../../test_files") files = list(directory.glob("*.pdf")) file_embed_data = process_pdf(files, model) query = "What is the first page of the pdf" query_embeddings = process_query(query, model) images, results_str = score(query_embeddings, file_embed_data) import matplotlib.pyplot as plt # show the images side by side using subplots fig, axs = plt.subplots(1, len(images), figsize=(20, 15)) for i, image in enumerate(images): axs[i].imshow(image) axs[i].axis('off') plt.show(); ``` -------------------------------- ### Load and use embedding models Source: https://github.com/starlightsearch/embedanything/blob/main/docs/index.md Basic usage for loading a pretrained model and embedding a file. ```python model = EmbeddingModel.from_pretrained_local( WhichModel.Bert, model_id="Hugging_face_link" ) data = embed_anything.embed_file("test_files/test.pdf", embedder=model) ``` -------------------------------- ### Configure semantic encoder Source: https://github.com/starlightsearch/embedanything/blob/main/docs/blog/posts/config.md Sets up a Jina-based semantic encoder required for semantic chunking strategies. ```python semantic_encoder = EmbeddingModel.from_pretrained_hf( WhichModel.Jina, model_id="jinaai/jina-embeddings-v2-small-en" ) ```