Skip to main content

LFM ONNX HF Library

Install

pip install lfm-onnx-hf

Python Usage

Basic Prompt (sync, stream=False)

from lfm_onnx_hf import LFMOnnxEngine, GenerationConfig

engine = LFMOnnxEngine()

text = engine.basic_prompt(
    "What is the capital of France?",
    stream=False,
    generation=GenerationConfig(
        max_new_tokens=64,
        temperature=0.0,
        top_k=50,
        repetition_penalty=1.05,
        seed=42,
    ),
)
print(text)

Basic Prompt (sync, stream=True)

from lfm_onnx_hf import LFMOnnxEngine

engine = LFMOnnxEngine()

for chunk in engine.basic_prompt("Write a one-line poem about the sea.", stream=True):
    print(chunk, end="", flush=True)
print()

Basic Prompt + Assistant Prefill

from lfm_onnx_hf import LFMOnnxEngine

engine = LFMOnnxEngine()

text = engine.basic_prompt(
    "Return strict JSON with fields city and country.",
    assistant_prefill="```json\n",
    stop_tokens=["```"],
    stream=False,
)
print(text)

Chat Input (sync, stream=False)

from lfm_onnx_hf import LFMOnnxEngine

engine = LFMOnnxEngine()

turns = [
    {"role": "user", "content": "My name is Ana."},
    {"role": "user", "content": "What is my name?"},
]

text = engine.chat_input(turns, stream=False)
print(text)

Chat Input (sync, stream=True)

from lfm_onnx_hf import LFMOnnxEngine

engine = LFMOnnxEngine()

turns = [{"role": "user", "content": "Give me 3 short productivity tips."}]

for chunk in engine.chat_input(turns, stream=True):
    print(chunk, end="", flush=True)
print()

Full Generate API (sync)

from lfm_onnx_hf import LFMOnnxEngine

engine = LFMOnnxEngine()

messages = [{"role": "user", "content": "Explain recursion in 2 sentences."}]
text, stats = engine.generate(
    messages=messages,
    max_new_tokens=80,
    temperature=0.1,
    top_k=50,
    repetition_penalty=1.05,
    seed=7,
    assistant_prefill="",
    stop_tokens=["```"],
)

print(text)
print(stats)

Async Usage (stream=False and stream=True)

import asyncio
from lfm_onnx_hf import LFMOnnxEngine


async def main():
    engine = LFMOnnxEngine()

    # async non-stream
    text = await engine.basic_prompt_async(
        "One word for water in French?",
        stream=False,
        stop_tokens=["```"],
    )
    print(text)

    # async stream
    stream_iter = await engine.chat_input_async(
        [{"role": "user", "content": "List 5 planets."}],
        stream=True,
    )
    async for chunk in stream_iter:
        print(chunk, end="", flush=True)
    print()


asyncio.run(main())

Hugging Face Source

By default, first use downloads from:

  • Repo: cnmoro/LFM-Q4-GGUFS
  • Subfolder: 2_5_350m
  • Model: model_q4.slim.spec.strip.min.onnx

CLI Usage

Basic

lfm-onnx-hf \
  --prompt "What is the capital of France?" \
  --max-new-tokens 64 \
  --temperature 0.0

Stream Output

lfm-onnx-hf \
  --prompt "Write a short haiku about rain" \
  --stream

Assistant Prefill

lfm-onnx-hf \
  --prompt "Return strict JSON with fields city and country" \
    --assistant-prefill '```json\n' \
    --stop-token '```'

Multi-turn Messages

lfm-onnx-hf \
  --messages-json '[{"role":"system","content":"Be concise."},{"role":"user","content":"Summarize photosynthesis in one paragraph."}]'

HF Options

lfm-onnx-hf \
  --repo-id cnmoro/LFM-Q4-GGUFS \
  --subfolder 2_5_350m \
  --model model_q4.slim.spec.strip.min.onnx \
  --download-max-retries 8 \
  --download-initial-backoff 1.5

Common CLI Options

  • --repo-id
  • --subfolder
  • --model
  • --revision
  • --token
  • --cache-root
  • --prompt
  • --system
  • --messages-json
  • --max-new-tokens
  • --temperature
  • --top-k
  • --repetition-penalty
  • --seed
  • --stream
  • --assistant-prefill
  • --stop-token (repeatable)
  • --benchmark-runs
  • --provider
  • --intra-op-threads
  • --inter-op-threads
  • --download-max-retries
  • --download-initial-backoff

Metadata

Release files for lfm-onnx-hf 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lfm-onnx-hf 0.1.3
File Size Uploaded Provenance
lfm_onnx_hf-0.1.3.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lfm-onnx-hf 0.1.3
File Interpreter ABI Platform
lfm_onnx_hf-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / lfm_onnx_hf-0.1.3.tar.gz

Download URL lfm_onnx_hf-0.1.3.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
df457e01cd3d5a23dc14c587170ecdf7dd4db4a49bc1b1da29558a96714d638b
BLAKE2b-256 checksum
How to use checksums
7b4d62ffbea30e9fc3732dd1eb8846ceae47f469c6dd2cfabd1735d545362071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / lfm_onnx_hf-0.1.3-py3-none-any.whl

Download URL lfm_onnx_hf-0.1.3-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79c1ce8fbdf51af8ae7ffaddbf700893edc3ad4bb5f5c515b7191dc6ac9ec8ff
BLAKE2b-256 checksum
How to use checksums
c3d95d9f949106a7e98635f07a7d6c155477bee3608e0e2cf1dfbcf96e99fe5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for lfm-onnx-hf 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page