> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Train the NSR Machine on examples

> Trains the neural-symbolic system using input-output pairs. The system learns to map inputs to outputs through both neural perception and symbolic program…

Trains the neural-symbolic system using input-output pairs. The system learns
to map inputs to outputs through both neural perception and symbolic program synthesis.
**Training Process**

1. Neural perception maps inputs to symbol distributions
2. Parser constructs syntactic structures
3. Abductive reasoning synthesizes programs that explain the examples
4. Library learning extracts reusable program components
   **Example**

```bash theme={null}
curl -X POST 'https://api.nsr.stateset.com/api/v1/nsr/train' \
-H 'X-API-Key: your-api-key' \
-H 'Content-Type: application/json' \
-d '&#123;
'examples': [
&#123;'inputs': [&#123;'type': 'text', 'value': 'walk'&#125;], 'output': &#123;'type': 'list', 'value': [&#123;'type': 'string', 'value': 'WALK'&#125;]&#125;&#125;,
&#123;'inputs': [&#123;'type': 'text', 'value': 'run'&#125;], 'output': &#123;'type': 'list', 'value': [&#123;'type': 'string', 'value': 'RUN'&#125;]&#125;&#125;
],
'epochs': 5
&#125;'
```

**Required scope:** `models:manage`

### Request body

`NSRTrainRequest`

**epochs** `integer`

Number of epochs (optional, default 1)

**examples** `TrainingExampleRequest[]` *required*

Training examples

### Response

`NSRTrainResponse`

**final\_loss** `number (double)` *required*

Final training loss

**programs\_learned** `integer` *required*

Programs learned during training

**successful\_abductions** `integer` *required*

Successful abductions

**total\_examples** `integer` *required*

Total examples processed

**training\_time\_ms** `integer (int64)` *required*

Training time in milliseconds

### Status codes

| Code | Meaning |
| - | - |
| `200` | Training completed successfully |
| `400` | Invalid request - empty examples or validation failed |
| `401` | Unauthorized — missing or invalid credentials |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |
| `500` | Internal server error - training failed |
| `504` | Training budget exhausted before completion |

```bash cURL theme={null}
curl --request POST \
  --url 'https://api.nsr.stateset.com/api/v1/nsr/train' \
  --header "X-API-Key: $STATESET_NSR_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "epochs": 5,
  "examples": [
    {
      "inputs": [
        {
          "type": "text",
          "value": "walk"
        }
      ],
      "output": {
        "type": "list",
        "value": [
          {
            "type": "string",
            "value": "WALK"
          }
        ]
      }
    },
    {
      "inputs": [
        {
          "type": "text",
          "value": "run"
        }
      ],
      "output": {
        "type": "list",
        "value": [
          {
            "type": "string",
            "value": "RUN"
          }
        ]
      }
    }
  ]
}'
```

```json 200 theme={null}
{
  "final_loss": 0.023,
  "programs_learned": 3,
  "successful_abductions": 8,
  "total_examples": 10,
  "training_time_ms": 1250
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.