📊 LangLLaMA-FactQA: Financial Fact Extraction from Amazon 10-K Using RDF, SPARQL, LangChain, and LLaMA 3
🔍 Extract structured financial knowledge from SEC 10-K filings using RDF graphs, query them via SPARQL, and interface naturally using LLaMA 3 LLM through LangChain—all powered by Apache Jena Fuseki.
This project allows users to query financial data from Amazon's 10-K filing (XBRL to RDF) through a local LangChain+Ollama-powered chatbot.
- 🧠 Converts XBRL filings to RDF triples
- 🔎 Loads the
.ttl(Turtle) file into a local Apache Jena Fuseki triplestore - 🧾 Uses SPARQL queries dynamically generated by LLaMA 3 LLM
- 💬 Interface built using Streamlit for ease of access
| Layer | Tools |
|---|---|
| LLM | Ollama with LLaMA 3 |
| Prompting | LangChain |
| Graph DB | Apache Jena Fuseki |
| File Conversion | Arelle (for XBRL to RDF pipeline) |
| UI | Streamlit |
| RDF Format | Turtle (.ttl) |
| Language | Python 3.10+ |
| Environment | Conda + Windows 11 |
📂 LangLLaMA-FactQA/
├── amzn-2024.ttl # Converted RDF Turtle file
├── xbrl_to_rdf.py # Script to convert XBRL to RDF
├── sparql_query.py # Basic SPARQL test script
├── main.py # LangChain + LLaMA SPARQL interface
├── app.py # Streamlit UI
├── requirements.txt # Python dependencies
└── demo_screenshot.png # UI screenshot preview
git clone https://github.com/noorcs39/langllama-factqa
cd langllama-factqa
conda create -n ldm python=3.10
conda activate ldm
pip install -r requirements.txt- Download and unzip Apache Jena Fuseki
- Run
fuseki-serverbatch file - Open
http://localhost:3030 - Add dataset
/amzn - Upload
amzn-2024.ttl
ollama pull llama3
ollama run llama3streamlit run app.py- What is the value of AccountsPayableCurrent?
- How much is AccountsReceivableNetCurrent?
- Give me the value of AccruedLiabilitiesCurrent.
Noor Uddin
📧 noor.cs2@yahoo.com
🌐 https://noorcs39.github.io/Nooruddin
This project is licensed under the MIT License.
- SEC EDGAR for public 10-K filings
- Arelle for XBRL parsing
- LangChain & Ollama for powerful LLM pipelines
- Apache Jena for SPARQL and RDF storage
