{"id":9653,"library":"deepsearch-glm","title":"DeepSearch Graph Language Models","description":"deepsearch-glm is a Python library that enables the creation and querying of Graph Language Models (GLMs). It integrates Large Language Models (LLMs) with knowledge graphs derived from unstructured documents, primarily leveraging the `deepsearch-toolkit` library for graph processing. The current version is 1.0.0, and it's actively developed by DeepSearch AI, with releases expected to follow a feature-driven cadence.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/deepsearch-ai/deepsearch-glm","tags":["LLM","graph-neural-networks","knowledge-graph","document-ai","transformers","deepsearch"],"install":[{"cmd":"pip install deepsearch-glm","lang":"bash","label":"Basic Install"},{"cmd":"pip install deepsearch-glm[all]","lang":"bash","label":"Install with all optional dependencies (includes ML backends)"}],"dependencies":[{"reason":"Core dependency for graph processing and document models.","package":"deepsearch-toolkit","optional":false},{"reason":"Required for underlying Large Language Model functionality.","package":"transformers","optional":false},{"reason":"Machine learning backend for `transformers`. Either PyTorch or TensorFlow is typically required.","package":"torch","optional":true},{"reason":"Machine learning backend for `transformers`. Either PyTorch or TensorFlow is typically required.","package":"tensorflow","optional":true}],"imports":[{"wrong":"from deepsearch_glm import GraphLanguageModel","symbol":"GraphLanguageModel","correct":"import deepsearch_glm"}],"quickstart":{"code":"import os\nfrom deepsearch.glm.core.glm import GraphLanguageModel\nfrom deepsearch.glm.queries import GlmQuery\nfrom deepsearch.documents.core.models import Document\n\n# Note: The deepsearch-glm-base model is large (~1.5GB) and will be downloaded on first run.\n# This example requires deepsearch-toolkit to implicitly process documents into a graph.\n\ntry:\n    # 1. Initialize the GraphLanguageModel (this will download a model if not cached)\n    # This might take a while and uses significant memory/disk space.\n    print(\"Loading GraphLanguageModel... (first run may download ~1.5GB model)\")\n    glm_model = GraphLanguageModel.from_pretrained(\"deepsearch-ai/deepsearch-glm-base\")\n    print(\"GraphLanguageModel loaded.\")\n\n    # 2. Prepare a dummy document. In a real scenario, this would be processed\n    # by deepsearch-toolkit to extract a knowledge graph before querying.\n    doc_content = \"The DeepSearch AI platform helps enterprises extract insights from unstructured data using advanced AI.\"\n    dummy_document = Document(name=\"deepsearch_info.txt\", content=doc_content)\n\n    # 3. Create a query\n    question = \"What is the DeepSearch AI platform used for?\"\n    query = GlmQuery(\n        model=glm_model,\n        documents=[dummy_document], # Provide documents directly for implicit graph creation\n        query_text=question\n    )\n\n    # 4. Run the query\n    print(f\"\\nQuerying: {question}\")\n    result = query.run()\n\n    # 5. Print the result\n    print(\"\\nQuery Result:\")\n    print(result.answer)\n\nexcept ImportError as e:\n    print(f\"Error: {e}. Ensure all core and optional dependencies (like 'transformers', 'torch' or 'tensorflow') are installed.\")\n    print(\"Try: pip install deepsearch-glm[all]\")\nexcept Exception as e:\n    print(f\"An error occurred during execution: {e}\")\n    print(\"Common issues include insufficient disk space, network problems during model download, or missing ML backend (torch/tensorflow).\")","lang":"python","description":"This quickstart demonstrates how to load a GraphLanguageModel and query it with a simple document. It highlights the main components and interactions within `deepsearch-glm`. Note that the first run will download a large language model."},"warnings":[{"fix":"Ensure you have sufficient disk space, RAM, and a stable internet connection. Consider pre-downloading models or using a shared cache in production environments if applicable.","message":"The `GraphLanguageModel.from_pretrained()` method will download a large language model (e.g., `deepsearch-glm-base` is ~1.5GB) on its first invocation. This requires significant disk space, memory, and an active internet connection, and may take considerable time.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Familiarize yourself with `deepsearch-toolkit` documentation for advanced graph-related tasks. Ensure `deepsearch-toolkit` is installed (it's a core dependency).","message":"While `deepsearch-glm` simplifies interaction with GLMs, its core functionality for processing documents into knowledge graphs heavily relies on `deepsearch-toolkit`. For advanced graph manipulation or custom document processing, direct usage and understanding of `deepsearch-toolkit` is often necessary.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `deepsearch-glm` with the `[all]` extra to include common optional dependencies (e.g., `pip install deepsearch-glm[all]`), or manually install your preferred backend: `pip install torch` or `pip install tensorflow`.","message":"The underlying Large Language Models (via `transformers`) require a machine learning backend like PyTorch (`torch`) or TensorFlow (`tensorflow`). While `deepsearch-glm` lists these as optional dependencies, practically, one of them is required for the library to function. You might encounter `ModuleNotFoundError` if neither is installed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':50 'activ':54 'ai':58,79 'cadenc':68 'creation':15 'current':47 'deepsearch':1,6,40,57,81 'deepsearch-glm':5 'deepsearch-toolkit':39 'deriv':32 'develop':55 'document':35,78 'document-ai':77 'driven':67 'enabl':13 'expect':61 'featur':66 'feature-driven':65 'follow':63 'glm':7 'glms':22 'graph':2,19,31,44,71,76 'graph-neural-network':70 'integr':24 'knowledg':30,75 'knowledge-graph':74 'languag':3,20,26 'larg':25 'leverag':37 'librari':11,42 'llm':69 'llms':28 'model':4,21,27 'network':73 'neural':72 'primarili':36 'process':45 'python':10 'queri':17 'releas':60 'toolkit':41 'transform':80 'unstructur':34 'version':48","created_at":"2026-04-17T01:20:01.979035+00:00","updated_at":"2026-04-17T01:20:01.979035+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/deepsearch-glm/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}