Infer (one-shot inference)

Prompt a model you just trained and see it stream

Prompt a model you just trained and watch it stream a reply — the fastest way to answer “did it work?”.

bash
praisonai-train infer -d lora_model "Summarise this release."
Diagram

praisonai-train infer

💬 prompt

📦 load adapter

🧩 chat template

✅ streamed tokens

Quick Start

  1. Prompt the trained model

    Point at a trained adapter and pass a prompt — the reply streams token-by-token.

    bash
    praisonai-train infer -d lora_model "Summarise this release."
  2. Tune the output length and sampling

    Bump --max-new-tokens for longer replies; lower --temperature for more focused output.

    bash
    praisonai-train infer -d lora_model "Write release notes." \
        --max-new-tokens 512 --temperature 0.3

How It Works

infer loads the trained model with Unsloth, applies the tokenizer’s chat template with a user role, and streams the generation straight to stdout.

Diagram
ModelTokenizerFastLanguageModelpraisonai-train inferUserModelTokenizerFastLanguageModelpraisonai-train inferUserinfer -d lora_model “prompt”from_pretrained + for_inferencemodel + tokenizerapply chat template (role: user)input idsgenerate (TextStreamer, skip_prompt=True)tokens stream to stdout

The model is loaded via Unsloth’s FastLanguageModel.from_pretrained + for_inference, and generation streams through TextStreamer(tokenizer, skip_prompt=True).


Configuration Options

OptionShortTypeDefaultDescription
prompt (positional)—strrequiredWhat to send the model.
--model-dir-dPath (must exist)lora_modelPath to a trained adapter or model.
--max-new-tokens—int256Maximum new tokens to generate.
--temperature—float0.7Sampling temperature.
--max-seq-length—int2048Context length used when loading the model.
--load-in-4bit / --no-load-in-4bit—boolTrueLoad the model in 4-bit quantisation.

Streaming

The prompt is skipped (skip_prompt=True), so only the model’s reply prints — the first token is your “is it alive?” signal, arriving long before the last on a large model.


Choosing between infer, serve, benchmark

Three commands touch a trained model — pick by what you’re trying to answer.

Diagram

Prove the fine-tune works

Persistent OpenAI endpoint

tokens/sec on a remote API

What do you need?

✅ infer
one prompt, streamed reply

✅ serve
OpenAI-compatible HTTP

✅ benchmark
rank deployments

infer runs a single local generation; serve stands up an OpenAI-compatible endpoint; benchmark measures throughput on already-deployed remote APIs.


Best Practices

Install the [llm] extra first

infer needs the Unsloth / Transformers stack. Run pip install "praisonai-train[llm]" — otherwise the command exits 1 with that exact remediation.

Keep the defaults for a sanity check

temperature=0.7 and max-new-tokens=256 are deliberately usable defaults. Leave them for a first “did my fine-tune take?” check and only bump --max-new-tokens when you need longer outputs.

Disable 4-bit only when you need to

Turn off --load-in-4bit only if the model doesn’t fit in 4-bit or you’re comparing against full-precision output. The 4-bit default keeps memory low.

One prompt, one generation

infer is not a chat loop — it sends a single prompt and streams one reply, then exits. For a persistent endpoint use serve instead.


Related