import streamlit as st # 📚 Importing Streamlit to create our awesome app! #import streamlit_mermaid # 🧜‍♀️ Mermaid diagrams in Streamlit! import os # 📁 For file operations, because who doesn't like saving stuff? # 🖼️ Setting the page configuration to make it look neat. st.set_page_config(page_title="Knowledge Graph Completion", layout="wide") # 🎯 Setting the title of our app. st.title("Knowledge Graph Completion") # 📖 Introducing PBF with some Markdown magic! st.markdown("# I. Introduction to Portable Brain Format (PBF)") st.markdown(""" **Definition and Purpose of PBF** - Goal of human and machine readability for knowledge graph exchange - Comparison to similar graph standards (RDF, GQL) - Mention of tools and libraries supporting PBF and related formats (Neo4j, Apache Jena) - Current state of language portability in knowledge management AI """) st.markdown("### Comparison of Graph Standards") # 🧑‍🎨 Mermaid diagram editor for the first diagram filename1 = st.text_input("Enter filename for Diagram 1:", "diagram1.mmd") mermaid_code1 = st.text_area("Edit Mermaid Diagram 1:", '''graph LR PBF[Portable Brain Format] RDF[RDF] GQL[Graph Query Language] PBF -- Similarities --> RDF PBF -- Similarities --> GQL RDF -- Differences --> GQL ''') # 🚀 Save and Load buttons for Diagram 1 col1, col2 = st.columns(2) with col1: if st.button("Save Diagram 1"): with open(filename1, 'w') as f: f.write(mermaid_code1) st.success(f"Diagram 1 saved to {filename1}!") with col2: if st.button("Load Diagram 1"): if os.path.exists(filename1): with open(filename1, 'r') as f: mermaid_code1 = f.read() st.success(f"Diagram 1 loaded from {filename1}!") else: st.error(f"File {filename1} does not exist.") # 🧜‍♀️ Displaying the Mermaid diagram for Diagram 1 st.markdown("#### Diagram 1:") #streamlit_mermaid.mermaid(mermaid_code1) # Repeat the process for other Mermaid diagrams in the app st.markdown("# II. Knowledge Graph Completion") st.markdown("## Using Language Models") st.markdown(""" - **KG-BERT**: Using BERT for knowledge graph completion (Yao et al., 2019) - **KG-LLM**: Exploring Large Language Models for knowledge graph completion (Yao et al., 2024) """) st.markdown("## Improving Existing Models") st.markdown(""" - **ProjB**: An improved bilinear biased ProjE model for knowledge graph completion (Moattari et al., 2022) """) st.markdown("## Other Approaches") st.markdown(""" - **GRank**: Graph Pattern Entity Ranking Model (Ebisu & Ichise, 2019) """) # 🧠 Time to dive into Knowledge Graph Embeddings. st.markdown("# III. Knowledge Graph Embeddings") st.markdown("## Applications") st.markdown("- **Entity Type Prediction** (Biswas et al., 2020)") st.markdown("## Biomedical Domain") st.markdown("- Link prediction, rule learning, polypharmacy tasks (Gema et al., 2023)") st.markdown("## Specific Models and Frameworks") st.markdown(""" - **Knowledgebra**: An algebraic learning framework for KG (Yang et al., 2022) - Deep learning on knowledge graphs for recommender systems (Gao et al., 2020) - Neuromorphic knowledge graph embeddings (Caceres Chian et al., 2021) """) st.markdown("## Benchmarks and Best Practices") st.markdown("- Benchmark and best practices for biomedical KG embeddings (Chang et al., 2020)") st.markdown("### Knowledge Graph Embedding Process") # 🧑‍🎨 Mermaid diagram editor for the second diagram filename2 = st.text_input("Enter filename for Diagram 2:", "diagram2.mmd") mermaid_code2 = st.text_area("Edit Mermaid Diagram 2:", '''graph TD A[Knowledge Graph] --> B[Embedding Model] B --> C[Vector Representations] C --> D[Downstream Tasks] D --> E[Entity Type Prediction] D --> F[Link Prediction] D --> G[Recommender Systems] ''') # 🚀 Save and Load buttons for Diagram 2 col3, col4 = st.columns(2) with col3: if st.button("Save Diagram 2"): with open(filename2, 'w') as f: f.write(mermaid_code2) st.success(f"Diagram 2 saved to {filename2}!") with col4: if st.button("Load Diagram 2"): if os.path.exists(filename2): with open(filename2, 'r') as f: mermaid_code2 = f.read() st.success(f"Diagram 2 loaded from {filename2}!") else: st.error(f"File {filename2} does not exist.") # 🧜‍♀️ Displaying the Mermaid diagram for Diagram 2 st.markdown("#### Diagram 2:") #streamlit_mermaid.mermaid(mermaid_code2) # 🌐 Exploring Knowledge Graph Applications. st.markdown("# IV. Knowledge Graph Applications") st.markdown("## Commonsense Reasoning") st.markdown(""" - Fusing context into KG for commonsense QA (Xu et al., 2021) - **CSKG**: The CommonSense Knowledge Graph (Ilievski et al., 2021) """) st.markdown("## Conversation Generation") st.markdown("- Knowledge-aware conversation generation with explainable reasoning over augmented graphs (Liu et al., 2019)") st.markdown("## Question Answering") st.markdown("- Question answering over spatio-temporal knowledge graphs (Dai et al., 2024)") st.markdown("### Application in Commonsense Reasoning") # 🧑‍🎨 Mermaid diagram editor for the third diagram filename3 = st.text_input("Enter filename for Diagram 3:", "diagram3.mmd") mermaid_code3 = st.text_area("Edit Mermaid Diagram 3:", '''graph LR Context -->|Fused into| KnowledgeGraph KnowledgeGraph -->|Used for| CommonsenseQA ''') # 🚀 Save and Load buttons for Diagram 3 col5, col6 = st.columns(2) with col5: if st.button("Save Diagram 3"): with open(filename3, 'w') as f: f.write(mermaid_code3) st.success(f"Diagram 3 saved to {filename3}!") with col6: if st.button("Load Diagram 3"): if os.path.exists(filename3): with open(filename3, 'r') as f: mermaid_code3 = f.read() st.success(f"Diagram 3 loaded from {filename3}!") else: st.error(f"File {filename3} does not exist.") # 🧜‍♀️ Displaying the Mermaid diagram for Diagram 3 st.markdown("#### Diagram 3:") mermaidblock="```mermaid" mermaidblockend="```" st.markdown(mermaidblock + mermaid_code3 + mermaidblockend) # 🏗️ Introducing Specific Knowledge Graphs. st.markdown("# V. Specific Knowledge Graphs") st.markdown(""" - **TechKG**: A large-scale Chinese technology-oriented knowledge graph (Ren et al., 2018) - **Wikidata**: Discovering implicational knowledge in Wikidata (Hanika et al., 2019) - **EventNarrative**: A large-scale event-centric dataset for knowledge graph-to-text generation (Colas et al., 2022) """) # 🧩 Discussing Knowledge Graph Representation. st.markdown("# VI. Knowledge Graph Representation") st.markdown("- **KSR**: A semantic representation of knowledge graph within a novel unsupervised paradigm (Xiao et al., 2020)") # 🔄 Wrapping up with RDF Generation and Validation. st.markdown("# VII. RDF Generation and Validation") st.markdown("- **R2RML and RML**: Comparison for RDF generation, rules validation, and inconsistency resolution (Dimou, 2020)")