Continuous Learning_Startup & Investment – Telegram
Continuous Learning_Startup & Investment
2.4K subscribers
513 photos
5 videos
16 files
2.72K links
We journey together through the captivating realms of entrepreneurship, investment, life, and technology. This is my chronicle of exploration, where I capture and share the lessons that shape our world. Join us and let's never stop learning!
Download Telegram
LLM을 Production Level에서 학습하고 운영하면서 겪는 챌린지들

1. (Comparatively small) Large Language Model Use-cases?
1. 헬스케어:
- BioMed LM(2.7 billion parameters)
- 비교적 규모가 작은 대규모 언어 모델(LLM) 사용 사례로 잘 알려진 것 중 하나는 MosaicML과 스탠포드 기초 모델 연구 센터(CRFM)에서 개발한 생의학 텍스트를 위한 도메인 전용 LLM인 BioMedLM입니다. 이 모델은 특히 생의학 분야를 위한 산업별 LLM의 기능을 보여줍니다.
2. 금융: 금융 기관은 기술 지원, 사기 탐지, 보고, 금융 뉴스에 대한 정서 분석에 LLM을 활용할 수 있습니다.
- [BloombergGPT](https://www.bloomberg.com/company/press/bloomberggpt-50-billion-parameter-llm-tuned-finance/)
- [FinGPT(Opensource)](https://the-decoder.com/fingpt-is-an-ai-financial-framework-designed-to-learn-from-the-wisdom-of-the-market/)
3. 프로그래밍: [Replit의 7B LLM](https://huggingface.co/replit/replit-code-v1-3b)인 replit-code-v1-3b는 코드 완성에 중점을 둔 27B 인과 언어 모델로서, 여러 프로그래밍 언어가 포함된 데이터 세트에서 학습되었습니다.


2. What are the pros and cons for training own large language models?
1. 장점
1. 컨텐츠/필터 제어: 자체 LLM을 교육함으로써 특정 요구 사항과 선호도에 맞게 모델을 조정하여 회사의 목표와 가치에 부합하도록 할 수 있습니다.**[1](https://www.brookings.edu/articles/exploring-the-impact-of-language-models/)**
2. 모델 및 지적 재산에 대한 소유권: 자체 LLM을 개발하면 모델과 그 기반 기술에 대한 완전한 소유권을 보유할 수 있으며, 이는 귀사의 귀중한 자산이 될 수 있습니다.**[1](https://www.brookings.edu/articles/exploring-the-impact-of-language-models/)**
3. 설명 가능성 및 투명성 향상: 자체 LLM을 교육하면 모델 내부를 더 잘 제어할 수 있으므로 의사 결정 프로세스의 설명 가능성과 투명성을 개선하는 데 도움이 됩니다.
4. 특정 산업 또는 도메인 요구사항에 맞게 조정: 산업 또는 도메인의 고유한 과제와 요구 사항을 해결하도록 맞춤형 LLM을 설계하여 모델이 특정 사용 사례에 최적화되도록 할 수 있습니다.
2. 단점
1. 높은 컴퓨팅 리소스와 비용: 자체 LLM을 교육하고 배포하는 것은 리소스 집약적일 수 있으며, 상당한 컴퓨팅 파워와 재정적 투자가 필요합니다. [3](https://www.analyticsinsight.net/pros-and-cons-of-customising-large-language-models/)
2. 시간이 오래 걸리는 교육 과정: 데이터 수집, 정리, 전처리뿐만 아니라 특정 요구사항에 맞게 모델을 미세 조정해야 하므로 맞춤형 LLM을 개발하는 데 오랜 시간이 소요될 수 있습니다.
3. 방대한 양의 데이터 관리 LLM을 학습하려면 대량의 데이터를 처리해야 하며, 이는 저장, 처리 및 개인 정보 보호 문제 측면에서 어려울 수 있습니다.
4. 모델 편향성 및 독성 문제를 해결하는 데 있어 잠재적인 어려움: 맞춤형 LLM에 편향성 및 독성 콘텐츠가 없는지 확인하는 것은 복잡하고 지속적인 프로세스가 될 수 있으므로 지속적인 모니터링과 평가가 필요합니다.**[6](https://towardsdatascience.com/overcoming-the-limitations-of-large-language-models-9d4e92ad9823)**
3. LLM을 교육, 확장 및 배포하는 데 있어 어떤 어려움이 있나요?
1. 컴퓨팅 리소스, 비용 및 인프라: LLM(대규모 언어 모델)을 학습하고 실행하는 것은 리소스 집약적이고 비용이 많이 들며, 특히 강력한 GPU 인프라가 필요합니다. 이는 초기 학습 단계부터 모델을 배포하는 추론 단계까지 확장됩니다. 이러한 리소스 관리의 복잡성은 불안정성으로 이어져 성능, 지연 시간, 심지어 비즈니스 모델에까지 영향을 미칠 수 있습니다.
- 비용 관리를 위한 엔지니어링
- 패널리스트들은 비용을 관리하기 위해 간단한 분류기와 같은 기본적인 엔지니어링 기법을 사용하여 대규모 언어 모델을 호출하는 것이 합당한지 여부를 결정할 수 있다고 제안합니다. 이들은 첫 번째 단계로 특정 모델을 사용할 수 있는지 평가한 다음 수용 가능한 결과를 제공하는 가장 낮은 수준으로 모델을 축소해야 한다고 강조합니다.
- **[Cost Optimization and Performance // LLMs in Production Conference Panel Discussion 2](https://youtu.be/wxq1ZeAM9fc)**
- Details
1. 훈련 비용: 대규모 언어 모델을 처음부터 학습하는 데 드는 비용으로, 여기에는 고급 하드웨어에서 여러 차례 반복하여 대규모 데이터 세트에 대한 계산을 실행하는 것이 포함됩니다. 여기에는 전기료와 잠재적인 데이터 저장 비용도 포함됩니다.
- 확장 비용: 모델이 더 커지고 복잡해지면 더 강력한 하드웨어, 더 많은 스토리지, 더 많은 에너지가 필요하므로 비용이 증가합니다. 더 많은 데이터나 정확도를 위해 모델을 확장하려면 추가 학습이 필요하므로 비용이 더 증가할 수 있습니다.
2. 배포 비용: 여기에는 학습된 모델을 효율적으로 실행하기 위해 최적화된 서버로 옮기는 데 드는 비용이 포함되며, 여기에는 특수 하드웨어가 필요할 수 있습니다. 지속적인 유지보수, 모니터링, 기존 시스템과의 통합 비용도 배포 비용에 영향을 미칩니다.
3. 추론/서비스 비용: 새로운 데이터에 대한 예측을 위해 모델을 사용하는 경우, 모델 실행을 위한 컴퓨팅 비용과 잠재적인 데이터 전송 비용이 발생합니다. 이러한 비용의 규모는 모델의 크기와 새로운 데이터의 양에 따라 달라집니다. 시간이 지남에 따라 사용 패턴에 따라 이러한 비용이 크게 누적될 수 있습니다.
2. 데이터 관리 및 개인정보 보호: LLM은 학습을 위해 방대한 양의 데이터를 필요로 하므로 저장, 처리, 특히 데이터 프라이버시와 관련된 문제가 발생합니다. LLM은 잠재적으로 학습 데이터에서 민감한 정보를 기억하고 유출할 수 있으므로 익명화 및 데이터 정화를 위한 엄격한 방법이 필요합니다.
3. 편향성, 독성 및 품질 관리: 인공 지능은 학습한 데이터를 통해 학습하기 때문에 내재된 편견이나 독성 콘텐츠를 흡수하고 전파할 위험이 있습니다. 또한 모호한 입력에 어려움을 겪고 문맥상 부적절하거나 부정확한 출력을 생성하거나 사실과 다르거나 허구의 텍스트를 '환각'할 수도 있습니다. 따라서 이러한 모델의 품질과 신뢰성을 보장하기 위해서는 지속적인 모니터링, 평가 및 조정이 필수적입니다.
4. 모델 적응 및 엔지니어링 엄격성: 특정 작업이나 도메인에 맞게 LLM을 조정하고 효과적인 프롬프트를 제작하는 것은 복잡하고 시간이 많이 소요되는 과정일 수 있습니다. 기존 및 향후 시스템과의 호환성을 보장하는 것도 중요한 엔지니어링 과제이므로 업데이트, 버전 관리 및 다른 구성 요소와의 통합을 위한 신중한 전략이 필요합니다.
5. 모델 설명 가능성 및 투명성: 복잡성으로 인해 LLM의 의사 결정 프로세스를 이해하는 것은 어려울 수 있습니다. 이러한 불투명성은 특히 의사 결정이 어떻게 이루어졌는지 명확하게 파악하는 것이 중요한 애플리케이션의 경우 문제가 될 수 있습니다.
6. 배포 전략: 프로덕션 환경에서 LLM을 배포하려면 하드웨어 기능, 지연 시간 요구 사항, 애플리케이션의 특정 요구 사항 간의 균형을 맞추는 신중한 전략이 필요합니다.

4. 참고자료:
1. [Unleashing LLMs in Production: Challenges & Opportunities. Chip Huyen, Amjad Masad & Michele Catasta](https://youtu.be/ByhMpN2iSbc)
2. [Real-time machine learning: challenges and solutions](https://huyenchip.com/2022/01/02/real-time-machine-learning-challenges-and-solutions.html)
3. [Building LLM applications for production](https://huyenchip.com/2023/04/11/llm-engineering.html)
4. [Efficiently Scaling and Deploying LLMs // Hanlin Tang // LLM's in Production Conference](https://youtu.be/AVccFl8-5-8)
5. **[Cost Optimization and Performance // LLMs in Production Conference Panel Discussion 2](https://youtu.be/wxq1ZeAM9fc)**
Chip이 일하기도 했던 Snorkel이 궁금해서 찾아보니 이런 회사군요 ㅎㅎ

Solving the Last Mile Problem of Foundation Models with Data-Centric AI
Everyone will soon be using foundation models (FMs) like GPT-4.

동영상에서 Snorkel AI의 CEO인 알렉스 래트너는 기초 모델의 ‘라스트 마일’ 문제를 해결하는 데 있어 데이터 중심 AI의 역할과 맞춤형 및 도메인별 모델 개발의 중요성에 대해 설명합니다. 그는 독점적인 도메인별 데이터로 학습된 기초 모델을 나타내는 ‘GPT-You’라는 개념을 AI 애플리케이션의 미래로 소개합니다.

그는 AI 개발의 본질적이고 가장 중요한 측면은 올바른 아키텍처를 선택하거나 모델 매개변수를 미세 조정하는 것이 아니라 데이터를 조작, 큐레이팅, 레이블 지정, 슬라이싱, 샘플링 및 개발하는 것이라고 강조합니다. 이러한 데이터 중심 접근 방식을 통해 전문화된 고성능 기반 모델을 만들 수 있습니다.

또한 라트너는 ‘라스트 마일’ 문제에 대한 해결책으로서 데이터 중심 AI의 개념에 대해 자세히 설명합니다. 데이터 중심 AI는 라벨링, 샘플링, 큐레이팅, 증강 등 데이터를 반복하여 특정 작업을 위한 전문화된 모델을 만드는 데 중점을 둡니다. 그는 저렴한 쿼리 세트를 사용하여 ChatGPT를 복제하는 데 성공한 Alpaca와 같은 프로젝트의 성공과 내구성 있는 모델을 만드는 데 있어 개인 데이터 배포의 중요성에 대해 강조합니다.

데이터 중심 AI의 적용에 대해 래트너는 데이터의 고유성과 모델의 정확도라는 두 가지 차원으로 나누어 설명합니다. AI를 가장 보람 있게 사용할 수 있는 경우는 데이터가 기초 모델에 학습된 것과 매우 유사하고 오류에 대한 허용 오차가 높은 경우입니다. 그러나 비표준 데이터와 높은 정확도가 요구되는 상황에서는 레이블이 지정된 데이터에 대한 상당한 양의 작업과 미세 조정이 필요합니다.

래트너는 데이터 중심 AI를 사용하여 기초 모델을 개발하기 위한 플랫폼인 스노클 플로우를 소개합니다. 워크플로우는 기본 기초 모델에서 시작하여 특정 작업을 정의하고 기초 모델을 데이터에 적용하여 안내식 오류 분석으로 이어집니다. 이 프로세스는 기본 모델의 오류를 식별하고, 프로그래밍 방식의 라벨링을 사용하여 오류를 수정하며, 미세 조정을 위해 수정 및 증강된 라벨링 데이터로 기본 모델을 업데이트하거나 더 작은 규모의 작업별 모델로 추출합니다.

결론적으로 라트너는 데이터 중심 AI의 중요성과 이것이 기초 모델의 개발 및 미세 조정에 가져다주는 가치를 강조합니다. 그는 이러한 원칙에 대한 더 많은 탐구와 적용을 장려하며, 데이터 중심 AI와 기초 모델의 미래에 초점을 맞춘 향후 컨퍼런스에 청중을 초대합니다.
Our AI and ML Predictions for 2023: AI Arize
With prediction season coming to a close, here are a few hot takes on some prevailing trends and a few educated guesses on the year ahead.

1. Prompt Engineering Will Grow Into a Field: Prompt engineering doesn’t feel much like data science, but prompting is a growing area of significant importance with large language models (LLMs). In a way, finding the right prompt to get the right response turns a data science fine tuning problem into a fast and iterative prompt testing problem. There are already entire products such as Github Copilot that are built on top of prompt engineering with OpenAI, combining a well-executed product integration with GitHub and a data silo advantage. LLMs such as OpenAI will likely release pre-set prompts to help you ask the right questions. Word of caution: products built on prompts alone are not defensible.

2. A Multi-Modal LLM Will Go Mainstream: An LLM that supports both image or video and language together will be released this year to a lot of fanfare, possibly even eclipsing the fanfare around ChatGPT. The power of having both modalities in a single model is underappreciated right now and will be as groundbreaking in new use cases as ChatGPT is to conversation assistants.

3. Multiple Successful Vertical AI Assistants Will Emerge: We are seeing vertically-focused LLMs with the right prompt construction, software interface, and the right data creating focused value. The best execution to date has been GitHub Copilot. There will likely be multiple vertical AI assistants in fields like the law, medicine and biotech. These will be accomplished by connecting an LLM to unique vertical-specific datasets, fine tuning and aligning in specific verticals, prompt engineering for that vertical, and offering a user interface with workflows for that vertical. I believe these can be defensible if done right.

4. ChatGPT Will Not Threaten Google; It’s an Entirely New Large Market: It is very normal to see something new and try to think of it as a product replacement for what you already know. This is often the wrong way to look at it. I view ChatGPT as a whole new type of technology that enables a wide swath of products that have nothing to do with search. I think the network effects of search will be near impossible to dislodge in the near team, and the value replacement is just not there yet. That said, large new markets are enabled by the progress in LLMs. It’s also likely that a sizable portion of traffic distribution will occur through product integrations like CoPilot versus traffic arriving to and typing in a single home page.

5. Embedding Use for Interpretability and Content Control for Models/LLMs will Accelerate: The use of embeddings analysis for AI interpretability will grow as a field. Toolsets will launch that use these embeddings to monitor and control AI. We have already seen incredible pickup of our embedding drift solutions across a wide swath of industries. We’ve also seen embeddings used for content protection in Dall-E and other generative models. Embeddings represent the latent structure models have learned and they are the backbone of every modern deep learning model.
MLSys 2023 학회에 참여하고 있습니다. 눈에 보이는 논문 몇편 소개해드릴까 합니다.
https://arxiv.org/abs/2305.02538 / Cuttlefish: Low-Rank Model Training without All the Tuning
개인적으로는 별로 좋아하는 연구는 아닙니다만, Low-Rank 모델 Training에 관심이 많으신 것 같습니다. Low-rank traning과 자동화를 좀 섞은것 같고, LLM은 모르겠지만, BERT정도까지는 좋은결과를 가지고 있습니다.
https://arxiv.org/abs/2211.05102 / Efficiently Scaling Transformer Inference
구글의 유명한 논문입니다. Outstanding Paper 상을 받았구요. PaLM의 서빙 시스템을 다루고 있는 논문입니다. TPU 최적화된 내용이라서, GPU향에서는 약간 다를수 있다는 함정이지만, 배울 수 있는 내용이 많습니다. 최근 구글에서 Grouped-Query Attention이 나왔는데, 얘는 기본적으로 Multi-query attention (MQA)를 사용하고 있고, Feed forward 를 위한 파티셔닝 전략을 설명하고 있습니다.
LLM Serving에 있어서 제일 중요하다고 생각하는 것중 하나가 Latency향 최적화, throughput 최적화 의 차이를 이해하는 것이라고 생각합니다. 그 부분에 대해서 많이 배우실수 있습니다.
https://proceedings.mlsys.org/paper_files/paper/2023/file/4552cedd396a308320209f75f56a5ad5-Paper-mlsys2023.pdf / Efficient GPU Kernels for N:M-Sparse Weights in Deep Learning
요즘 N:M sparsity가 정말 가속이 잘 되는지 궁금한데.. 저도 공부해볼까 싶어서 붙여넣었습니다.
https://proceedings.mlsys.org/paper_files/paper/2023/file/de4086ad4276d895be8ef25ec03c964b-Paper-mlsys2023.pdf / Unified Convolution Framework: A compiler-based approach to support sparse convolutions
한국인 MIT 학생의 발표인데, Compiler 궁금하신 분들 보시죠 ㅎㅎ

네이버 권세중님
What is great friendship? How could we cultivate this?

Reid Hoffman

1. 친구들은 내가 볼 수 없는 것을 볼 수 있도록 도와줄 수 있습니다.
2. 내가 친구들을 돕고 친구들이 나를 도와주면 우리는 더 잘하고 더 멀리 갈 수 있습니다.
3. 나에게는 수백 명의 친구, 멘토가 있습니다.
4. 친구들은 당신이 그들을 돕도록 허락합니다. 친구들은 대화를 통해 저를 전적으로 신뢰하고 믿어주어 저를 가치 있는 사람으로 만들어주었습니다.
5. 우정을 최우선 순위로 삼는다.
6. 의식적으로 좋은 우정을 만든다. 의식을 만든다. 우정이 무엇이며 어떻게 개선할 수 있는지 이야기하세요.
7. 당신이 원하는 것과 당신의 꿈을 친구들에게 공유하세요.
8. 친구들은 당신이 원하는 것이 아니라 내가 해야 할 일을 말해줍니다.
9. 인생은 가장 충만한 팀 스포츠입니다.

---

Charlie Munger and Warren Buffet

독이 되는 사람을 피하세요: 버핏과 멍거는 모두 삶에 부정적인 영향을 미칠 수 있는 독성이 있는 사람들과 멀리 떨어져 지내는 것이 중요하다고 강조합니다. 그러나 버핏은 사람을 비방하고 다리를 불태우는 것은 친구가 전혀 없을 수도 있다고 경고합니다.

공유된 가치와 신뢰: 버핏과 멍거의 오랜 우정은 공유된 가치, 신뢰, 상호 존중을 기반으로 합니다.

서로에게서 배우기: 버핏은 멍거의 지성, 유머 감각, 명쾌한 사고력 등 그가 중요하게 여기는 자질에 대해 자주 언급해 왔습니다. 또한 멍거는 버핏의 투자 능력과 지혜에 대해 존경심을 표하기도 했습니다.

---

Naval Ravikant

장기적인 우정을 소중히 여깁니다: Naval은 상호 존중과 공유된 가치에 기반한 장기적인 우정과 동료 관계의 중요성을 강조합니다.

정직: Naval에 따르면 정직은 우정과 관계의 기본 가치입니다. 친구에게 정직하고 투명하게 행동하면 신뢰를 쌓고 유대감을 강화하는 데 도움이 됩니다.

관심사 공유: Naval은 친구와 관심사와 열정을 공유하면 우정이 더욱 풍성하고 즐거워질 수 있다고 믿습니다.

독립성: Naval은 트윗에서 친구나 또래 집단의 신념에 따르지 않고 독립적인 사고를 하는 것의 중요성에 대해 언급했습니다.

양보다 질: Naval은 피상적인 우정을 많이 쌓기보다는 소수의 친한 친구와 깊고 의미 있는 관계를 형성하는 데 집중할 것을 제안합니다. .
LLM을 RAG 방식으로 써보시는 시도를 많이 하실텐데요 .
관련하여 스탠포드에서 LLM에 넣는 input들의 상대적 위치와 관련해 다양한 실험을 한 흥미로운 논문이 있어 정리해봤습니다.
당연히 서비스 상황마다, 이용하는 LLM마다 상황이 다르지만
실험 범위를 좁힐 수 있는 좋은 가이드가 되겠네요
(혹시 이런 RAG 실전에 도움되는 다른 논문을 알고 계시다면 공유해주시면 감사하곘습니다! ㅎㅎ )
<짧은 (제 맘대로) 결론>

RAG 접근에서는 ranked list truncation 전략, 즉 순위가 높은 document를 앞에 넣어주고 일정 수준 이하 document는 넣어주지 않는 전략을 쓰자
만약 위 1의 접근이 쉽지 않은 경우, 즉 중요한 부분을 골라내기 어려운 경우는 GPT-3.5말고 Claude를 검토해 볼법하다.
그 이유는 단순히 max context length가 길어서라기 보다는,
중요 정보 위치에 따른 결과 편차가 GPT에 비해 적어서

decoder-only 모델을 쓰는 경우(예: gpt-3.5-turbo)에는 Query-aware contextualization 방법, 즉 프롬프트에 documents 전후에 query 텍스트를 중복해서 넣어주는 방법을 시도해보자
-------------
<논문 내용 정리>

중요한 정보가 앞 또는 뒤쪽에 있을 때 성능이 높아진다.
• [첫번째 그림] 정답을 포함한 passage의 상대적 위치를 바꿔가면서 실험했더니 앞 또는 뒤쪽에 있을때와 중간에 있을 때 (실험 상) 정확도가 많이 차이남
• 심지어 GPT-3.5의 경우는, 중요 정보가 중간에 있는 경우에, 아무런 context를 주지 않고 실행한 경우보다 더 낮은 수치가 나오기도…ㄷㄷ
• 이러한 U-shape 결과는 instcruct 넣어주든 안넣어주든 유사하게 나타나며, encoder-decoder 모델보다 decoder-only 모델에서 더 심하게 나타남.
(근데 경향성이 저렇다는거지 결국 중요한건 모델 바이 모델입니다.
예를 들어 claude의 길이에 따른 성능 편차는 gpt-3.5에 비해 훨씬 적습니다.)
• [두번째 그림] 이 현상은 supervised instruction-tuning을 한 모델뿐만 아니라 하지 않은 모델에도 유사한 현상이 나타남.
즉 instruction-tuning할 때 instruct가 앞쪽에 위치해서 이런 현상이 나타나는건 아닌것으로 보임

decoder-only 모델에서 Query-aware contextualization 방법이 효과 있다.
• Query-aware contextualization 란 프롬프트에서 Query 텍스트를 documents 전후로 넣어주는 방법
• 즉 1번 결과에서 보듯 정보의 위치가 퍼포먼스에 영향을 많이 끼치는 decoder-only 모델의 경우에는 query 위치도 중요하단 얘기임
• multi-document QA에서는 상대적으로 이 기법의 효과는 적었지만, 이 때도 중요 document의 상대적 위치에 따라 영향 정도가 달라짐
(중요 document가 앞쪽에 위치하는 경우는 multi-document QA에서도 이 방법이 유효했음)

Context를 많이 넣어줄수록 항상 좋은가? -> 당연히 아니다
• 일정 수준의 context가 이미 있는 상황에서는 관련 있는 내용이라도 더 넣어봤자 성능 향상이 미미
• [세번째 그림] 관련 없는걸 넣으면 당연하게도 떨어지는 경향을 보임
• 또한 Extended-context 모델과 원 모델 비교헀을 때 동일 인풋에 대해서는 성능 차이 거의 없다
(여기서는 GPT-3.5-Turbo and GPT-3.5-Turbo (16K) 를 비교했습니다.
16k 가격이 두배고, 많이 넣어봤자 도움이 안되니 최대한 8k 모델에 맞춰서 이용하는게 이득)
참고: 실험환경
Task: multi-document QA, key-value retrieval
Model: OpenAI’s GPT-3.5-Turbo, Anthropic’s Claud, MPT-30B-Instruct, LongChat-13B(16K)
https://www.linkedin.com/posts/philipp-schmid-a6a2bb196_are-vector-databases-here-to-stay-yes-activity-7085908435686285312-QVfB/?utm_source=share&utm_medium=member_android
<의사결정의 순서>
전문가와 비전문가의 차이가 크게 도드라지는 부분 중 하나는 일의 순서이다. 특히 인지적 과업일 경우 의사결정의 순서가 전문가와 비전문가를 가른다. 어떤 순서로 의사결정을 하면 일을 하기가 훨씬 수월한데, 그렇지 않으면 일하면서 헤매게 되고 어려움을 겪게 된다.
해야할 의사결정들이 많을 때 자신에게 물어야할 질문은 이렇다. "어느 의사결정을 먼저 하면 다른 의사결정들을 내리기가 훨씬 수월해질까?"
이것이 바로 건축학자 크리스토퍼 알렉산더가 말하는 시퀀스(sequence)라는 개념이다.
건축학자인 크리스토퍼 알렉산더에 따르면 작은 집 하나를 짓는데에만 해야할 의사결정이 수백개에 달한다고 한다. 그러면 가능한 의사결정의 순서는 천문학적으로 늘어나게 된다. 하지만 가장 핵심적인(center) 의사결정부터 하나씩 진행하게 되면 점점 일이 정돈되고 수월하게 풀리게 된다. 했던 걸 다시 되돌려야 할 확률도 확 줄어든다.
예를 들어, 그는 부엌을 만들 때에 가장 우선적으로 할 의사결정 중 하나로 식탁의 위치 정하기를 꼽는다. 왜냐하면 결국 (서양식) 부엌의 가장 핵심이 되는 활동은 가족이 함께 식사를 하는 것이기 때문이다. 이게 정해지면 다른 모든 것들은 부차적인 의사결정이 되어 굉장히 쉽게 풀려버린다. 근데, 이걸 정하지 않은 상태에서 냉장고를 어디에 둘지 정하는 것은 기준이 명확하지 않아 어려움이 많을 것이다.
건축뿐만이 아니다. 인지적 작업을 하는 경우 모두가 해당한다. 내가 의사결정을 내려야 하는데 감도 잘 안오고 모호하다면 순서가 잘못된 거 아닌가 생각해 보는 것이 도움이 될 것이다.
2. <생성적 순서>

다음은 건축가 Christopher Alexander의 역작 Nature of Order 2권(p. 317)에 나오는 일화를 내가 번역하고(급하게 하느라 좀 거칠다) 편집한 것이다. 여기에 애자일의 오의奧義가 숨어 있다. 사실 이런 게 회고니 스크럼 미팅이니 하는 것보다 오백배 더 중요하다.

- ---

건축은 복잡하기 때문에 디자이너는 모든 걸 한번에 해야한다는 이야기가 퍼져있다. "복잡한 전체가, 부분으로 나뉘지 않는 하나로 존재하는데 어떻게 한 번에 하나씩 처리하면서 설계를 성공적으로 할 수 있겠어요?" 같은 질문을 보면 알 수 있다.

건축을 공부하는 학생 하나를 가르치려고 내가 여러달 노력을 했다. 그는 뛰어난 학생이었지만 설계에 대해 취약했다. 그러다가 그 친구가 집 하나를 설계해야 하는 디자인 수업에 같이 참여하게 되었다. 그 학생은 제대로 설계를 하려고 아무리 노력해도 잘 되지 않았다. 그의 드로잉 보드 위에는 난잡한 흔적이 가득했다.

누군가 설계를 제대로 못할 때에는 통상 잘못된 순서로 접근을 하기 때문이다. 모든 가능한 이슈들 사이를 오가면서 계속 혼돈 속에 빠지기 때문이다.

그러다가 어느날 그 학생이랑 같이 앉아서 대화를 하게 됐다.

"오늘 당신의 설계를 저랑 대화하면서 풀어보면 어떨까요. 일단 이미 갖고 있는 건 잊으세요. 전체 설계를 다 지워버리고요. 아무것도 없는 거로 시작합시다."

"그 현장(site)에서 가장 중요한 건 뭐고, 또 그 현장과 관련해 당신의 설계가 해야할 가장 중요한 것은 무엇인가요? 나머지는 걱정하지 마세요. 이 질문 하나에 대해서만 얘기해주세요."

"좋아요. 그럼 표시를 해보죠. 그거 하나만 딱 넣어봐요. 나머지는 모두 잊어먹고요."

"좋아요. 이제 다음으로 가장 중요한 게 뭔지 말해주세요."

이렇게 한시간 가량 지속했다. 학생이 뭔가가 중요하다고 했지만 내가 느끼기에 그 학생이 실제로 그걸 중요하게 느낀 건지 의심이 가면, 나는 그 학생을 쳐다보면서 아뇨, 다음으로 진짜로 가장 중요한 게 뭔가요? 라고 묻기도 했다.

그렇게 한시간이 끝나갈 때 쯤에는 그는 아름다운 건물을 완성할 수 있었다.

그 학생이 나에게 와서 이렇게 말했다. "이게 이렇게 간단하리라고는 생각도 못했어요. 전에는 한번도 이걸 이해한 적이 없었어요. 근데 이제 마침내 이해를 했어요. 선생님이 이제껏 얘기해 온 게 무슨 말인지요. 선생님은 그냥 한번에 딱 하나씩만 갖고 하시고 또 그걸 바른 순서로 하시는 거에요. 그게 전부죠. 단지 가장 중요한 걸 하라는 거. 그리고 그걸 끝내라는 거."

이게 작동하는 이유는 자연의 모든 시스템과 같이, 실제로 펼쳐지는 과정이 그 자제로 "전체"(whole)라는 것 때문이다. 인간의 모든 펼쳐지는 과정의 핵심은, 예술가 혹은 건축가가 바로 첫날부터 자기가 만드는 걸 전체로, 온전한 하나의 것으로 시각화할 수 있어야 한다는 거다. 심지어 당신이 시작하기도 전에, 그걸 선택하고 그게 바로 전체인 거처럼 봐야 한다. 그걸 전체로서 느끼고 그 전체성 속에서 그 부분을 상상해야 하며... 점진적으로 거기에서 이 전체성의 특성들을 끌어내야 한다.

김창준 님
#스타트업 아이디어: LLM을 위한 QA 플랫폼

LLM을 활용한 서비스가 많아지면, LLM의 Hallucination을 잡는 게 중요하고 이를 위해서 여러 Iteration을 돌면서 엔지니어링을 해야하는데요.

예를들어, 챗봇 애플리케이션을 쇼핑몰에 도입하려고 한다면 이커머스 환경에서 챗봇의 유용성은 제품 클릭 수와 같은 지표에 연결되어야 하며, 이 지표를 기반으로 피드백 및 모델 조정이 이루어져야해요. 그런데 이런 걸 하기엔 되게 어려운 점들이 많죠. 그리고 이 챗봇 애플리케이션의 성능을 높이기 위해서는 여러가지 요소(데이터 품질, 학습 방식, 디버깅 방식, 프롬프트 등을 개선해야하는데요. 이걸 자체적으로 하기엔 좀 빡세보이네요 ㅎㅎ

https://snorkel.ai/도 이런 비즈니스 해보고 싶어하는 것 같고요.

https://dust.tt/는 ML 엔지니어가 아닌 쉬운 GUI로 봇을 만드는데에 집중하는 팀인 것 같고요 ㅎㅎ
### What is Flash Attention?

FlashAttention is an algorithm designed to improve the performance, cost, and latency of attention mechanisms in transformer models, particularly in large language models (LLMs) and other transformer-based architectures**[1](https://www.quora.com/How-does-flash-attention-work)**. It can replace standard attention mechanisms in various applications, offering significant benefits in terms of speed, memory efficiency, and training costs**[1](https://www.quora.com/How-does-flash-attention-work)**. It has been widely adopted in large language model (LLM) libraries due to its significant speedup and memory efficiency**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)[11](https://github.com/Dao-AILab/flash-attention)**.

### Model Performance

FlashAttention-2, the latest version, is 2x faster than its predecessor, FlashAttention, and 5-9x faster than standard attention implementations**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)**. This speedup allows for training models with twice as long context for the same training cost as before**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)**. When used end-to-end to train GPT-style language models, FlashAttention-2 reaches a training speed of up to 225 TFLOPs/s**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)[5](https://twitter.com/_akhaliq/status/1680988185776607237)**.

### Cost and Latency

FlashAttention-2 addresses the inefficiencies of its predecessor by reformulating the algorithm to reduce non-matmul FLOPs, improve parallelism, and optimize work partitioning between thread blocks and warps on GPUs**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)**. Non-matmul FLOPs are more expensive than matmul FLOPs, so these improvements lead to significant speedup and reduced latency**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)**.The algorithm also minimizes communication and synchronization between warps, further improving performance**[1](https://crfm.stanford.edu/2023/07/17/flash2.html)**. FlashAttention-2 is more memory-efficient than exact attention baselines, with memory usage linear in sequence length rather than quadratic**[3](https://arxiv.org/pdf/2205.14135.pdf)[16](https://www.adept.ai/blog/flashier-attention)**. This allows it to scale to much longer sequence lengths, enabling the training of higher-quality models**[2](https://arxiv.org/abs/2205.14135)**.

### What is better?

Incumbents, or standard attention mechanisms, have quadratic memory usage and slower training times due to their computation and memory access patterns**[4](https://crfm.stanford.edu/2023/01/13/flashattention.html)**. FlashAttention, on the other hand, offers the following advantages:

1. Faster training times: FlashAttention-2, the latest version, is 2x faster than its predecessor, FlashAttention, and 5-9x faster than standard attention implementations**[1](https://www.quora.com/How-does-flash-attention-work)**. This speedup allows for faster training times and longer context lengths for the same training cost as before**[1](https://www.quora.com/How-does-flash-attention-work)**.
2. Longer context lengths(Memory efficiency): FlashAttention reduces memory usage from quadratic to linear in sequence length by leveraging tiling and recomputation techniques**[4](https://crfm.stanford.edu/2023/01/13/flashattention.html)**. This allows it to scale to much longer sequence lengths, enabling the training of higher-quality models**[2](https://github.com/HazyResearch/flash-attention)**.
3. Reduced training costs: The improvements in training speed and memory efficiency can result in reduced training costs**[1](https://www.quora.com/How-does-flash-attention-work)**.

### How is it possible?

The improvements in FlashAttention-2 were made by:
1. Tweaking the algorithm to reduce the number of non-matmul FLOPs**[1](https://github.com/HazyResearch/flash-attention)**.
2. Parallelizing the attention computation, even for a single head, across different thread blocks to increase occupancy**[1](https://github.com/HazyResearch/flash-attention)**.
3. Distributing the work between warps within each thread block to reduce communication through shared memory**[1](https://github.com/HazyResearch/flash-attention)**.

It achieves this by exploiting the asymmetric GPU memory hierarchy, bringing significant memory savings (linear instead of quadratic) and runtime speedup**[4](https://arxiv.org/abs/2205.14135)**. Additionally, FlashAttention-2 minimizes communication and synchronization between warps, further improving performance**[1](https://github.com/HazyResearch/flash-attention)**.

### Implication for industry players
1. Chipmakers: FlashAttention reduces the computational and memory requirements for attention mechanisms in transformer models, driving the demand for more efficient and specialized hardware to further optimize the performance of these models**[11](https://www.ft.com/content/8352e84b-284c-4ebe-a7c1-5e2093566e0d)**. This could lead to innovations in GPU architectures and the development of specialized AI accelerators.

This could lead to innovations in GPU architectures and the development of specialized AI accelerators that are better suited for handling the reduced computational and memory requirements of attention mechanisms in transformer models.Some components that could be affected include:

1. Memory hierarchy: FlashAttention exploits the asymmetric GPU memory hierarchy, which could lead to the development of new memory architectures that further optimize memory access patterns for attention mechanisms**[4](https://openreview.net/forum?id=H4DqfPSibmx)**.
2. Parallelism: FlashAttention improves parallelism in attention computation, which could influence the design of GPU architectures and AI accelerators to better support parallel processing for transformer models**[1](https://arxiv.org/pdf/2205.14135.pdf)**.
3. Communication and synchronization: FlashAttention reduces communication and synchronization between warps, which could impact the design of interconnects and synchronization mechanisms in GPU and AI accelerator architectures**[1](https://arxiv.org/pdf/2205.14135.pdf)**.
2. LLM makers: FlashAttention can help improve the efficiency of large language models (LLMs) by speeding up training times, allowing for longer context lengths, and reducing training costs**[1](https://arxiv.org/abs/2205.14135)**. This can lead to the development of more powerful LLMs and the creation of new AI services based on these models.
- By speeding up the attention mechanism and reducing memory requirements, FlashAttention allows for longer context lengths during training, which can lead to better model performance**[1](https://ahmdtaha.medium.com/flashattention-fast-and-memory-efficient-exact-attention-with-io-awareness-2a0aec52ed3d)**. This efficiency enables LLM makers to train more powerful models without sacrificing quality, as FlashAttention computes exact attention without any approximation**[3](https://arxiv.org/pdf/2205.14135.pdf)**.
- FlashAttention can also help reduce the cost for training, scaling, deploying, or fine-tuning LLMs by offering faster training times, longer context lengths, and reduced training costs**[1](https://ahmdtaha.medium.com/flashattention-fast-and-memory-efficient-exact-attention-with-io-awareness-2a0aec52ed3d)**. This is achieved through its improved memory efficiency, which allows it to scale to much longer sequence lengths, and its faster training times compared to standard attention mechanisms**[1](https://ahmdtaha.medium.com/flashattention-fast-and-memory-efficient-exact-attention-with-io-awareness-2a0aec52ed3d)**.
- FlashAttention could affect the open-source ecosystem by providing an efficient alternative to standard attention mechanisms. Its open-source implementation**[11](https://aws.amazon.com/blogs/machine-learning/new-performance-improvements-in-amazon-sagemaker-model-parallel-library/)** can be integrated into various open-source libraries and frameworks, leading to wider adoption and further development of the algorithm. This can drive innovation and efficiency across various industries and players, leading to the development of more powerful AI models and services.
3. Infrastructure builders for LLMs (e.g., Mosaic ML): By integrating FlashAttention into their infrastructure offerings, these companies can enable more efficient and cost-effective training and deployment of LLMs**[15](https://www.mosaicml.com/blog/mpt-7b)**. This can lead to wider adoption of AI technologies and more advanced AI services.
4. LLM-using services (e.g., Perplexity): Services that rely on LLMs, such as natural language processing, machine translation, text summarization, and sentiment analysis, can benefit from the improved performance and efficiency provided by FlashAttention**[6](https://www.wsj.com/articles/memory-chip-makers-struggle-with-decline-in-demand-and-price-falls-11665141235)**. Faster training times and longer context lengths can lead to better performance in these tasks, enabling the development of more advanced AI services.
LLM(Large Language Model) 학습 및 서비스 운영에 관심이 많은 AI 엔지니어 분들을 초대합니다.
LLM 모델을 실제로 학습시키고 서비스를 제공하기 위해서는 많은 어려움들이 존재합니다. 실제로 LLM 학습시켜 서비스를 만들어본 경험들을 나눠봐요 🙂

세션 참가 신청하기: https://lu.ma/agitownjuly2

해당 세션에서는 아래 내용에 대해서 다룰 예정입니다.

1️⃣ 자체 LLM 학습의 장단점: LLM 직접 학습시켜야할까요 아니면 Third Party 솔루션을 써야할까요? 직접 학습하게 되면 특정 요구사항에 맞게 모델을 수정하고, 모델 디버깅이 편하지만, 높은 학습비용과 고품질의 데이터 가공 등 신경써야할 부분이 많습니다.

2️⃣ Quality, Cost, Latency 간의 트레이드오프: 비용 집약적인 GPU 추론부터 비용 관리를 위한 엔지니어링의 기본에 이르기까지 성능, 비용, 시간 간의 균형을 맞추는 방법을 살펴봅니다.

3️⃣ 신뢰, 안정성 및 개인 정보 보호: LLM에서 흔히 발생하는 'Hallucination'의 함정, 좋은 데이터를 얻기 위한 기술, 개인 정보를 보호하면서 높은 데이터 품질을 유지하는 방법에 대해 알아보세요. 또한 모델 편향성, 독성, 품질 관리의 복잡성과 모델 설명 가능성 및 투명성 문제에 대해서도 논의할 예정입니다.

4️⃣ Latency: 지연 시간이 문제가 되는 이유는 무엇이며 어떻게 해결할 수 있을까요? Transformer 아키텍처의 한계와 the potential of models like sequential state space models, Flash Attention Model의 잠재력에 대해 알아보세요.

5️⃣ 모델 학습 방법 및 엔지니어링: GPT-4에서 전문가 혼합 모델(MoE)을 성공적으로 구현한 사례, 다중 쿼리 주의(MQA)의 잠재력, 그리고 모델의 미래에 대한 예측에 대해 알아보세요.

해당 세션 관련 읽을거리

1. [Unleashing LLMs in Production: Challenges & Opportunities. Chip Huyen, Amjad Masad & Michele Catasta](https://youtu.be/ByhMpN2iSbc)
2. [Real-time machine learning: challenges and solutions](https://huyenchip.com/.../real-time-machine-learning...)
3. [Building LLM applications for production](https://huyenchip.com/2023/04/11/llm-engineering.html)
4. [Efficiently Scaling and Deploying LLMs // Hanlin Tang // LLM's in Production Conference](https://youtu.be/AVccFl8-5-8)
5. [Cost Optimization and Performance // LLMs in Production Conference Panel Discussion 2](https://youtu.be/wxq1ZeAM9fc)
6. [Solving the Last Mile Problem of Foundation Models with Data-Centric AI](https://youtu.be/-oDgV6q6KtI...)
1. [Everyone will soon be using foundation models (FMs) like GPT-4.](https://threadreaderapp.com/thread/1642666624091312129.html)
7. [Debugging LLMs: Best Practices for Better Prompts and Data Quality](https://youtu.be/OsP1PAKyHq0)
Like this newsletter, unsexy business. Wait what? I believe earning money and being profitable is sexy.

https://maily.so/unsexybusinesskr