You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maintainer here. For a Rust application that wants to own model lifetime and consume generated text directly, Ferrum exposes the same engine abstraction used by its CLI and server. The application calls the engine directly.
This example covers in-process text generation; vector embeddings and reranking are separate model tasks.
The public builder selects a real tokenizer and executor when a model path is supplied. This example selects the CPU Llama executor. Use a locally provisioned, unquantized LlamaForCausalLM SafeTensors checkpoint with its config.json, tokenizer files and referenced weight shards. Allow enough RAM for the selected model.
Run it with your model directory and a UTF-8 prompt file:
cargo run --manifest-path example/Cargo.toml -- /absolute/llama-directory /absolute/prompt.txt
The program performs two generations: one collected response, then one stream. Supply a raw completion prompt, or apply your instruction model's chat template before calling the engine. The generation interface accepts InferenceRequest, not OpenAI messages.
Your application owns the Tokio runtime, local model files, prompt construction, request limits and shutdown ordering. Here it admits one active request, sets a 2,048-token context limit and requests at most 64 new tokens. Ferrum manages scheduling and execution resources within that configuration. Both successful and failed generation paths await shutdown.
Choose ferrum serve when multiple clients need a separate process and OpenAI-compatible HTTP endpoints; choose the library when direct Rust calls and host-managed lifecycle fit your application.
Verification: this complete example passed CPU cargo check against the immutable v0.8.8 source using cached dependencies. No model was loaded or inference measured for this tutorial. Written with AI assistance and reviewed against release source.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Maintainer here. For a Rust application that wants to own model lifetime and consume generated text directly, Ferrum exposes the same engine abstraction used by its CLI and server. The application calls the engine directly.
This example covers in-process text generation; vector embeddings and reranking are separate model tasks.
The public builder selects a real tokenizer and executor when a model path is supplied. This example selects the CPU Llama executor. Use a locally provisioned, unquantized LlamaForCausalLM SafeTensors checkpoint with its config.json, tokenizer files and referenced weight shards. Allow enough RAM for the selected model.
Start with the released source:
git clone --depth 1 --branch v0.8.8 https://github.com/sizzlecar/ferrum-infer-rs source mkdir -p example/srcPut this in example/Cargo.toml:
And example/src/main.rs:
Run it with your model directory and a UTF-8 prompt file:
The program performs two generations: one collected response, then one stream. Supply a raw completion prompt, or apply your instruction model's chat template before calling the engine. The generation interface accepts InferenceRequest, not OpenAI messages.
Your application owns the Tokio runtime, local model files, prompt construction, request limits and shutdown ordering. Here it admits one active request, sets a 2,048-token context limit and requests at most 64 new tokens. Ferrum manages scheduling and execution resources within that configuration. Both successful and failed generation paths await shutdown.
Choose ferrum serve when multiple clients need a separate process and OpenAI-compatible HTTP endpoints; choose the library when direct Rust calls and host-managed lifecycle fit your application.
Verification: this complete example passed CPU cargo check against the immutable v0.8.8 source using cached dependencies. No model was loaded or inference measured for this tutorial. Written with AI assistance and reviewed against release source.
All reactions