# Set up for Unit 18: neural network tools and an SAP BTP trial

> Add PyTorch (CPU build) and Sentence Transformers to your course folder, create an SAP BTP trial account, tour the cockpit, and prove it all works.

- Course: Orchestrate, Unit 18 · Neural networks and embeddings
- Page: https://erpfde.com/topics/set-up-for-unit-18/
- Updated: 2026-11-10
- Reading time: Foundational 6 min, Deep 40 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

Unit 18 moves from classic machine learning to **neural networks** and **embeddings**. A neural network is a model built from many small, adjustable pieces. An embedding is a list of numbers that captures what a piece of text means, so a computer can tell that "order on credit hold" and "sales order blocked for credit" are about the same thing.

Learners need two new free Python libraries for this. **PyTorch** builds and trains neural networks. **Sentence Transformers** turns text into embeddings with a small ready-made model.

Learners also create a free **SAP BTP trial account**. SAP Business Technology Platform (BTP) is where SAP customers build and run their own extensions and AI services. The last topic of Unit 18 explains how it is organized, and later units build on it. As of September 2026 the trial is free for up to 90 days, and anyone can sign up with an email address. Your company may still have its own rules about that.

Setup takes 45 to 60 minutes, mostly downloads and waiting for the trial to be created.

### Why it matters to the business

Embeddings are behind most enterprise AI that "understands" text: searching product master data by meaning, finding similar past tickets, and giving a chatbot the right documents. Unit 18 builds a small semantic search over SAP-style master data. Later units grow that into grounded assistants.

The BTP trial matters for a different reason. Almost every SAP AI service a team will buy or build on sits in a BTP account. People who have clicked through a BTP account understand quotes, architecture diagrams and project plans faster. Terms such as global account, subaccount and entitlement stop being abstract.

Two points for a leader:

- **The trial is for learning only.** SAP's documentation says a trial account must not be used for production or team development. It is deleted after 90 days, with everything in it.
- **Company data stays out.** Everything in Unit 18 uses made-up data. Nothing from your SAP systems should go into a personal trial.

### How SAP does it

The open tools in this unit are the same kind SAP's own data scientists use. SAP BTP offers two ways to try the platform, and they are often confused:

- **Trial account:** free, time-limited, for individuals exploring the platform. As of September 2026 it lasts up to 90 days. Anyone can sign up at sap.com.
- **Free tier:** free service plans inside a paid BTP contract (Pay-As-You-Go or an enterprise agreement, CPEA). It has no time limit and projects can move to production.

This course uses the trial, because it needs no contract. Later units check, at the time they are written, which AI services each option includes.

### What this unit adds

| Item | What it is | Cost | Used in |
| --- | --- | --- | --- |
| PyTorch (CPU build) | Library for building and training neural networks | Free | Neural networks from scratch, and Unit 19 |
| Sentence Transformers | Library and small models that turn text into embeddings | Free | Embeddings and semantic similarity, semantic search over SAP master data |
| An embedding model (all-MiniLM-L6-v2) | A small ready-made model downloaded once from Hugging Face | Free, no account | Same as above |
| SAP BTP trial account | Your own time-limited BTP global account and subaccount | Free for 90 days | SAP BTP foundations for AI builders, and later units |

### Time and money

- **Time:** 45 to 60 minutes. PyTorch is a large download. The trial account takes a few minutes to be created.
- **Money:** nothing. No credit card is part of the trial steps SAP describes.
- **Disk space:** plan for a few gigabytes free. On Linux, installing PyTorch the default way pulls a much larger GPU build; the deep layer shows the smaller CPU command.
- **The trial clock:** 90 days from sign-up. If a learner doesn't sign in for 30 days, the account is suspended. A learner who pauses the course for months can simply create a new trial later.

### Questions to ask IT

- Can learners download from `pypi.org`, `download.pytorch.org` and `huggingface.co`, or is there an internal mirror?
- May learners sign up for an SAP BTP trial, and with a personal or a work email address?
- Does the company network allow the SAP BTP trial sites (`*.hanatrial.ondemand.com`)?
- Do learner laptops have a few gigabytes of free disk space?
- If the company already has a BTP contract, is there a free-tier or sandbox subaccount learners could use later instead of a trial?

### Common misconceptions

- **"Neural networks need a GPU."** Not for this course. Unit 18's networks and the small embedding model run on any recent laptop. Unit 19's setup explains when a GPU helps.
- **"The BTP trial is the same as the free tier."** No. The trial is time-limited and for individuals. The free tier sits inside a paid contract and can go to production.
- **"We can pilot on the trial."** SAP's documentation rules out production use and team development. Use it to learn, then pilot in a proper account.
- **"The embedding model sends our text to a cloud service."** Not here. The model is downloaded once and runs on the laptop.

### Key terms

- **Neural network:** a model made of layers of simple units whose weights are adjusted during training.
- **Embedding:** a list of numbers that represents the meaning of a text, so similar meanings get similar numbers.
- **SAP BTP:** SAP Business Technology Platform, where SAP customers build and run extensions and AI services.
- **Global account:** your contract with SAP in BTP. In a trial, SAP creates one for you.
- **Subaccount:** a space inside the global account, in one region, where services actually run.
- **Entitlement:** the right to use a service in a subaccount; the basis of billing in a paid account.

### Check yourself

1. What does Unit 18's setup add, and what does it cost?
   - A. A paid GPU cloud account and an SAP AI Core contract for each learner
   - B. Two free libraries, a small model and a 90-day BTP trial, at no cost
   - C. A copy of S/4HANA for each learner, billed monthly per user
   - D. Only a Hugging Face paid account for downloading embedding models

   Answer: B. Learners add PyTorch and Sentence Transformers, download one small embedding model, and create an SAP BTP trial. All of it is free; the trial lasts up to 90 days.

2. What is an embedding, in business terms?
   - A. A compressed backup of a document, so it takes less storage space
   - B. A password that protects a text from being read by other systems
   - C. A list of numbers capturing meaning, so similar texts can be found
   - D. A rule that sorts each text into one of a fixed set of SAP categories

   Answer: C. An embedding turns text into numbers so that texts with similar meaning get similar numbers. That is what lets search find "order on credit hold" when someone types "sales order blocked for credit".

3. A partner suggests running your pilot in an SAP BTP trial account. What is the problem?
   - A. Trial accounts can't run any services until a contract is signed
   - B. Trial accounts cost more than the free tier once the first month is over
   - C. Trial accounts are only available to SAP partners, not to customers
   - D. SAP rules out production and team use, and deletes it after 90 days

   Answer: D. SAP's documentation says a trial must not be used for production or team development, and the account is deleted after 90 days with everything in it. Pilots belong in a proper account, such as a free-tier or sandbox subaccount under a contract.

4. How does the BTP free tier differ from the trial?
   - A. Free tier needs a paid contract, has no time limit, can go to production
   - B. Free tier is the new name for the trial, and keeps the same 90-day limit
   - C. Free tier is shorter than the trial but includes more memory and services
   - D. Free tier is only for students and individual learners, with no contract

   Answer: A. The free tier is a set of free service plans inside a Pay-As-You-Go or enterprise (CPEA) contract. It has no time limit and projects can move to production. The trial needs no contract but is time-limited and for learning only.

5. Why does the course use made-up data in Unit 18?
   - A. Real SAP data can't be turned into embeddings by an open-source model
   - B. Company data must not go into a personal learning account or laptop
   - C. The embedding model only understands made-up English text, not SAP data
   - D. SAP forbids any use of Python with data from SAP systems

   Answer: B. The trial is a personal learning account and the scripts run on a laptop. Keeping company data out avoids a data-protection problem, and the made-up data is shaped like SAP data so the lessons still carry over.

6. What should you ask IT before learners start Unit 18?
   - A. Whether IT can create production BTP subaccounts for each learner in the team
   - B. Whether learners may connect the trial to the live S/4HANA system for real data
   - C. Whether the download and BTP trial sites are reachable, and which email to use
   - D. Whether IT will buy GPUs for every laptop so PyTorch can train models

   Answer: C. The setup downloads from PyPI, the PyTorch site and Hugging Face, and the trial runs on SAP's trial sites. IT should confirm access, the email address rule for sign-up, disk space, and whether a company sandbox exists as an alternative.

7. Why is a hands-on BTP trial useful for a non-developer?
   - A. It replaces the need for an SAP partner on later BTP implementation projects
   - B. It qualifies the learner for an SAP certification in BTP administration
   - C. It lets them approve BTP contracts and entitlements without procurement
   - D. Terms like global account, subaccount and entitlement become concrete

   Answer: D. Most SAP AI services sit in a BTP account. Having clicked through one, people read quotes, architecture diagrams and plans faster, because the account model is no longer abstract.

## Deep layer

### Mental model: two new libraries on your laptop, one new account in the cloud

Your course folder stays the same: one `.venv`, one `requirements.txt`, one Git repository. This unit adds two libraries to that folder and one thing outside it: an SAP BTP trial account that lives in SAP's cloud and that you reach through a web page called the **cockpit**.

```mermaid
flowchart LR
  T[PyTorch CPU build] --> V[.venv<br/>course Python]
  S[sentence-transformers] --> V
  V --> H[hello_torch.py]
  M[Embedding model<br/>downloaded once] --> H
  B[SAP BTP trial<br/>in SAP's cloud] --> N[btp_trial_notes.md]
  H --> C[check_unit18.py]
  N --> C
```

Nothing on your laptop talks to the BTP trial in this unit. You explore the trial in the browser and write down what you find. The Unit 18 topic on BTP foundations uses those notes.

### How it works

#### PyTorch and the CPU build

PyTorch comes in two kinds of builds. A **GPU build** (also called a CUDA build) can use an NVIDIA graphics card to train faster. A **CPU build** uses only the normal processor. The CPU build is much smaller, and it is all this course needs until Unit 19.

Which build you get depends on your system and where `pip` downloads from:

| Your system | Plain `pip install torch` gives you | What to run in this course |
| --- | --- | --- |
| Windows | The CPU build | `pip install torch` |
| macOS (Apple silicon) | The CPU build | `pip install torch` |
| Linux | The large GPU build | `pip install torch --index-url https://download.pytorch.org/whl/cpu` |

As of September 2026 the latest PyTorch release is 2.14.0 and needs Python 3.10 or newer. Your course Python from Unit 17 (3.11 or newer) meets that. PyPI lists macOS wheels only for Apple silicon Macs on macOS 14 or newer.

The `--index-url` option tells `pip` to download from PyTorch's own server instead of PyPI. That server has a separate copy of each release built for CPU only.

#### Sentence Transformers and the model download

Sentence Transformers is a library that loads a ready-made embedding model and turns texts into vectors with one call: `model.encode(texts)`. It depends on PyTorch and on Hugging Face's `transformers` library, and `pip` installs those for you.

The library itself contains no model. The first time you ask for one, it downloads it from **Hugging Face**, a public site that hosts open models. This course uses `all-MiniLM-L6-v2`, the model in the library's own quick-start example. It turns each text into 384 numbers. After the first download, the copy on your computer is used, so it also works offline.

> **Note** Words you will meet. **Tensor**: PyTorch's name for an array of numbers, like a numpy array that can also track gradients. **Gradient**: how much the error changes when you nudge a weight; you met it in [Gradient descent, by hand](https://erpfde.com/topics/gradient-descent-by-hand/). **Vector**: a list of numbers; an embedding is a vector. **Similarity score**: a number that says how close two vectors point; here, between -1 and 1, where higher means more alike. **Cockpit**: the web page where you manage an SAP BTP account.

#### The SAP BTP trial account model

A paid SAP BTP account and a trial account use the same structure. SAP Learning describes it like this:

- A **global account** represents your contract with SAP. In the trial, SAP creates one for you.
- **Directories** (optional) group subaccounts, for example by department or region.
- A **subaccount** runs in exactly one **region** (a data center location). Services and apps live here. Your trial gets one subaccount, named `trial`.
- **Entitlements** say which services, and how much of each, a subaccount may use.

Inside the trial subaccount, SAP also sets up the **Cloud Foundry environment**, a runtime for apps. It has one **org**, linked one-to-one to the subaccount, and one **space** named `dev` where apps are deployed.

You find services in the **Service Marketplace**. Creating one gives you either a **service instance** (used by an app you deploy) or a **subscription** (a ready-made application that runs on its own). Both then appear under **Instances and Subscriptions**.

As of September 2026, SAP's documentation sets these trial rules:

| Rule | What it means for you |
| --- | --- |
| Free for up to 90 days | Then the trial account is deleted automatically, with everything in it |
| Suspended after 30 days without sign-in | Sign in regularly; each sign-in extends the current interval by up to 30 days, within the 90 days |
| Apps stop automatically every day | Around midnight in your region; restart them when you need them |
| 4 GB memory for apps, 8 GB instance memory, 10 routes, 40 services | Plenty for the course |
| Not for production or team development | Learning only; keep company data out |

### Build it yourself: add the Unit 18 tools and open your BTP trial

You will install PyTorch and Sentence Transformers, run a short script that trains one "neuron" and compares SAP-style texts by meaning, then create your SAP BTP trial and tour its cockpit. A check script confirms everything at the end.

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/) and [Set up for Unit 17](https://erpfde.com/topics/set-up-for-unit-17/). They install Python, VS Code and Git, create your `orchestrate-course` folder with its `.venv`, and add the data libraries. This walkthrough doesn't repeat those steps.

#### What you need

- Your course folder from Units 2 and 17.
- About 45 to 60 minutes and an internet connection.
- A few gigabytes of free disk space.
- An email address for the SAP account. The trial is free; no payment details are part of SAP's trial steps.

#### Step 1: Open your course folder and turn on the virtual environment

1. Open VS Code, choose **File > Open Folder**, and open `orchestrate-course`.
2. Open a terminal: **Terminal > New Terminal**.
3. If the prompt doesn't start with `(.venv)`, turn it on:

   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

#### Step 2: Install PyTorch (CPU build)

Run the one command for your system, with `(.venv)` showing:

- **Windows (PowerShell):**

  ```powershell
  pip install torch==2.14.0
  ```

- **macOS:**

  ```bash
  pip install torch==2.14.0
  ```

- **Linux:**

  ```bash
  pip install torch==2.14.0 --index-url https://download.pytorch.org/whl/cpu
  ```

The `==2.14.0` pins the version this topic was tested with, so your results match. Wait for a line starting `Successfully installed`. This is a large download and can take several minutes.

> **Warning** On Linux, don't skip the `--index-url` part. Without it, `pip` installs the GPU build. It works on a CPU too, but in our test the environment grew to about 6 GB.

> **Tip** On an Intel Mac, `pip` may answer `No matching distribution found for torch`. As of September 2026, PyPI lists PyTorch wheels for macOS only on Apple silicon. See **If something goes wrong** below.

#### Step 3: Add Sentence Transformers and update `requirements.txt`

1. In VS Code, open `requirements.txt` and add these two lines below the existing ones:

   ```text
   torch==2.14.0
   sentence-transformers==6.1.0
   ```

2. Save the file (Ctrl+S, or Cmd+S on Mac).
3. Run:

   ```bash
   pip install -r requirements.txt
   ```

4. Wait for `Successfully installed`. Lines saying `Requirement already satisfied` for torch and the Unit 17 libraries are expected: the CPU build from Step 2 (`2.14.0+cpu` on Linux) satisfies `torch==2.14.0`, so it is kept.

> **Note** `requirements.txt` says *which* libraries you need, not which build. If you ever recreate `.venv` on Linux, run the Step 2 command first, then `pip install -r requirements.txt`. Otherwise `pip` fetches the large GPU build again.

#### Step 4: Make the Unit 18 folder

From your course folder:

- **Windows (PowerShell):**

  ```powershell
  New-Item -ItemType Directory -Force unit18
  cd unit18
  ```

- **macOS / Linux:**

  ```bash
  mkdir -p unit18
  cd unit18
  ```

#### Step 5: Run the PyTorch smoke test

The script trains the smallest possible neural network, one neuron, to learn the rule `y = 2x + 1` from 20 noisy made-up points. It is the gradient descent you did by hand in Unit 17, but PyTorch works out the gradients for you. With `--embed`, it also compares SAP-style texts by meaning.

1. In VS Code's file list, right-click `unit18`, choose **New File** and name it `hello_torch.py`.
2. Paste the code below and save.
3. In the terminal, inside `unit18`, run:

   ```bash
   python hello_torch.py
   ```

```python
"""Unit 18 smoke test: train a one-neuron network with PyTorch, then (optionally) compare
SAP-style texts with an embedding model.

How to run (from the unit18 folder, with the course .venv turned on):
    python hello_torch.py            # PyTorch only, no download, no account
    python hello_torch.py --embed    # also download a small embedding model (one time) and compare texts

All data is made up.
"""
import argparse

import torch

QUERY = "Sales order blocked: customer over credit limit"
CANDIDATES = [  # made-up texts, shaped like notes on SAP documents
    "Order on credit hold until finance releases it",
    "Purchase order price differs from the invoice",
    "Planned order is late because a component is missing",
    "Pallet of M8 screws, zinc plated",
]


def train_one_neuron(steps: int = 500) -> None:
    """Learn y = 2x + 1 from 20 noisy points with gradient descent, the PyTorch way."""
    torch.manual_seed(0)                          # same "random" numbers every run
    x = torch.linspace(0, 1, 20).unsqueeze(1)     # 20 inputs, shape (20, 1)
    y = 2 * x + 1 + 0.05 * torch.randn(x.shape)   # true rule plus a little noise

    model = torch.nn.Linear(1, 1)                 # one neuron: y = w*x + b
    optimizer = torch.optim.SGD(model.parameters(), lr=0.5)
    loss_fn = torch.nn.MSELoss()

    for step in range(steps + 1):
        optimizer.zero_grad()                     # forget last step's gradients
        loss = loss_fn(model(x), y)               # how wrong are we?
        loss.backward()                           # PyTorch works out the gradients
        optimizer.step()                          # nudge w and b downhill
        if step % 100 == 0:
            print(f"  step {step:3d}  loss {loss.item():.4f}")

    w, b = model.weight.item(), model.bias.item()
    print(f"Learned w = {w:.2f}, b = {b:.2f}  (the true rule was w = 2, b = 1)")


def compare_texts(model_name: str) -> None:
    """Turn texts into embeddings (lists of numbers) and rank them by similarity to QUERY."""
    from sentence_transformers import SentenceTransformer  # imported here so the default run skips it

    print(f"\nLoading embedding model {model_name} (downloads once, then uses the copy on disk)...")
    model = SentenceTransformer(model_name)
    vectors = model.encode([QUERY] + CANDIDATES)
    print(f"Each text became {vectors.shape[1]} numbers.")
    scores = model.similarity(vectors[:1], vectors[1:])[0]  # QUERY against each candidate
    print(f"\nMost similar to: '{QUERY}'")
    for score, text in sorted(zip(scores.tolist(), CANDIDATES), reverse=True):
        print(f"  {score:5.2f}  {text}")


def main() -> None:
    parser = argparse.ArgumentParser(description="Unit 18 smoke test: PyTorch and embeddings.")
    parser.add_argument("--embed", action="store_true", help="also run the embedding comparison")
    parser.add_argument("--model", default="sentence-transformers/all-MiniLM-L6-v2",
                        help="embedding model to use with --embed")
    args = parser.parse_args()

    print(f"PyTorch {torch.__version__}, running on: CPU")
    print("Training one neuron on made-up points:")
    train_one_neuron()
    if args.embed:
        compare_texts(args.model)
    else:
        print("\nSkipped the embedding test. Run with --embed to try it.")


if __name__ == "__main__":
    main()
```

**What success looks like:**

```text
PyTorch 2.14.0+cpu, running on: CPU
Training one neuron on made-up points:
  step   0  loss 2.7650
  step 100  loss 0.0019
  step 200  loss 0.0019
  step 300  loss 0.0019
  step 400  loss 0.0019
  step 500  loss 0.0019
Learned w = 2.10, b = 0.97  (the true rule was w = 2, b = 1)

Skipped the embedding test. Run with --embed to try it.
```

The loss drops quickly and then stays flat: the neuron has learned as much as the noisy points allow. That is why `w` is 2.10, not exactly 2. The version text after `PyTorch` differs by system, for example `2.14.0` on Windows and macOS or `2.14.0+cpu` on Linux. The loss numbers may differ slightly between versions and systems; what matters is that the loss falls and `w` and `b` end near 2 and 1.

#### Step 6: Run the embedding test

1. Still inside `unit18`, run:

   ```bash
   python hello_torch.py --embed
   ```

2. The first run downloads the model from Hugging Face. You may see progress bars. No account or key is needed.

**What success looks like** (after the PyTorch lines):

```text
Loading embedding model sentence-transformers/all-MiniLM-L6-v2 (downloads once, then uses the copy on disk)...
Each text became 384 numbers.

Most similar to: 'Sales order blocked: customer over credit limit'
  0.xx  Order on credit hold until finance releases it
  0.xx  ...
  0.xx  ...
  0.xx  Pallet of M8 screws, zinc plated
```

Your scores are real numbers in place of `0.xx`, sorted from most to least similar. The texts are made up, so the scores only show how the model ranks them, not results from SAP data. Expect the credit-hold text at or near the top and the screws at the bottom: the first is about the same business problem, the last is product master data. Run it a second time; it starts faster because the model is already on disk.

If the download fails (for example, a company network blocks Hugging Face), Step 5 still proves PyTorch works. Try Step 6 again on another network. The Unit 18 embeddings topic needs it.

**What each part of the script does:**

| Part | What it does |
| --- | --- |
| `torch.manual_seed(0)` | Fixes PyTorch's random numbers, so every run makes the same noisy points |
| `torch.linspace`, `torch.randn` | Build 20 inputs and the matching noisy outputs as tensors |
| `torch.nn.Linear(1, 1)` | One neuron with one weight `w` and one bias `b` |
| `MSELoss`, `SGD` | The error measure (mean squared error) and the gradient descent optimizer |
| `zero_grad`, `backward`, `step` | The training loop: clear old gradients, compute new ones automatically, move the weights |
| `SentenceTransformer(model_name)` | Loads the embedding model, downloading it the first time |
| `model.encode(...)` | Turns each text into a vector of 384 numbers |
| `model.similarity(...)` | Scores how alike the query vector is to each candidate vector |
| `--embed`, `--model` | Optional: run the embedding test, and choose another model |

#### Step 7: Create your SAP BTP trial account

> **Warning** The trial runs for up to 90 days from sign-up, and it is suspended if you don't sign in for 30 days. If you will pause the course for a long time, you can do this step when you reach the BTP topic instead. You can always create a new trial later.

1. If you don't have an SAP account yet: open <https://www.sap.com>, click **Log On** in the upper-right corner, then **Register**. Fill in the required fields and click **Submit**.
2. Open your email and click the activation link SAP sent you.
3. Open the trial page: <https://www.sap.com/products/technology-platform/trial.html>. Click **Try Now** and follow the instructions on screen.
4. When sign-up is complete, open the trial cockpit: <https://cockpit.hanatrial.ondemand.com/trial/>. Bookmark it; this is how you get back.
5. The cockpit asks you to choose a region. Pick one near you from the list it shows.
6. Click **Create Account**. A dialog shows progress while SAP sets up your trial. This can take a few minutes.
7. When it finishes, click **Continue**.
8. You now see your trial global account. Click the tile named **trial** to open your subaccount.

> **Note** Labels on SAP's sites change from time to time. If a button reads slightly differently, pick the closest match. The steps above follow SAP's own "Get an Account on SAP BTP Trial" tutorial as of September 2026.

#### Step 8: Tour the cockpit and write your notes

You will look around your trial and write down what you find in a notes file. None of this is secret, but it is personal to your account, so keep it in your course folder.

1. In VS Code, create `btp_trial_notes.md` inside `unit18` and paste this template:

   ```text
   # My SAP BTP trial

   - Created on:
   - Region:
   - Global account name:
   - Subaccount name: trial
   - Cloud Foundry API endpoint:
   - Cloud Foundry org name:
   - Space(s):
   - Three services in the Service Marketplace that mention AI or machine learning:
   - Anything in Instances and Subscriptions already:
   ```

2. In the cockpit, on the subaccount page (**Overview**), find the **Cloud Foundry** section. Copy the **API endpoint** and the **org name** into your notes.
3. Find the **Spaces** section. You should see one space named `dev`. Write it down.
4. Note the region shown for the subaccount.
5. In the left menu, open **Services > Service Marketplace**. Type `AI` in the search box. Write down up to three service names you see. If none appear, write "none found"; that is a valid result too.
6. Open **Services > Instances and Subscriptions**. In a new trial it may be empty; write "empty" if so.
7. Look at the breadcrumbs at the top of the page. Click **Trial Home** or the global account name to go up a level, then open the **trial** tile again. This is how you move between the global account and the subaccount.
8. Don't click **Enable Kyma**, **Delete Trial** or anything that creates services yet. Later units tell you when to.
9. Save the notes file.

> **Tip** If a popup offers **Extend Trial**, accept it. It keeps the account active within the 90 days.

#### Step 9: Run the Unit 18 check

1. Go back to your course folder in the terminal:

   ```bash
   cd ..
   ```

2. In VS Code, create a new file in the course folder (not in `unit18`), paste the script below and save it as `check_unit18.py`.
3. Run it:

   ```bash
   python check_unit18.py
   ```

```python
"""Check that your computer is ready for Unit 18 (neural networks and embeddings).

Run it from your course folder:  python check_unit18.py
It only reads your setup and opens two web pages to test your network.
It installs nothing and sends none of your files or keys anywhere.
"""
import importlib.metadata
import importlib.util
import os
import subprocess
import sys
import urllib.error
import urllib.request

problems = 0


def report(ok: bool, label: str, fix: str = "", optional: bool = False) -> None:
    """Print one line: OK, MISSING (must fix) or LATER (optional for now)."""
    global problems
    if ok:
        print(f"  OK       {label}")
    elif optional:
        print(f"  LATER    {label}  ->  {fix}")
    else:
        problems += 1
        print(f"  MISSING  {label}  ->  {fix}")


def version_of(package: str) -> str:
    try:
        return importlib.metadata.version(package)
    except importlib.metadata.PackageNotFoundError:
        return ""


def reachable(url: str) -> bool:
    """True if the site answers at all (any HTTP status counts; we only test the network)."""
    try:
        urllib.request.urlopen(urllib.request.Request(url, method="HEAD"), timeout=15)
        return True
    except urllib.error.HTTPError:
        return True   # the site answered, even if with an error page
    except Exception:
        return False


print("\n1. Python")
v = sys.version_info
report(v >= (3, 11), f"Python {v.major}.{v.minor}.{v.micro}",
       "the course needs Python 3.11 or newer (see Set up for Unit 17, Step 1)")
report(sys.prefix != sys.base_prefix, "virtual environment is active", "activate .venv (Step 1)")

print("\n2. Libraries")
for module, package in [("torch", "torch"), ("sentence_transformers", "sentence-transformers")]:
    found = importlib.util.find_spec(module) is not None
    label = f"{package} {version_of(package)}".strip()
    report(found, label, "install it (Steps 2 and 3)")

print("\n3. PyTorch works")
# Run a tiny calculation with gradients in a fresh Python. This catches broken installs.
test = (
    "import torch;"
    "w = torch.tensor(3.0, requires_grad=True);"
    "(w * w).backward();"
    "assert abs(w.grad.item() - 6.0) < 1e-6;"
    "print(torch.version.cuda or '')"
)
try:
    result = subprocess.run([sys.executable, "-c", test], capture_output=True, text=True, timeout=180)
    ok = result.returncode == 0
    detail = (result.stderr.strip().splitlines() or ["unknown error"])[-1] if not ok else ""
    gpu_build = ok and bool(result.stdout.strip())
except subprocess.TimeoutExpired:
    ok, detail, gpu_build = False, "timed out", False
report(ok, "tensor maths and gradients", f"{detail}; reinstall PyTorch (Step 2)")
if ok:
    report(not gpu_build, "CPU build of PyTorch",
           "you have the larger GPU (CUDA) build; it works, but the CPU build saves gigabytes (Step 2)",
           optional=True)

print("\n4. Network")
report(reachable("https://huggingface.co"), "can reach huggingface.co (embedding model download)",
       "ask IT to allow huggingface.co, or use another network", optional=True)
report(reachable("https://cockpit.hanatrial.ondemand.com"), "can reach the SAP BTP trial site",
       "ask IT to allow *.hanatrial.ondemand.com, or use another network", optional=True)

print("\n5. Course folder")
report(os.path.isdir("unit18"), "unit18 folder", "create it (Step 4)", optional=True)
report(os.path.exists(os.path.join("unit18", "hello_torch.py")), "unit18/hello_torch.py",
       "create it (Step 5)", optional=True)
report(os.path.exists(os.path.join("unit18", "btp_trial_notes.md")), "unit18/btp_trial_notes.md",
       "write it during the cockpit tour (Step 8)", optional=True)

print()
if problems:
    print(f"{problems} item(s) to fix. Fix them in order, then run this again.")
    sys.exit(1)
print("All set. Your computer is ready for Unit 18.")
```

**What success looks like:**

```text
1. Python
  OK       Python 3.11.15
  OK       virtual environment is active

2. Libraries
  OK       torch 2.14.0
  OK       sentence-transformers 6.1.0

3. PyTorch works
  OK       tensor maths and gradients
  OK       CPU build of PyTorch

4. Network
  OK       can reach huggingface.co (embedding model download)
  OK       can reach the SAP BTP trial site

5. Course folder
  OK       unit18 folder
  OK       unit18/hello_torch.py
  OK       unit18/btp_trial_notes.md

All set. Your computer is ready for Unit 18.
```

Your version numbers may differ; that is fine as long as each line says `OK`. A `LATER` line doesn't stop you:

- `LATER CPU build of PyTorch` means you have the GPU build. It works; it only uses more disk. To switch on Linux, run `pip uninstall torch`, then the Step 2 command.
- `LATER can reach ...` means your network blocked that site when the check ran. Try another network, or ask IT.

**What each part of the check does:**

| Part | What it checks |
| --- | --- |
| Python | Version 3.11 or newer, and that `.venv` is active |
| Libraries | That PyTorch and Sentence Transformers can be found, and their versions |
| PyTorch works | Starts a fresh Python, computes a gradient (the slope of `w*w` at 3 is 6), and asks whether this is a GPU build |
| Network | Whether Hugging Face and the BTP trial cockpit answer. It sends no data, only a request for the page header |
| Course folder | That `unit18`, the smoke test and your trial notes exist |

Like the earlier checks, it uses only Python's built-in modules and changes nothing.

#### Step 10: Save your work in Git

From the course folder:

```bash
git add requirements.txt check_unit18.py unit18/hello_torch.py unit18/btp_trial_notes.md
git commit -m "Set up Unit 18: PyTorch, embeddings, BTP trial"
```

The downloaded model is not in your course folder, so nothing large goes into Git.

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized, or `command not found` | Python isn't installed, or the terminal can't find it | Windows: repeat Unit 2, Step 1, then open a new terminal. macOS/Linux: use `python3` until `.venv` is active |
| `ModuleNotFoundError: No module named 'torch'` (or `sentence_transformers`) | The library isn't installed in the Python you're using | Check for `(.venv)` in the prompt, then repeat Steps 2 and 3 |
| `No matching distribution found for torch` | Your Python or system has no current PyTorch build: Python older than 3.10, a 32-bit Python, or an Intel Mac | Run `python --version`; recreate `.venv` with a newer 64-bit Python (Unit 17, Step 1). On an Intel Mac, use another computer for Units 18 and 19, or use an online notebook service, which Unit 19's setup plans to cover |
| Linux: the install downloads several gigabytes, or `nvidia` packages appear | `pip` is fetching the GPU build | Stop with Ctrl+C, run `pip uninstall torch`, then the Linux command in Step 2 |
| pip shows `ProxyError`, `SSLError` or `Could not fetch URL` | Your network or company proxy blocks `pypi.org` or `download.pytorch.org` | Try a home network, or ask IT for access or the internal package mirror |
| `--embed` fails with a connection, proxy or `huggingface.co` error | The model download is blocked | Try another network, or ask IT to allow `huggingface.co`. Step 5 alone still proves PyTorch works |
| A warning mentions `HF_TOKEN` or not being logged in to Hugging Face | Hugging Face notes you are downloading without an account | Ignore it. This model needs no account or key |
| `No space left on device` during install | The disk is full | Free a few gigabytes and run the command again |
| The trial page asks you to log on again and again | Browser cookies are blocked, or you are signed in with another SAP account | Try a private browser window, or sign out of other SAP sites first |
| The cockpit says the account is suspended | You didn't sign in for 30 days or more | SAP deletes suspended trials. Create a new trial and rebuild it from your notes file |
| Windows: `.venv\Scripts\Activate.ps1 cannot be loaded` | PowerShell blocks scripts | Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`, answer `Y`, and try again |

### Where this shows up in SAP

The trial account you created has the same shape as a customer's paid BTP account: a global account, subaccounts in regions, entitlements, and services from the marketplace. When a customer's architect says "we'll provision it in the AI subaccount in the EU region", you now know what that means and where it lives in the cockpit.

The difference is the contract. A trial is free, isolated and deleted after 90 days. A customer's account is a contract with SAP, where entitlements drive the bill. SAP also offers a **free tier**: free service plans inside a Pay-As-You-Go or CPEA contract, with no time limit and a path to production. When a project needs to go past learning, ask whether the customer's account has free-tier plans for the service in question before anyone buys a paid plan.

Embeddings show up in SAP too. Units 3 and 6 look at SAP's own options for embedding models and vector search, and compare them with the open model you downloaded here.

### Pitfalls

- **The GPU build by accident.** On Linux, a plain `pip install torch`, or recreating `.venv` from `requirements.txt` alone, fetches the large GPU build. Run the CPU command first.
- **Letting the trial lapse.** Thirty days without signing in suspends the trial. Sign in now and then, and keep your notes, so a new trial is quick to set up.
- **Treating the trial as a team sandbox.** SAP's rules exclude team development and production use. Share what you learn, not the account.
- **Company data in the trial or the model.** Everything in Unit 18 is made up. Keep it that way in a personal account.
- **Forgetting the daily stop.** Apps in the trial stop around midnight in your region. If something you deployed "disappeared" the next day, restart it.
- **Assuming the embedding model knows SAP terms.** It is a general-purpose model. It knows that "credit hold" and "blocked for credit" are close, but not your company's own codes. The embeddings topic tests where it breaks.

### Exercise: write your own SAP texts and read your trial

1. Copy `hello_torch.py` to `my_texts.py` in `unit18`.
2. Change `QUERY` to a problem from a process you know, for example a three-way match exception: "Invoice quantity higher than goods receipt".
3. Replace `CANDIDATES` with five made-up texts: two that describe the same problem in other words, two about other processes, and one piece of product master data.
4. Run `python my_texts.py --embed`. Check that your two rewordings rank highest.
5. If one of them doesn't, write one sentence in `btp_trial_notes.md` under a new heading `## Embedding surprises`, saying which text ranked where and why you think so.
6. Complete every line of the notes template from Step 8.
7. Save your work in Git:

   ```bash
   git add unit18/my_texts.py unit18/btp_trial_notes.md
   git commit -m "Add my own embedding test and BTP trial notes"
   ```

**Done when:** `check_unit18.py` prints `All set`, `my_texts.py --embed` prints your five texts ranked by similarity, `btp_trial_notes.md` has every line filled in, and `git log` shows the commit. Keep both files: the embeddings topic reuses your texts, and the SAP BTP foundations topic starts from your trial notes.

### Check yourself

1. You are on Linux. Which command installs the CPU build of PyTorch?
   - A. `pip install torch-cpu`
   - B. `pip install torch --index-url https://download.pytorch.org/whl/cpu`
   - C. `pip install torch --gpu=false`
   - D. `pip install torch`, which already gives the CPU build on every operating system

   Answer: B. On Linux, PyPI serves the GPU (CUDA) build. The `--index-url` option points `pip` at PyTorch's own server, which has a CPU-only copy of each release. On Windows and macOS, plain `pip install torch` already gives the CPU build.

2. In `hello_torch.py`, what does `loss.backward()` do?
   - A. Moves every weight one step downhill, using the learning rate of 0.5
   - B. Resets the gradients from the last step so they don't add up
   - C. Works out the gradient of the loss for every weight automatically
   - D. Runs the training loop backwards to undo the last weight update

   Answer: C. `backward()` computes the gradients, the slopes you calculated by hand in Unit 17. `optimizer.step()` then moves the weights, and `zero_grad()` clears the old gradients before the next step.

3. Why does the embedding test work offline on the second run?
   - A. The model is built into the sentence-transformers library itself
   - B. Hugging Face caches the texts you compared, not the model
   - C. The model runs on SAP BTP after the first call to Hugging Face
   - D. The model is downloaded once and then loaded from your disk

   Answer: D. The library contains no model. The first call downloads `all-MiniLM-L6-v2` from Hugging Face; later runs load the copy on your computer, so they start faster and need no network.

4. What does `model.similarity(...)` return in the smoke test?
   - A. A score per candidate for how close its vector is to the query's
   - B. The 384 numbers that make up each candidate's vector, one row per text
   - C. The probability that each candidate text is about a sales order
   - D. The number of words each candidate shares with the query text

   Answer: A. `encode` turns each text into a vector of 384 numbers. `similarity` compares the query's vector with each candidate's and returns a score, where higher means more alike. It compares meaning, not shared words.

5. How is an SAP BTP trial account organized?
   - A. One subaccount per service, each in its own region, under a shared global account
   - B. A single Cloud Foundry space with no subaccounts and no global account
   - C. A global account, a `trial` subaccount in one region, a Cloud Foundry org and a `dev` space
   - D. A directory per learner inside SAP's own global account, with all learners sharing one `dev` space

   Answer: C. SAP creates a global account for you with one subaccount, `trial`, in the region you chose. The subaccount has one Cloud Foundry org, linked one-to-one, and one space named `dev` for deploying apps.

6. What is the difference between a service instance and a subscription in the cockpit?
   - A. An instance is free, while a subscription is always paid through entitlements
   - B. A subscription lives in the global account, while an instance lives in the org
   - C. They are the same thing, shown under two names in Instances and Subscriptions
   - D. A subscription runs on its own; an instance is used by an app you deploy

   Answer: D. Both come from the Service Marketplace and appear under Instances and Subscriptions. A subscription is a standalone application; a service instance needs a runtime and is used by an application you deploy.

7. You haven't signed in to your trial for five weeks, and the cockpit says it is suspended. What happened, and what do you do?
   - A. Thirty days without sign-in suspends it; create a new trial from your notes
   - B. Your region was shut down; move the subaccount to another region in the cockpit
   - C. The midnight daily stop suspended it; restart your apps from the cockpit
   - D. Your entitlements ran out; buy a Pay-As-You-Go plan to continue the trial

   Answer: A. SAP's documentation suspends trials after 30 days without sign-in, and suspended trials are deleted. Create a new trial; your notes file makes that quick. The daily stop only stops apps; it doesn't suspend the account.

8. A colleague wants to load real customer master data into your trial to test semantic search. What do you say?
   - A. Fine, as long as the trial subaccount's region is inside the EU
   - B. Fine, if the data is deleted before the 90-day trial period ends
   - C. No; a trial is for personal learning, not team or production use
   - D. Fine, because the embedding model runs locally and sends nothing out

   Answer: C. SAP's documentation says a trial must not be used for production or team development, and company data doesn't belong in a personal account. Use made-up data now, and a proper subaccount under a contract for real pilots.

## Sources

- [torch (PyPI)](https://pypi.org/project/torch/): latest release 2.14.0 (September 2026), requires Python 3.10 or newer; wheels for Windows x86-64, Linux x86-64 and ARM64, macOS 14 or newer on Apple silicon (ARM64)
- [Previous PyTorch versions (pytorch.org)](https://pytorch.org/get-started/previous-versions/): CPU-only pip command for Linux and Windows uses --index-url https://download.pytorch.org/whl/cpu; macOS uses the plain pip command
- [Using uv with PyTorch (Astral docs)](https://docs.astral.sh/uv/guides/integration/pytorch/): PyPI hosts CPU-only PyTorch wheels for Windows and macOS and GPU (CUDA) wheels for Linux; CPU index URL
- [sentence-transformers (PyPI)](https://pypi.org/project/sentence-transformers/): release 6.1.0 (September 2026), Python 3.10+, recommends PyTorch 2.2+ and transformers v5+; quickstart with all-MiniLM-L6-v2 (384 numbers per text), encode and similarity; Apache 2.0
- [Trial Accounts and Free Tier (SAP BTP documentation source, SAP-docs on GitHub)](https://github.com/SAP-docs/btp-cloud-platform/blob/main/docs/10-concepts/trial-accounts-and-free-tier-046f127.md): 90-day trial, suspension after 30 days without sign-in, automatic deletion after 90 days, daily app stop, resource limits, not for production or team development; free tier needs a Pay-As-You-Go or CPEA account
- [Get an Account on SAP BTP Trial (SAP Developers tutorial)](https://developers.sap.com/tutorials/hcp-create-trial-account/): Log On, Register, email activation, Try Now, cockpit URL, region choice, Create Account, Continue, the trial subaccount tile, Service Marketplace
- [Take a Tour of SAP BTP Trial (SAP tutorial source on GitHub)](https://github.com/sap-tutorials/Tutorials/blob/master/tutorials/cp-trial-quick-onboarding/cp-trial-quick-onboarding.md): global account, trial subaccount, one Cloud Foundry org per subaccount, dev space, Extend Trial, Enable Kyma, breadcrumbs, Trial Home
- [SAP BTP trial (sap.com)](https://www.sap.com/products/technology-platform/trial.html): 90-day trial, Try Now, trial is non-commercial and deleted at the end; free tier is a separate commercial model
- [Explaining SAP BTP account model (SAP Learning)](https://learning.sap.com/courses/operating-sap-business-technology-platform/explaining-sap-btp-account-model): global account as the contract with SAP, directories, subaccounts in one region, entitlements
- [Managing service subscriptions (SAP Learning)](https://learning.sap.com/courses/operating-sap-business-technology-platform/managing-service-subscriptions): Service Marketplace, service plans, Instances and Subscriptions; a subscription runs standalone
