LiteRT-LM CLI

명령줄 인터페이스 (CLI)를 사용하면 코드를 작성하지 않고도 모델을 즉시 테스트할 수 있습니다.

지원되는 플랫폼:

  • Linux
  • macOS
  • Windows
  • Raspberry Pi

설치

영구적으로 설치하지 않고 litert-lm를 즉시 실행합니다. uv가 필요합니다.

uvx를 사용하여 litert-lm 명령어에 접두사를 지정하여 필요할 때 실행할 수 있습니다.

uvx litert-lm run --help

방법 2: uv (영구 설치)

litert-lm을 시스템 전체 바이너리로 설치합니다. uv가 필요합니다.

uv tool install litert-lm

방법 3: pip

가상 환경 내의 표준 설치 --upgrade을 사용하면 이전 버전이 이미 설치되어 있더라도 최신 버전을 사용할 수 있습니다.

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

업그레이드 중

litert-lm를 최신 버전으로 업그레이드하려면 다음을 실행합니다.

uvx (메서드 1)을 사용하는 경우

별도의 조치는 필요하지 않습니다. uvx는 최신 버전을 자동으로 실행합니다.

uv (메서드 2)로 설치된 경우

uv tool upgrade litert-lm

pip로 설치된 경우 (방법 3)

가상 환경을 활성화하고 다음을 실행합니다.

pip install --upgrade litert-lm

채팅

Hugging Face에서 다운로드하고 모델을 실행합니다.

litert-lm run  \
  --from-huggingface-repo=litert-community/gemma-4-E2B-it-litert-lm \
  gemma-4-E2B-it.litertlm \
  --prompt="What is the capital of France?"

🔴 신규: 멀티 토큰 예측 (MTP)

다중 토큰 예측 (MTP)은 디코딩 속도를 크게 가속화하는 성능 최적화입니다. MTP는 GPU 백엔드의 모든 작업에 권장됩니다.

CLI에서 MTP를 사용 설정하려면 --enable-speculative-decoding=true 플래그를 사용합니다.

litert-lm run  \
  --from-huggingface-repo=litert-community/gemma-4-E2B-it-litert-lm \
  gemma-4-E2B-it.litertlm \
  --backend=gpu \
  --enable-speculative-decoding=true \
  --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=litert-community/gemma-4-E2B-it-litert-lm \
  gemma-4-E2B-it.litertlm \
  --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가 도구 실행: LiteRT-LM CLI가 이 호출을 가로채고 preset.py에 정의된 해당 Python 함수를 실행합니다.
  3. CLI가 tool_response 전송: CLI가 결과를 모델에 다시 전송합니다.
  4. 모델이 최종 답변 생성: 모델이 도구 응답을 사용하여 사용자를 위한 최종 답변을 계산하고 생성합니다.

이 '함수 호출' 루프는 CLI 내에서 자동으로 실행되므로 복잡한 오케스트레이션 코드를 작성하지 않고도 Python 기능을 사용하여 로컬 LLM을 보강할 수 있습니다.

Python, C++, Kotlin API에서도 동일한 기능을 사용할 수 있습니다.

제거 중

litert-lm을 제거하려면 다음 단계를 따르세요.

uvx (메서드 1)을 사용하는 경우

별도의 조치는 필요하지 않습니다. uvx는 임시 캐시에서 실행되며 영구적으로 설치되지 않습니다.

uv (메서드 2)로 설치된 경우

uv tool uninstall litert-lm

pip로 설치된 경우 (방법 3)

pip uninstall litert-lm