{"id":14065775,"url":"https://github.com/complexdb/zincbase","last_synced_at":"2025-07-29T21:33:37.472Z","repository":{"id":57478337,"uuid":"237141678","full_name":"complexdb/zincbase","owner":"complexdb","description":"A state of the art knowledge base","archived":false,"fork":false,"pushed_at":"2020-06-01T02:30:25.000Z","size":12292,"stargazers_count":170,"open_issues_count":6,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T13:44:45.441Z","etag":null,"topics":["graph-embedding","knowledge-base","knowledge-graph","prolog"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/complexdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-30T04:54:46.000Z","updated_at":"2024-08-15T02:04:06.000Z","dependencies_parsed_at":"2022-09-06T10:12:12.807Z","dependency_job_id":null,"html_url":"https://github.com/complexdb/zincbase","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complexdb%2Fzincbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complexdb%2Fzincbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complexdb%2Fzincbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complexdb%2Fzincbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/complexdb","download_url":"https://codeload.github.com/complexdb/zincbase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228052622,"owners_count":17862103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-embedding","knowledge-base","knowledge-graph","prolog"],"created_at":"2024-08-13T07:04:43.095Z","updated_at":"2024-12-04T05:30:57.498Z","avatar_url":"https://github.com/complexdb.png","language":"Python","readme":"[![CircleCI](https://circleci.com/gh/complexdb/zincbase.svg?style=svg)](https://circleci.com/gh/complexdb/zincbase)\n[![DOI](https://zenodo.org/badge/183831265.svg)](https://zenodo.org/badge/latestdoi/183831265)\n[![Documentation Status](https://readthedocs.org/projects/zincbase/badge/?version=latest)](https://zincbase.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version fury.io](https://badge.fury.io/py/zincbase.svg)](https://pypi.python.org/pypi/zincbase/)\n[![PyPI download month](https://img.shields.io/pypi/dm/zincbase.svg)](https://pypi.python.org/pypi/zincbase/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/zincbase.svg)](https://pypi.python.org/pypi/zincbase/)\n[![PyPI license](https://img.shields.io/pypi/l/zincbase.svg)](https://pypi.python.org/pypi/zincbase/)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/2245347/57199440-c45daf00-6f33-11e9-91df-1a6a9cae6fb7.png\" width=\"140\" alt=\"Zincbase logo\"\u003e\n\nZincBase is a state of the art knowledge base and complex simulation suite. It does the following:\n\n* Store and retrieve graph structured data efficiently.\n* Provide ways to query the graph, including via bleeding-edge graph neural networks.\n* Simulate complex effects playing out across the graph and see how predictions change.\n\nZincbase exists to answer questions like \"what is the probability that Tom likes LARPing\", or \"who likes LARPing\", or \"classify people into LARPers vs normies\", or simulations like \"what happens if all the LARPers become normies\".\n\n\u003cimg src=\"https://user-images.githubusercontent.com/2245347/57595488-2dc45b80-74fa-11e9-80f4-dc5c7a5b22de.png\" width=\"320\" alt=\"Example graph for reasoning\"\u003e\n\nIt combines the latest in neural networks with symbolic logic (think expert systems and prolog), graph search, and complexity theory.\n\nView full documentation [here](https://zincbase.readthedocs.io).\n\n## Quickstart\n\n`pip3 install zincbase`\n\n```\nfrom zincbase import KB\nkb = KB()\nkb.store('eats(tom, rice)')\nfor ans in kb.query('eats(tom, Food)'):\n    print(ans['Food']) # prints 'rice'\n\n...\n# The included assets/countries_s1_train.csv contains triples like:\n# (namibia, locatedin, africa)\n# (lithuania, neighbor, poland)\n\nkb = KB()\nkb.from_csv('./assets/countries_s1_train.csv', delimiter='\\t')\nkb.build_kg_model(cuda=False, embedding_size=40)\nkb.train_kg_model(steps=8000, batch_size=1, verbose=False)\nkb.estimate_triple_prob('fiji', 'locatedin', 'melanesia')\n0.9607\n```\n\n# Requirements\n\n* Python 3\n* Libraries from requirements.txt\n* GPU preferable for large graphs but not required\n\n# Installation\n\n`pip install -r requirements.txt`\n\n_Note:_ Requirements might differ for PyTorch depending on your system.\n\n# Web UI\n\nZincbase can serve live-updating force-directed graphs in 3D to a web browser. The command\n`python -m zincbase.web` will set up a static file server and a websocket\nserver for live updates. Visit `http://localhost:5000/` in your browser\nand you'll see the graph UI. As you build a graph in Python, you can\nvisualize it (and changes to it) in realtime through this UI.\n\nHere are a couple of examples (source code [here](https://github.com/complexdb/zincbase/tree/master/examples/visualization)):\n\n![Peek 2020-03-21 12-34](https://user-images.githubusercontent.com/2245347/77235135-93e52a80-6b70-11ea-89ca-fe01f83708ff.gif)\n\n![Peek 2020-03-21 12-39](https://user-images.githubusercontent.com/2245347/77235199-0f46dc00-6b71-11ea-8380-6698283c98f6.gif)\n\n# Complexity (Graph/Network) Examples\n\nTwo such examples are included (right now; we intend to include more soon such\nas virus spread and neural nets that communicate.) The examples are\nbasic ones: Conway's Game of Life and the Abelian Sandpile. Here are some\nscreencaps; source code is [here](https://github.com/complexdb/zincbase/tree/master/examples),\nperformance can be lightning fast depending how you tweak Zincbase recursion\nand propagation settings.\n\n![Peek 2020-03-06 23-53](https://user-images.githubusercontent.com/2245347/76139614-94c17c80-6006-11ea-8690-9059cd1a4672.gif)\n![Peek 2020-03-06 23-55](https://user-images.githubusercontent.com/2245347/76139591-4a400000-6006-11ea-96fc-ab3943834886.gif)\n\n### Required for the UI\n\n* You should `pip install zincbase[web]` to get the optional web extra.\n* You should have Redis running; by default, at `localhost:6379`. This\nis easily achievable, just do `docker run -p 6379:6379 -d redis`\n\n# Testing\n\n```\npython test/test_main.py\npython test/test_graph.py\n... etc ... all the test files there\npython -m doctest zincbase/zincbase.py\n```\n\n# Validation\n\n\"Countries\" and \"FB15k\" datasets are included in this repo.\n\nThere is a script to evaluate that ZincBase gets at least as good\nperformance on the Countries dataset as the original (2019) RotatE paper. From the repo's\nroot directory:\n\n```\npython examples/eval_countries_s3.py\n```\n\nIt tests the hardest Countries task and prints out the AUC ROC, which should be\n~ 0.95 to match the paper. It takes about 30 minutes to run on a modern GPU.\n\nThere is also a script to evaluate performance on FB15k: `python examples/fb15k_mrr.py`.\n\n## Running the web UI\n\nThere are a couple of extra requirements -- install with `pip3 install zincbase[web]`.\nYou also need an accessible Redis instance somewhere. This one-liner will get it running\nlocally: `docker run -p 6379:6379 -d redis` (requires Docker, of course.)\n\nYou then need a Zincbase server instance running:\n\n## Building documentation\n\nFrom docs/ dir: `make html`. If something changed a lot: `sphinx-apidoc -o . ..`\n\n## Pushing to pypi\n\nNOTE: This is now all automatic via CircleCI, but here are the manual steps for reference:\n\n* Edit `setup.py` as appropriate (probably not necessary)\n* Edit the version in `zincbase/__init__.py`\n* From the top project directory `python setup.py sdist bdist_wheel --universal`\n* `twine upload dist/*`\n\n# TODO\n\n* add ability to `kb = KB(backend='complexdb://my_api_key')`\n* utilize postgres as backend triple store\n* Reinforcement learning for graph traversal.\n* Rete algorithm (maybe)\n\n# References \u0026 Acknowledgements\n\n[Theo Trouillon. Complex-Valued Embedding Models for Knowledge Graphs. Machine Learning[cs.LG]. Université Grenoble Alpes, 2017. English. ffNNT : 2017GREAM048](https://tel.archives-ouvertes.fr/tel-01692327/file/TROUILLON_2017_archivage.pdf)\n\n[L334: Computational Syntax and Semantics -- Introduction to Prolog, Steve Harlow](http://www-users.york.ac.uk/~sjh1/courses/L334css/complete/complete2li1.html)\n\n[Open Book Project: Prolog in Python, Chris Meyers](http://www.openbookproject.net/py4fun/prolog/intro.html)\n\n[Prolog Interpreter in Javascript](https://curiosity-driven.org/prolog-interpreter)\n\n[RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space, Zhiqing Sun and Zhi-Hong Deng and Jian-Yun Nie and Jian Tang, International Conference on Learning Representations, 2019](https://openreview.net/forum?id=HkgEQnRqYQ)\n\n# Citing\n\nIf you use this software, please consider citing:\n\n```\n@software{zincbase,\n  author = {{Tom Grek}},\n  title = {ZincBase: A state of the art knowledge base},\n  url = {https://github.com/tomgrek/zincbase},\n  version = {0.1.1},\n  date = {2019-05-12}\n}\n\n```\n\n# Contributing\n\nSee CONTRIBUTING. And please do!","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplexdb%2Fzincbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomplexdb%2Fzincbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplexdb%2Fzincbase/lists"}