Docker Deployment
Once you've selected a YAML
configuration, make sure either the Docker Engine
or Podman Machine
is running and launch TrustGraph
with:
docker compose -f <configuration-file.yaml> up -d
When using Podman
, simply replace docker
with podman
in all TrustGraph
commands.
Verify TrustGraph Containers​
On first running a Docker Compose
file, it may take a while (depending on your network connection) to pull all the necessary components. Once all of the components have been pulled, check that the TrustGraph containers are running:
docker ps
The status of TrustGraph
services can be checked with:
tg-processor-state
To watch the status in 2 second increments:
watch tg-processor-state
On MacOS
, the watch
feature can be installed with Homebrew
:
brew install watch
Any containers that have exited unexpectedly can be found by checking the STATUS
field using the following:
docker ps -a
Before proceeding, allow the system to stabilize. A safe warm up period is 120 seconds
. If services seem to be "stuck", it could be because services did not have time to initialize correctly and are trying to restart. Waiting 120 seconds
before launching any scripts should provide much more reliable operation.
Load a Text Corpus​
Create a sources directory and get a test PDF file. To demonstrate the power of TrustGraph
, the provided script loads a PDF of the public Roger's Commision Report from the NASA Challenger disaster. This PDF includes complex formatting, unique terms, complex concepts, unique concepts, and information not commonly found in public knowledge sources.
mkdir sources
curl -o sources/Challenger-Report-Vol1.pdf https://sma.nasa.gov/SignificantIncidents/assets/rogers_commission_report.pdf
Load the file for knowledge extraction:
tg-load-pdf sources/Challenger-Report-Vol1.pdf
To load a text file, use the following script:
tg-load-text sources/<txt-file.txt>
Batch Loading​
Sets of PDF
or txt
files can be loaded at once with the loader script. Load all the files into a directory.
To load a batch of PDFs from a directory named sources
:
tg-load-pdf sources/*.pdf
To load a batch of text files from a directory named sources
:
tg-load-text sources/*.txt
Graph Parsing​
To check that the knowledge graph is successfully parsing data:
tg-graph-show
The output should be a set of semantic triples in N-Triples format.
http://trustgraph.ai/e/enterprise http://trustgraph.ai/e/was-carried to altitude and released for a gliding approach and landing at the Mojave Desert test center.
http://trustgraph.ai/e/enterprise http://www.w3.org/2000/01/rdf-schema#label Enterprise.
http://trustgraph.ai/e/enterprise http://www.w3.org/2004/02/skos/core#definition A prototype space shuttle orbiter used for atmospheric flight testing.
Number of Graph Edges​
N-Triples format is not particularly human readable. It's more useful to know how many graph edges have successfully been extracted from the text corpus:
tg-graph-show | wc -l
The Challenger report has a long introduction with quite a bit of adminstrative text commonly found in official reports. The first few hundred graph edges mostly capture this document formatting knowledge. To fully test the ability to extract complex knowledge, wait until at least 1000
graph edges have been extracted. The full extraction for this PDF will extract many thousand graph edges.
GraphRAG Test Query​
tg-query-graph-rag -q "Give me 20 facts about the space shuttle Challenger"
This script forms a LM prompt asking for 20 facts regarding the Challenger disaster. Depending on how many graph edges have been extracted, the response will be similar to:
Here are 20 facts from the provided knowledge graph about the Space Shuttle disaster:
1. **Space Shuttle Challenger was a Space Shuttle spacecraft.**
2. **The third Spacelab mission was carried by Orbiter Challenger.**
3. **Francis R. Scobee was the Commander of the Challenger crew.**
4. **Earth-to-orbit systems are designed to transport payloads and humans from Earth's surface into orbit.**
5. **The Space Shuttle program involved the Space Shuttle.**
6. **Orbiter Challenger flew on mission 41-B.**
7. **Orbiter Challenger was used on STS-7 and STS-8 missions.**
8. **Columbia completed the orbital test.**
9. **The Space Shuttle flew 24 successful missions.**
10. **One possibility for the Space Shuttle was a winged but unmanned recoverable liquid-fuel vehicle based on the Saturn 5 rocket.**
11. **A Commission was established to investigate the space shuttle Challenger accident.**
12. **Judit h Arlene Resnik was Mission Specialist Two.**
13. **Mission 51-L was originally scheduled for December 1985 but was delayed until January 1986.**
14. **The Corporation's Space Transportation Systems Division was responsible for the design and development of the Space Shuttle Orbiter.**
15. **Michael John Smith was the Pilot of the Challenger crew.**
16. **The Space Shuttle is composed of two recoverable Solid Rocket Boosters.**
17. **The Space Shuttle provides for the broadest possible spectrum of civil/military missions.**
18. **Mission 51-L consisted of placing one satellite in orbit, deploying and retrieving Spartan, and conducting six experiments.**
19. **The Space Shuttle became the focus of NASA's near-term future.**
20. **The Commission focused its attention on safety aspects of future flights.**
Custom GraphRAG Requests​
At any point, a GraphRAG
request can be generated and run with the following script:
tg-query-graph-rag -q "RAG request here"
Shutting Down TrustGraph​
When shutting down TrustGraph
, it's best to shut down all Docker containers and volumes. Run the docker compose down
command that corresponds to your model and graph store deployment:
docker compose -f <configuration-file.yaml> down -v
To confirm all Docker containers have been shut down, check that the following list is empty:
docker ps
To confirm all Docker volumes have been removed, check that the following list is empty:
docker volume ls