Metadata-Version: 2.5
Name: fjallstation
Version: 0.1.1
Summary: A data and RL environment API for LLM training in the built environment.
Project-URL: Repository, https://github.com/zengpz/fjallstation
Author: Zeng Peng
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: agents,building-energy,hvac,llm,modelica,reinforcement-learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: datasets>=4.0
Requires-Dist: numpy
Requires-Dist: pyarrow
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# Fjällstation

*"Fjällstation is the mountain station at the foot of Kebnekaise, where you prepare before the climb."*

A data and RL environment API for LLM training in the built environment.

## What you get

| Part | What it does |
|---|---|
| `fjallstation.Corpus()` | domain text for pretraining, as a Hugging Face dataset |
| `fjallstation.Instruct()` | chats for fine-tuning, as a Hugging Face dataset |
| `fjallstation.Env()` | modelling tasks in Modelica: a container to work in, and a reward |
| Task image | OpenModelica with the libraries of the tasks |
| Server | gives the tasks and the rewards |

You bring the data: one folder in a [simple format](https://github.com/zengpz/fjallstation/blob/main/docs/data.md). The same parts run on one workstation or on several machines.

## Quick start

You need Python 3.10 or later and Docker. Tested on Linux.

```bash
pip install fjallstation
fjallstation image                    # build the task image; the first build takes some minutes
fjallstation example ./store          # the example store: five texts, five chats, five tasks
fjallstation server --store ./store   # the server; keep it running in this terminal
```

Then, in a second terminal in the same folder, with Python:

```python
import fjallstation                       # reads ./store, or the folder in FJALLSTATION_STORE

for doc in fjallstation.Corpus():
    print(doc["text"])
for row in fjallstation.Instruct():
    print(row["messages"])

env = fjallstation.Env()
task = env.reset("example-heated-room")  # a task and a fresh container; env.reset() gives a random task
print(task.prompt)
print(env.exec("omc --version").output)  # your agent works in the container

model = """
model HeatedRoom
  Real T(start = 10, fixed = true);
  output Real T_room;
equation
  2e6*der(T) = 1500 - 100*T;
  T_room = T;
end HeatedRoom;
"""
result = env.step(model)                 # the container tries the model; the server gives the reward
print(result.reward, result.feedback)    # 1.0 correct
```

## Documents

- [The data folder](https://github.com/zengpz/fjallstation/blob/main/docs/data.md): the format, the examples, and how to make tasks of your own.
- [One episode, step by step](https://github.com/zengpz/fjallstation/blob/main/docs/protocol.md): the same episode with a shell, who runs as whom, and use on several machines.
- [The reward](https://github.com/zengpz/fjallstation/blob/main/docs/scoring.md): the two parts of the reward and the rule behind them.

## Licence

Apache 2.0, see [LICENSE](https://github.com/zengpz/fjallstation/blob/main/LICENSE). The task image installs OpenModelica and Modelica libraries; they have their own licences. Two example tasks use open datasets under CC BY 4.0; their credit is in the task text and in the data document.
