LiteRT에서 사용하는 머신러닝 (ML) 모델은 원래
TensorFlow 핵심 라이브러리 및 도구를 사용하여 빌드하고 학습했습니다. 빌드한 후에는
TensorFlow Core를 사용하여 모델을 더 작고 보다 작은
효율적인 ML 모델 형식인 LiteRT 모델입니다.
이 섹션에서는
LiteRT 모델 형식으로 변환할 수 있습니다.
전환 워크플로
TensorFlow 모델을 LiteRT 형식으로 변환하는 데는 몇 가지 경로가 사용될 수 있음
ML 모델의 콘텐츠에 따라
달라질 수 있습니다 이 과정의 첫 단계로
모델을 평가하여 직접 변환할 수 있는지 확인해야 합니다.
이 평가는 모델의 콘텐츠가
TensorFlow 작업에 기반한 표준 LiteRT 런타임 환경입니다.
정의합니다. 모델이 지원되는 집합 외의 연산을 사용하는 경우
모델을 리팩터링하거나 고급 변환 기법을 사용할 수 있습니다.
아래 다이어그램은 모델 변환의 대략적인 단계를 보여줍니다.
그림 1. LiteRT 변환 워크플로
다음 섹션에서는 모델을 평가하고 변환하는 프로세스를 간략하게 설명합니다.
LiteRT와 함께 사용할 수 있습니다.
입력 모델 형식
변환기는 다음 입력 모델 형식으로 사용할 수 있습니다.
SavedModel
(권장): 디스크에 파일 집합으로 저장되는 TensorFlow 모델입니다.
Keras와 concrete 함수 모델 둘 다 SavedModel로 저장 가능
추천 경로를 사용하여 전환할 수 있습니다.
Jax 모델이 있는 경우 TFLiteConverter.experimental_from_jax를 사용할 수 있습니다.
API를 사용하여 LiteRT 형식으로 변환할 수 있습니다. 이 API는
변경할 수 있습니다.
전환 평가
모델 평가는 변환을 시도하기 전에 중요한 단계입니다.
평가할 때
모델의 콘텐츠가 모델 아키텍처와 호환되는지
LiteRT 형식. 또한 모델이 적합한지 확인해야 합니다
모델이 사용하는 데이터 크기 측면에서 모바일 및 에지 기기에 사용할 수 있도록
하드웨어 처리 요구사항, 모델의 전체 크기와
있습니다.
대부분의 모델에서는 변환기가 즉시 작동합니다. 하지만
LiteRT 내장 연산자 라이브러리는
TensorFlow Core 연산자가 있습니다. 즉, 일부 모델에는 추가적인
몇 단계를 거쳐야 합니다
또한 LiteRT에서 지원되는 일부 작업은
성능상의 이유로 사용이 제한됩니다. 자세한 내용은
연산자 호환성 가이드
를 사용하여 변환을 위해 모델을 리팩터링해야 하는지 판단합니다.
모델 변환
LiteRT 변환기는 TensorFlow 모델을 취하여
LiteRT 모델 (최적화된
FlatBuffer 형식:
.tflite 파일 확장자)로 변경됩니다. 로드 가능
직접 변환할 수 있습니다.
변환기는 전환을 맞춤설정하는 3가지 주요 플래그 (또는 옵션)를 사용합니다.
다음과 같습니다.
최적화 플래그를 사용하면
적용할 최적화 유형 지정
확인할 수 있습니다. 가장 일반적으로 사용되는 최적화 기법은
학습 후 수량화를 참조하세요.
메타데이터 플래그를 사용하면 변환된 모델에 메타데이터를 추가할 수 있습니다.
이를 통해 배포 시 플랫폼별 래퍼 코드를
모델을 학습시키는 작업도
반복해야 합니다
Python API를 사용하여 모델을 변환할 수 있습니다.
명령줄 도구를 사용하면 됩니다. 자세한 내용은
단계별 TF 모델 변환 가이드
모델에서 변환기를 실행하는 방법에 대한 지침을 참조하세요.
일반적으로 모델을 표준 LiteRT용으로 변환합니다.
런타임 환경 또는
Google Play 서비스 런타임 환경
(베타) 일부 고급 사용 사례에는
모델 런타임 환경 맞춤설정을
수행할 수 있으며
확인할 수 있습니다. 자세한 내용은
고급 런타임 환경 섹션
개요를 참조하세요.
고급 전환
오류가 발생하는 경우
모델에서 변환기를 실행하는 동안
연산자 호환성 문제입니다. 모든 TensorFlow 작업이
TensorFlow에서 지원
라이트입니다. 모델을 리팩터링하거나
수정된 LiteRT를 만들 수 있는 고급 변환 옵션
형식 모델과 커스텀 런타임 환경이 포함됩니다.
모델 호환성 개요 참조
TensorFlow 및 LiteRT 모델 호환성 자세히 알아보기
고려해야 합니다
모델 호환성 개요의 주제에서는 모델 호환성과
Select 연산자와 같은 모델 리팩터링
참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-24(UTC)"],[],[],null,["# Model conversion overview\n\nThe machine learning (ML) models you use with LiteRT are originally\nbuilt and trained using TensorFlow core libraries and tools. Once you've built\na model with TensorFlow core, you can convert it to a smaller, more\nefficient ML model format called a LiteRT model.\nThis section provides guidance for converting\nyour TensorFlow models to the LiteRT model format.\n| **Note:** If you don't have a model to convert yet, see the [Models overview](./trained) page for guidance on choosing or building models.\n\nConversion workflow\n-------------------\n\nConverting TensorFlow models to LiteRT format can take a few paths\ndepending on the content of your ML model. As the first step of that process,\nyou should evaluate your model to determine if it can be directly converted.\nThis evaluation determines if the content of the model is supported by the\nstandard LiteRT runtime environments based on the TensorFlow operations\nit uses. If your model uses operations outside of the supported set, you have\nthe option to refactor your model or use advanced conversion techniques.\n\nThe diagram below shows the high level steps in converting a model.\n\n**Figure 1.** LiteRT conversion workflow.\n\nThe following sections outline the process of evaluating and converting models\nfor use with LiteRT.\n\n### Input model formats\n\nYou can use the converter with the following input model formats:\n\n- [SavedModel](https://www.tensorflow.org/guide/saved_model) (***recommended***): A TensorFlow model saved as a set of files on disk.\n- [Keras model](https://www.tensorflow.org/guide/keras/overview): A model created using the high level Keras API.\n- [Keras H5 format](https://www.tensorflow.org/guide/keras/save_and_serialize#keras_h5_format): A light-weight alternative to SavedModel format supported by Keras API.\n- [Models built from concrete functions](https://www.tensorflow.org/guide/intro_to_graphs): A model created using the low level TensorFlow API.\n\nYou can save both the Keras and concrete function models as a SavedModel\nand convert using the recommeded path.\n| **Note:** To avoid errors during inference, include signatures when exporting to the SavedModel format. The TensorFlow converter supports converting TensorFlow model's input/output specifications to LiteRT models. See the topic on [adding signatures](./signatures).\n\nIf you have a Jax model, you can use the `TFLiteConverter.experimental_from_jax`\nAPI to convert it to the LiteRT format. Note that this API is subject\nto change while in experimental mode.\n\n### Conversion evaluation\n\nEvaluating your model is an important step before attempting to convert it.\nWhen evaluating,\nyou want to determine if the contents of your model is compatible with the\nLiteRT format. You should also determine if your model is a good fit\nfor use on mobile and edge devices in terms of the size of data the model uses,\nits hardware processing requirements, and the model's overall size and\ncomplexity.\n\nFor many models, the converter should work out of the box. However,\nLiteRT builtin operator library supports a subset of\nTensorFlow core operators, which means some models may need additional\nsteps before converting to LiteRT.\nAdditionally some operations that are supported by LiteRT have\nrestricted usage requirements for performance reasons. See the\n[operator compatibility](./ops_compatibility) guide\nto determine if your model needs to be refactored for conversion.\n| **Key Point:** Most models can be directly converted to LiteRT format. Some models may require refactoring or use of advanced conversion techniques to make them compatible.\n\n### Model conversion\n\nThe LiteRT converter takes a TensorFlow model and generates a\nLiteRT model (an optimized\n[FlatBuffer](https://google.github.io/flatbuffers/) format identified by the\n`.tflite` file extension). You can load\na SavedModel or directly convert a model you create in code.\n\nThe converter takes 3 main flags (or options) that customize the conversion\nfor your model:\n\n1. [Compatibility flags](./ops_compatibility) allow you to specify whether the conversion should allow custom operators.\n2. [Optimization flags](./model_optimization) allow you to specify the type of optimization to apply during conversion. The most commonly used optimization technique is [post-training quanitization](./post_training_quant).\n3. [Metadata flags](./metadata) allow you to add metadata to the converted model which makes it easier to create platform specific wrapper code when deploying models on devices.\n\nYou can convert your model using the [Python API](./convert_tf#python_api) or\nthe [Command line](./convert_tf#cmdline) tool. See the\n[Convert TF model](./convert_tf) guide for step by step\ninstructions on running the converter on your model.\n\nTypically you would convert your model for the standard LiteRT\n[runtime environment](../android/index#runtime) or the\n[Google Play services runtime environment](../android/play_services)\nfor LiteRT (Beta). Some advanced use cases require\ncustomization of model runtime environment, which require additional steps in\nthe conversion proceess. See the\n[advanced runtime environment](../android#adv_runtime) section of the Android\noverview for more guidance.\n\nAdvanced conversion\n-------------------\n\nIf you run into [errors](./convert_tf#conversion_errors)\nwhile running the converter on your model, it's most likely that you have an\noperator compatibility issue. Not all TensorFlow operations are\nsupported by TensorFlow\nLite. You can work around these issues by refactoring your model, or by using\nadvanced conversion options that allow you to create a modified LiteRT\nformat model and a custom runtime environment for that model.\n\n- See the [Model compatibility overview](./ops_compatibility) for more information on TensorFlow and LiteRT model compatibility considerations.\n- Topics under the Model compatibility overview cover advanced techniques for refactoring your model, such as the [Select operators](./ops_select) guide.\n- For full list of operations and limitations see [LiteRT Ops page](https://www.tensorflow.org/mlir/tfl_ops).\n\nNext steps\n----------\n\n- See the [convert TF models](./convert_tf) guide to quickly get started on converting your model.\n- See the [optimization overview](./model_optimization) for guidance on how to optimize your converted model using techniques like [post-training quanitization](./post_training_quantization).\n- See the [Adding metadata overview](./metadata) to learn how to add metadata to your models. Metadata provides other uses a description of your model as well as information that can be leveraged by code generators."]]