A newer version of the Streamlit SDK is available:
1.54.0
π PySD Streamlit App with Hugging Face Transformers
This Streamlit app allows you to:
- Upload System Dynamics models in
.mdl(Vensim) or.xmileformat - Run simulations using
PySD - Visualize time series results
- Ask LLM-powered questions about your model using the Hugging Face
mistralai/Mistral-7B-Instructmodel
π Features
β
Upload and simulate .mdl or .xmile models
β
Visualize model outputs as time-series plots
β
Ask natural language questions about model logic
β
Integrates with Hugging Face-hosted Transformer APIs
π§± Installation & Usage
Step 1: Deploy as a Hugging Face Space
- Create a new Hugging Face Space and select:
- SDK: Streamlit
- Python version: 3.8+
Step 2: Upload Project Files
Upload the following files to the root of your Space:
app.pyrequirements.txtREADME.md
Step 3: Set up Hugging Face Token (Optional but Recommended)
To enable transformer-powered Q&A about your model:
Option 1: Use Streamlit Secrets
- Go to your HF Space β Settings β Secrets
- Add the secret key:
HF_API_TOKEN = your_hf_token_here
Option 2: Enter Token in App
If no token is saved in secrets, the app will prompt you to enter it interactively.
π¬ Example Questions
- βWhat causes the temperature to drop?β
- βWhich variables form a feedback loop?β
- βExplain the relationship between stock and flow.β
π¦ Dependencies
The app uses:
streamlitpysdmatplotlibpandasrequestslxml
All dependencies are listed in requirements.txt.
π§ LLM-Powered Q&A
The transformer model is queried through the Hugging Face Inference API:
- Model:
mistralai/Mistral-7B-Instruct-v0.1 - Input: Parsed model component structure from PySD
- Output: Natural language explanations
π Notes
- Hugging Face Spaces have limited RAM; large models or simulations may timeout
- The
.mdlmodel must follow Vensim conventions compatible with PySD - Advanced CLD/SFD visualization will be added in future releases
π Questions or Feedback?
Please feel free to fork or raise an issue on the repo or Hugging Face space. Contributions welcome!