> For the complete documentation index, see [llms.txt](https://slm-lab.gitbook.io/slm-lab/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://slm-lab.gitbook.io/slm-lab/master/using-slm-lab/slm-lab-command.md).

# Lab Command

## :rocket: The Lab Command

Before running anything in SLM Lab, be sure to activate the Conda environment:

```bash
conda activate lab
```

In SLM Lab, everything is run with the lab command with the following form:

```bash
python run_lab.py {spec file} {spec name} {lab mode}
```

{% hint style="success" %}
*This command runs any algorithm/environment specified in a spec file in SLM Lab. Spec files are located in the `slm_lab/spec/` folder.*
{% endhint %}

### The Spec File

The **spec file** contains the **spec** – a set of fully exposed hyperparameters that configure a run, including the agent, environment, and hyperparameter search. The **spec name** refers to a specific spec in the spec file.

All the spec files are defined in the **slm\_lab/spec/** folder. The spec file has the following format:

```javascript
{
  "{spec name}": {
    "agent": [{...}],
    "env": [{...}],
    ...
    "search": [{...}]
  },
  "{spec name 2}": {
    ...
  },
  ...
}
```

### The Lab Modes

We will take a deep dive into the spec file in the coming sections, since it is crucial to running SLM Lab. Next, the **lab mode** specifies one of the modes used to run the lab:

* **dev**: for development with verbose logging, environment rendering, and helpful checks like gradient updates. This is slower but useful for development.
* **train**: for training an agent to completion. This disables the development helper tools and thus runs the fastest.
* **enjoy@{prename}**: for replaying a trained model from a trial-session; `prename` specifies the trial and session, e.g. `enjoy@a2c_gae_pong_t0_s0`.
* **search**: for running an experiment / hyperparameter search.

In [Quick Start](/slm-lab/master/setup/quick-start.md), we used the lab command to read the demo spec file at `slm_lab/spec/demo.json`, use the `dqn_cartpole` spec in it, and run the spec in **dev** mode. To rerun the demo in train mode, we can simply change the lab mode to **train** to get the following:

```bash
python run_lab.py slm_lab/spec/demo.json dqn_cartpole train
```

In the coming sections we will learn to use SLM Lab with more hands-on tutorials.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://slm-lab.gitbook.io/slm-lab/master/using-slm-lab/slm-lab-command.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
