LiteRT-LM CLI

कमांड लाइन इंटरफ़ेस (सीएलआई) की मदद से, मॉडल को तुरंत टेस्ट किया जा सकता है. इसके लिए, कोड की ज़रूरत नहीं होती.

इस्तेमाल किए जा सकने वाले प्लैटफ़ॉर्म:

  • Linux
  • macOS
  • Windows (WSL के ज़रिए)
  • Raspberry Pi

इंस्टॉल करना

यह पूरे सिस्टम के लिए, litert-lm को बाइनरी के तौर पर इंस्टॉल करता है. इसके लिए uv की ज़रूरत होती है.

uv tool install litert-lm-nightly

दूसरा तरीका: pip

वर्चुअल एनवायरमेंट में स्टैंडर्ड इंस्टॉलेशन.

python3 -m venv .venv
source .venv/bin/activate
pip install litert-lm-nightly

Chat

HuggingFace से मॉडल डाउनलोड करें और उसे चलाएं:

litert-lm run  \
  --from-huggingface-repo=google/gemma-3n-E2B-it-litert-lm \
  gemma-3n-E2B-it-int4 \
  --prompt="What is the capital of France?"

फ़ंक्शन कॉल / टूल

प्रीसेट की मदद से टूल चलाए जा सकते हैं. preset.py बनाने के लिए:

import datetime
import base64

def get_current_time() -> str:
    """Returns the current date and time."""
    return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

system_instruction = "You are a helpful assistant with access to tools."
tools = [get_current_time]

प्रीसेट के साथ चलाएं:

litert-lm run  \
  --from-huggingface-repo=google/gemma-3n-E2B-it-litert-lm \
  gemma-3n-E2B-it-int4 \
  --preset=preset.py

प्रॉम्प्ट के सैंपल और इंटरैक्टिव आउटपुट:

> what will the time be in two hours?
[tool_call] {"arguments": {}, "name": "get_current_time"}
[tool_response] {"name": "get_current_time", "response": "2026-03-25 21:54:07"}
The current time is 2026-03-25 21:54:07.

In two hours, it will be **2026-03-25 23:54:07**.

यहां क्या हो रहा है?

जब कोई ऐसा सवाल पूछा जाता है जिसके लिए बाहरी जानकारी की ज़रूरत होती है (जैसे, मौजूदा समय), तो मॉडल को पता चल जाता है कि उसे किसी टूल को कॉल करना है.

  1. मॉडल tool_call जनरेट करता है: मॉडल, get_current_time फ़ंक्शन को कॉल करने के लिए JSON अनुरोध जनरेट करता है.
  2. CLI Executes Tool: LiteRT-LM CLI इस कॉल को इंटरसेप्ट करता है और आपके preset.py में तय किए गए Python फ़ंक्शन को लागू करता है.
  3. सीएलआई tool_response भेजता है: सीएलआई, मॉडल को नतीजा वापस भेजता है.
  4. मॉडल, आखिरी जवाब जनरेट करता है: मॉडल, टूल के जवाब का इस्तेमाल करके, उपयोगकर्ता के लिए आखिरी जवाब जनरेट करता है.

सीएलआई में "फ़ंक्शन कॉल करना" लूप अपने-आप होता है. इससे आपको Python की सुविधाओं के साथ लोकल एलएलएम को बेहतर बनाने में मदद मिलती है. इसके लिए, आपको कोई जटिल ऑर्केस्ट्रेशन कोड लिखने की ज़रूरत नहीं होती.

ये सुविधाएं Python, C++, और Kotlin एपीआई के ज़रिए भी उपलब्ध हैं.