[2025]LlamaDuo: LLMOps Pipeline for Seamless Migration from Service LLMs to Small-Scale Local LLMs
한줄 요약:
소형라마 학습(서비스에 맞게 대형LLM이용)
짧은 요약(Abstract) :
클라우드 기반의 대형 언어 모델(LLM)의 확산은 운영 종속성, 개인정보 문제, 지속적인 인터넷 연결 필요 등 여러 문제를 야기합니다. 이에 본 논문에서는 “LlamaDuo”라는 LLMOps 파이프라인을 제안하여, 서비스형 LLM에서 소형 로컬 LLM으로 지식과 기능을 원활하게 이전할 수 있도록 합니다. 이 파이프라인은 서비스 장애나 오프라인 상황에서도 AI 서비스를 지속할 수 있게 돕습니다.
LlamaDuo는 먼저 서비스 LLM이 생성한 합성 데이터로 작은 LLM을 파인튜닝합니다. 만약 성능이 기대에 못 미칠 경우, 서비스 LLM이 생성한 추가 데이터를 이용해 반복적으로 모델을 개선합니다. 이를 통해 소형 모델이 특정 작업에서 서비스 LLM에 맞먹거나 그 이상의 성능을 발휘할 수 있습니다. 다양한 다운스트림 작업에서 LlamaDuo의 효과성과 비용 효율성을 실험으로 입증하였고, 전체 파이프라인 코드는 공개되어 있습니다.
⸻
The widespread adoption of cloud-based proprietary large language models (LLMs) has introduced significant challenges, including operational dependencies, privacy concerns, and the necessity of continuous internet connectivity. In this work, we introduce an LLMOps pipeline, “LlamaDuo”, for the seamless migration of knowledge and abilities from service-oriented LLMs to smaller, locally manageable models. This pipeline is crucial for ensuring service continuity in the presence of operational failures, strict privacy policies, or offline requirements. Our LlamaDuo involves fine-tuning a small language model against the service LLM using a synthetic dataset generated by the latter. If the performance of the fine-tuned model falls short of expectations, it is enhanced by further fine-tuning with additional similar data created by the service LLM. This iterative process guarantees that the smaller model can eventually match or even surpass the service LLM’s capabilities in specific downstream tasks, offering a practical and scalable solution for managing AI deployments in constrained environments. Extensive experiments with leading-edge LLMs are conducted to demonstrate the effectiveness, adaptability, and affordability of LlamaDuo across various downstream tasks. Our pipeline implementation is available at https://github.com/deep-diver/llamaduo.
⸻
* Useful sentences : 단어정리
Methodology
본 논문은 서비스형 대형 언어 모델(LLM)에서 로컬 소형 LLM으로 지식과 기능을 이전하는 자동화된 LLMOps 파이프라인인 LlamaDuo를 제안합니다. 이 방법은 다음과 같은 구성요소로 이루어집니다: 1. Coverage Dataset 구축: 사용자 상호작용 로그(프롬프트 및 응답 중 만족스러운 쌍)를 수집하고 이를 학습/테스트 데이터셋으로 나눔. 2. 1차 파인튜닝: 수집한 coverage train 데이터를 이용하여 로컬 LLM을 초기 파인튜닝. 3. 성능 평가 (서비스 LLM 평가자): 테스트 데이터셋에 대해 파인튜닝된 로컬 LLM 응답을 생성하고, 서비스 LLM(GPT4o, Claude 3, Gemini 등)을 활용해 유사도와 정확도를 평가함. 4. 합성 데이터 생성: 성능이 기준 이하일 경우, 기존 train 데이터를 시드로 하여 서비스 LLM으로부터 추가적인 instruction-response 쌍을 생성. 5. 반복적 파인튜닝: 새로 생성된 합성 데이터를 누적하며 로컬 LLM을 재학습. 6. 종단 모델 확보 및 배포: 평가 기준을 만족하는 모델이 나올 때까지 위 과정을 반복한 후, 최종 모델을 오프라인 환경에 배포.
이 파이프라인은 프라이버시가 중요한 환경, 인터넷 연결이 제한된 상황, 또는 비용 효율성이 요구되는 경우에 적합하며, 실험 결과에서도 소형 LLM이 서비스 LLM 성능에 근접하거나 초과할 수 있음을 보여줍니다.
⸻
The proposed LlamaDuo pipeline automates the transition from service-based LLMs (e.g., GPT-4o, Claude 3, Gemini) to small-scale, locally deployable LLMs. It consists of the following steps: 1. Coverage Dataset Collection: Prompts and responses from real user interactions with service LLMs are curated. Satisfactory pairs are collected and split into train and test subsets. 2. Initial Fine-tuning: A small local LLM (e.g., Gemma 2B/7B, LLaMA3 8B) is fine-tuned on the coverage train set using supervised learning. 3. Evaluation (Service LLM as Judge): The fine-tuned local model generates responses for the test set. These responses are evaluated by the service LLM using similarity and precision metrics, following pairwise comparison and scoring-based strategies. 4. Synthetic Data Generation: If model performance falls short of a predefined threshold, the service LLM is prompted with the train set to generate additional synthetic (instruction, response) pairs. 5. Iterative Fine-tuning: The local LLM is fine-tuned repeatedly using the growing set of synthetic data until performance thresholds are met. 6. Final Deployment: Once the local model meets or exceeds the target performance, it is deployed in constrained environments (e.g., offline, privacy-sensitive settings).
This method ensures that a lightweight local LLM can achieve near-parity or even surpass the service LLM on specific downstream tasks while offering better control, privacy, and long-term cost efficiency.
⸻
Results
- 경쟁 모델 (Models): • 서비스 LLMs (Service LLMs): • GPT-4o (OpenAI) • Claude 3 Sonnet (Anthropic) • Gemini 1.5 Flash (Google DeepMind) • 로컬 소형 LLMs (Local Small LLMs): • Gemma 2B, Gemma 7B • Mistral 7B • LLaMA3 8B
⸻
- 테스트 데이터 (Test Data): • Hugging Face의 No Robots 데이터셋에서 4가지 작업별로 고르게 수집됨: • Summarization • Classification • Coding • Closed QA • 초기 coverage dataset에서 일부를 test set으로 분할 (예: summarization의 경우 100개 테스트 샘플)
⸻
- 평가 메트릭 (Evaluation Metrics): • 서비스 LLM이 평가자 역할 수행 (LLM-as-a-Judge) • 유사도(Similarity): 모델 응답이 정답과 얼마나 유사한가 • 정확도(Precision): 모델 응답이 프롬프트를 얼마나 잘 따랐는가 • 점수는 0~100 스케일로 평가되며, 평균 점수(mean) 및 커버리지 비율(정해진 기준 점수 이상 비율)로 측정
⸻
- 주요 결과 요약 (Summary): • 소형 LLM들도 충분한 합성 데이터로 학습하면 GPT-4o, Claude 3 등 대형 모델에 근접하거나 초과 가능 • 예시: • LLaMA3 8B는 분류(Classification) 작업에서 GPT-4o 수준의 성능 달성 • Gemma 7B는 코딩 작업에서 Claude 3에 근접 • Mistral 7B는 요약(Summarization)과 QA 작업에서 강세 • 특히 Gemma 2B처럼 작은 모델도 충분한 데이터와 반복 학습으로 실용적 수준에 도달 가능
⸻
- Competing Models: • Service LLMs: • GPT-4o (OpenAI) • Claude 3 Sonnet (Anthropic) • Gemini 1.5 Flash (Google DeepMind) • Local Small LLMs: • Gemma 2B, Gemma 7B • Mistral 7B • LLaMA3 8B
⸻
- Test Data: • Derived from the No Robots dataset by Hugging Face, covering 4 downstream tasks: • Summarization • Classification • Coding • Closed QA • Each subset (e.g., 100 samples for summarization) is held out as a test set for final evaluation.
⸻
- Evaluation Metrics: • Evaluated using LLM-as-a-Judge strategy: • Similarity: Measures alignment between the generated response and ground truth • Precision: Measures how well the response addresses the given prompt • Both metrics are scored from 0 to 100 • Final evaluation includes: • Mean score • Coverage percentage (proportion of responses above a threshold, e.g., 50 or 70)
⸻
- Key Findings: • Fine-tuned small LLMs can match or even exceed service LLM performance in specific tasks when trained on sufficient synthetic data. • Examples: • LLaMA3 8B matched GPT-4o in classification tasks. • Gemma 7B showed strong coding performance close to Claude 3 Sonnet. • Mistral 7B excelled in summarization and closed QA tasks. • Even Gemma 2B, a much smaller model, achieved competitive performance in some cases, confirming the scalability of the LlamaDuo pipeline.
⸻
예제
- 작업(Task): 요약(Summarization) • 학습 데이터 예시 (Coverage Dataset / Seed for Synthetic): 사용자는 특정 작업을 수행하는 프롬프트와 그에 대한 만족스러운 서비스 LLM의 응답을 수집합니다.
Instruction: 2023년 ChatGPT와 Claude가 어떻게 다르게 작동하는지 설명해줘.
Response: ChatGPT와 Claude는 둘 다 대형 언어 모델이지만, ChatGPT는 OpenAI가 개발한 반면, Claude는 Anthropic에서 개발되었습니다. ChatGPT는 사용자 질문에 직관적으로 답하는 데 강점을 보이며, Claude는 보다 안정적이고 윤리적 제약을 중시하는 방향으로 설계되었습니다.
• 이 데이터를 바탕으로 Claude 3 Sonnet 또는 GPT-4o 같은 서비스 LLM에게 유사한 instruction/response 쌍을 여러 개 생성하도록 요청함. (예: Figure 6 참조)
⸻
- 생성된 합성 데이터 예시 (Training)
{ “contents”: [ { “instruction”: “LLM과 검색 기반 시스템의 주요 차이점을 요약해줘.”, “response”: “LLM은 자연어를 생성하고 이해하는 데 특화되어 있으며, 문맥 기반 응답을 생성합니다. 반면 검색 기반 시스템은 기존 문서를 기반으로 관련 정보를 추출합니다.” }, { “instruction”: “Transformer 구조의 핵심 구성 요소를 설명하고 간단히 요약해줘.”, “response”: “Transformer는 self-attention 메커니즘을 기반으로 하며, 인코더-디코더 구조로 구성됩니다. 핵심 요소로는 multi-head attention, position-wise feed-forward network, 그리고 positional encoding이 있습니다.” } ] }
• 해당 응답은 교육 목적이나 정보성 요약 태스크에 적합하도록 설계됨.
⸻
- 테스트 데이터 예시 (Evaluation) • 테스트 입력 (Test Prompt):
Instruction: GPT-4o가 기존 GPT-4 대비 어떤 점에서 발전했는지 요약해줘.
• 정답 (Human Response):
GPT-4o는 멀티모달 처리 성능이 향상되었고, 속도 및 비용 측면에서도 기존 GPT-4보다 효율적입니다. 또한 음성 인식과 생성 기능이 통합되었습니다.
• 모델 출력 (Language Model Response):
GPT-4o는 텍스트, 이미지, 오디오 등 다양한 입력을 처리할 수 있으며, 빠른 응답 속도와 비용 효율성을 제공합니다. 또한 자연스러운 대화 흐름 유지 기능이 강화되었습니다.
• 서비스 LLM 평가 프롬프트 (Figure 5 기반):
{ “similarity_assessment”: { “score”: 91 }, “precision_assessment”: { “score”: 95 } }
- Task: Summarization • Training Data Example (Coverage Dataset / Seed):
Instruction: Explain how ChatGPT and Claude differ in their design as of 2023.
Response: ChatGPT and Claude are both large language models. ChatGPT is developed by OpenAI, while Claude is from Anthropic. ChatGPT excels in intuitive question answering, whereas Claude is designed with more emphasis on safety and ethical constraints.
• This pair is used to prompt service LLMs (e.g., Claude 3, GPT-4o) to generate new instruction-response pairs in similar format.
⸻
- Synthetic Data Example (Training):
{ “contents”: [ { “instruction”: “Summarize the key differences between LLMs and retrieval-based systems.”, “response”: “LLMs specialize in understanding and generating language using context, while retrieval-based systems extract relevant content from a fixed database. LLMs generate novel text; retrieval systems return existing information.” }, { “instruction”: “Briefly explain the core components of the Transformer architecture.”, “response”: “The Transformer architecture relies on self-attention and includes encoder-decoder modules. Its core components are multi-head attention, position-wise feed-forward networks, and positional encoding.” } ] }
⸻
- Test Data Example (Evaluation): • Test Prompt:
Instruction: Summarize the main improvements of GPT-4o compared to the original GPT-4.
• Reference Response (Human):
GPT-4o improves multimodal processing, is faster and cheaper than GPT-4, and includes built-in speech recognition and generation.
• Model Response (Fine-tuned Local LLM):
GPT-4o can handle text, image, and audio inputs efficiently. It also offers faster response times and cost efficiency, along with better conversational continuity.
• Evaluation Output from Service LLM (based on Figure 5):
{ “similarity_assessment”: { “score”: 91 }, “precision_assessment”: { “score”: 95 } }
⸻
요약
LlamaDuo는 서비스형 LLM으로부터 생성된 합성 데이터를 활용하여 소형 로컬 LLM을 반복적으로 파인튜닝하는 자동화 파이프라인이다. 실험 결과, LLaMA3 8B와 Gemma 7B 등의 모델이 요약, 분류, 코딩, QA 작업에서 GPT-4o 등 대형 모델에 필적하는 성능을 보였다. 예를 들어, GPT-4o가 생성한 테스트 문장을 요약하는 과제에서 로컬 LLM은 90점 이상의 유사도와 정확도를 기록했다.
⸻
LlamaDuo is an automated pipeline that iteratively fine-tunes small local LLMs using synthetic data generated by service LLMs. Experiments show that models like LLaMA3 8B and Gemma 7B achieve performance comparable to GPT-4o across summarization, classification, coding, and QA tasks. For example, in a summarization test generated by GPT-4o, local LLMs achieved similarity and precision scores above 90.
⸻
기타
Figure 1: 파이프라인 개요 • 내용: LlamaDuo는 개발–정렬–배포의 3단계로 구성됨. 사용자 프롬프트로 coverage dataset을 만들고, 이를 통해 로컬 LLM을 파인튜닝한 뒤, 성능이 기준 미달이면 합성 데이터를 반복 생성 및 학습. • 의의: 사람이 개입하지 않아도 자동으로 서비스 LLM에서 로컬 LLM으로 이전 가능.
⸻
Figure 2: Gemma 7B 모델의 합성 데이터 크기에 따른 성능 변화 • 내용: 합성 데이터의 양이 증가할수록 평균 점수 및 커버리지(50점 이상, 70점 이상 응답 비율)가 향상됨. • 의의: 데이터가 많을수록 로컬 LLM의 성능이 GPT-4o 등에 가까워지며, 128k~256k 이상에서는 포화 상태에 도달.
⸻
Figure 3: 정밀도 vs. 유사도 KDE 분포 (Gemma 2B vs. 7B) • 내용: 평가자에 따라 스코어 경향이 다르며, Claude는 관대하고 Gemini는 유사도에 보수적. • 의의: 평가자 선택에 따라 모델 성능 판단이 달라질 수 있으므로 일관된 기준 필요.
⸻
Figure 4 & Table 2: 비용 비교 • 내용: GPT-4o API를 장기간 사용하는 것보다 로컬 LLM을 파인튜닝하고 배포하는 것이 2개월 이후부터 비용 절감에 유리함. • 예시: 1년간 운영 시, GPT-4o는 최대 $117,000, Gemma 7B는 $24,000 내외.
⸻
Table 1: 성능 비교표 (4개 작업 기준) • 모델: GPT-4o, Claude 3, Gemini 1.5 Flash vs. Gemma 2B/7B, Mistral 7B, LLaMA3 8B • 메트릭: 유사도, 정밀도 (평균 점수 / 커버리지%) • 해석: 로컬 모델도 적절한 데이터와 튜닝을 통해 90% 이상까지 도달 가능하며, 일부 작업에서는 서비스 모델 능가.
⸻
Figure 1: Pipeline Overview • Content: LlamaDuo has three stages: Development, Alignment, and Deployment. Users collect prompt-response pairs, fine-tune local models, and iteratively enhance them with synthetic data if needed. • Significance: Enables full automation of model transfer from service LLMs to local models without human intervention.
⸻
Figure 2: Gemma 7B Performance vs. Synthetic Data Volume • Content: Performance metrics (mean score, coverage ≥50 and ≥70) increase with larger synthetic datasets. • Insight: Around 128k–256k samples, the local LLM reaches a performance plateau close to service LLMs.
⸻
Figure 3: KDE Plots – Precision vs. Similarity (Gemma 2B vs. 7B) • Content: Different judges assign different score patterns; Claude is lenient, Gemini is stricter on similarity. • Insight: Evaluation outcomes vary by judge, highlighting the need for consistent benchmarking criteria.
⸻
Figure 4 & Table 2: Cost Comparison • Content: After 2 months, local LLM deployment becomes more cost-effective than continuous GPT-4o API usage. • Example: Over one year, GPT-4o can cost up to $117,000, while a fine-tuned Gemma 7B setup stays under $24,000.
⸻
Table 1: Model Performance Comparison (Across 4 Tasks) • Models: GPT-4o, Claude 3, Gemini 1.5 Flash vs. Gemma 2B/7B, Mistral 7B, LLaMA3 8B • Metrics: Precision / Similarity (Mean Score / Coverage %) • Interpretation: With sufficient tuning, local models approach or even outperform service models in certain tasks, achieving over 90% in multiple benchmarks.
⸻
refer format:
@article{park2024llamaduo, title = {LlamaDuo: LLMOps Pipeline for Seamless Migration from Service LLMs to Small-Scale Local LLMs}, author = {Park, Chansung and Jiang, Juyong and Wang, Fan and Paul, Sayak and Tang, Jing}, journal = {arXiv preprint arXiv:2408.13467}, year = {2024}, url = {https://arxiv.org/abs/2408.13467}, eprint = {2408.13467}, archivePrefix = {arXiv}, primaryClass = {cs.LG} }
Park, Chansung, Juyong Jiang, Fan Wang, Sayak Paul, and Jing Tang. 2024. LlamaDuo: LLMOps Pipeline for Seamless Migration from Service LLMs to Small-Scale Local LLMs. arXiv preprint arXiv:2408.13467. https://arxiv.org/abs/2408.13467.