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

# Speculative summarization

<Tip>
  In this example, we will use the `summarization` speculation preset to generate a summary of the input text.
</Tip>

<Tabs>
  <Tab title="Python">
    <Steps>
      <Step title="Create a new project">
        ```sh theme={null}
        uv init demo && cd demo
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        uv add uzu
        ```
      </Step>

      <Step title="Paste into main.py">
        <CodePython />
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        uv run main.py
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Swift">
    <Steps>
      <Step title="Create a new SwiftUI project">
        <img src="https://mintcdn.com/mirai-bded675a/-MIzY7hlOp3HioeZ/images/quick-start/xcode-new-project.png?fit=max&auto=format&n=-MIzY7hlOp3HioeZ&q=85&s=7ef3a6a5ada8fec6d6cfe024e598e278" alt="" width="1430" height="1020" data-path="images/quick-start/xcode-new-project.png" />
      </Step>

      <Step title="Add the SDK">
        Add this package through SPM:

        ```sh theme={null}
        https://github.com/trymirai/uzu.git
        ```
      </Step>

      <Step title="Paste the snippet">
        <CodeSwift />
      </Step>

      <Step title="Add the snippet call">
        ```swift theme={null}
        var body: some View {
            VStack {
                Text("On-device AI")
            }
            .onAppear() {
                Task {
                    try await runExampleName()
                }
            }
        }
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="TypeScript">
    <Steps>
      <Step title="Make a new project folder">
        ```sh theme={null}
        mkdir demo && cd demo
        ```
      </Step>

      <Step title="Initialize with pnpm">
        ```sh theme={null}
        pnpm init
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        pnpm add typescript ts-node @types/node -D
        pnpm add @trymirai/uzu
        ```
      </Step>

      <Step title="Initialize a tsconfig.json">
        ```json theme={null}
        {
            "compilerOptions": {
                "target": "es2020",
                "module": "commonjs",
                "moduleResolution": "node",
                "strict": true,
                "esModuleInterop": true,
                "outDir": "dist",
                "types": [
                    "node"
                ]
            },
            "include": [
                "*.ts"
            ]
        }
        ```
      </Step>

      <Step title="Create main.ts">
        <CodeTypeScript />
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        pnpm ts-node main.ts
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Rust">
    <Steps>
      <Step title="Create a new project">
        ```sh theme={null}
        cargo new demo && cd demo
        ```
      </Step>

      <Step title="Install dependencies">
        ```sh theme={null}
        cargo add uzu --git https://github.com/trymirai/uzu
        cargo add tokio --features full
        ```
      </Step>

      <Step title="Paste into src/main.rs">
        <CodeRust />
      </Step>

      <Step title="Run the snippet">
        ```sh theme={null}
        cargo run --release
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

<Info>
  You will notice that the model's run count is lower than the actual number of generated tokens due to speculative decoding, which significantly improves generation speed.
</Info>
