MakiAi commited on
Commit
0b24ea8
·
2 Parent(s): 85dd626 89556f9

Merge docs/update-readme

Browse files
README.md CHANGED
@@ -64,18 +64,20 @@ license: mit
64
  - メモリ使用量の最適化
65
  - 実験結果の可視化
66
 
67
-
68
  ## 📚 実装例
69
 
70
  本リポジトリには以下の実装例が含まれています:
71
 
72
- 1. **Unslothを使用した高速ファインチューニング**
73
- - Llama-3.2-1B/3Bモデルの高速ファインチューニング実装
74
- - → 詳細は [`Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md`](sandbox/Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md) をご参照ください。
75
- - → [マークダウン形式からノートブック形式への変換はこちらを使用してください](https://huggingface.co/spaces/MakiAi/JupytextWebUI)
76
- - [📒ノートブックはこちら](https://colab.research.google.com/drive/1AjtWF2vOEwzIoCMmlQfSTYCVgy4Y78Wi?usp=sharing)
77
 
78
- 2. その他の実装例は随時追加予定
 
 
 
79
 
80
  ## 🛠️ 環境構築
81
 
 
64
  - メモリ使用量の最適化
65
  - 実験結果の可視化
66
 
 
67
  ## 📚 実装例
68
 
69
  本リポジトリには以下の実装例が含まれています:
70
 
71
+ ### Unslothを使用した高速ファインチューニング
72
+ - Llama-3.2-1B/3Bモデルの高速ファインチューニング実装
73
+ - → 詳細は [`Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md`](sandbox/Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md) をご参照ください。
74
+ - → [マークダウン形式からノートブック形式への変換はこちらを使用してください](https://huggingface.co/spaces/MakiAi/JupytextWebUI)
75
+ - [📒ノートブックはこちら](https://colab.research.google.com/drive/1AjtWF2vOEwzIoCMmlQfSTYCVgy4Y78Wi?usp=sharing)
76
 
77
+ ### OllamaとLiteLLMを使用した効率的なモデル運用
78
+ - Google Colabでのセットアップと運用ガイド
79
+ - → 詳細は [`efficient-ollama-colab-setup-with-litellm-guide.md`](sandbox/efficient-ollama-colab-setup-with-litellm-guide.md) をご参照ください。
80
+ - [📒ノートブックはこちら](https://colab.research.google.com/drive/1buTPds1Go1NbZOLlpG94VG22GyK-F4GW?usp=sharing)
81
 
82
  ## 🛠️ 環境構築
83
 
docs/README.en.md CHANGED
@@ -31,7 +31,7 @@ license: mit
31
  </p>
32
 
33
  <h2 align="center">
34
- Llama Model Fine-tuning Experiment Environment
35
  </h2>
36
 
37
  <p align="center">
@@ -44,41 +44,67 @@ license: mit
44
 
45
  ## 🚀 Project Overview
46
 
47
- **Llama-finetune-sandbox** provides an experimental environment for learning and verifying Llama model fine-tuning. You can try various fine-tuning methods, customize models, and evaluate performance. It caters to a wide range of users, from beginners to researchers. Version 0.1.0 includes a repository name change, a significantly updated README, and the addition of a Llama model fine-tuning tutorial.
48
 
49
  ## ✨ Key Features
50
 
51
- 1. **Diverse Fine-tuning Methods:**
52
  - LoRA (Low-Rank Adaptation)
53
  - QLoRA (Quantized LoRA)
54
- - Full Fine-tuning
55
- - Parameter-Efficient Fine-tuning (PEFT)
56
 
57
- 2. **Flexible Model Configuration:**
58
  - Customizable maximum sequence length
59
  - Various quantization options
60
  - Multiple attention mechanisms
61
 
62
- 3. **Experiment Environment Setup:**
63
  - Performance evaluation tools
64
  - Memory usage optimization
65
  - Visualization of experimental results
66
 
67
- ## 🔧 How to Use
68
 
69
- This repository includes a tutorial on high-speed fine-tuning using the Unsloth library (`sandbox/Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md`). This tutorial explains the fine-tuning process step-by-step with numerous code examples. The tutorial is written in Japanese. [Use this to convert from Markdown to Notebook format](https://huggingface.co/spaces/MakiAi/JupytextWebUI). A [Google Colab notebook](https://colab.research.google.com/drive/1AjtWF2vOEwzIoCMmlQfSTYCVgy4Y78Wi?usp=sharing) is also available.
70
 
 
71
 
72
- ## 📦 Installation Instructions
 
 
 
 
73
 
74
- Information not available.
75
 
 
76
 
77
- ## 🆕 Latest News
 
 
 
 
78
 
79
- - 🎉 Added Llama model fine-tuning tutorial.
80
 
 
 
 
 
81
 
82
- ## 📄 License
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  This project is licensed under the MIT License.
 
31
  </p>
32
 
33
  <h2 align="center">
34
+ Llama Model Fine-tuning Experiment Environment
35
  </h2>
36
 
37
  <p align="center">
 
44
 
45
  ## 🚀 Project Overview
46
 
47
+ **Llama-finetune-sandbox** is an experimental environment for learning and verifying Llama model fine-tuning. You can try various fine-tuning methods, customize models, and evaluate performance. It caters to a wide range of users, from beginners to researchers. Version 0.1.0 includes a repository name change, significantly updated README, and added a Llama model fine-tuning tutorial.
48
 
49
  ## ✨ Key Features
50
 
51
+ 1. **Various Fine-tuning Methods:**
52
  - LoRA (Low-Rank Adaptation)
53
  - QLoRA (Quantized LoRA)
54
+ - ⚠️~Full Fine-tuning~
55
+ - ⚠️~Parameter-Efficient Fine-tuning (PEFT)~
56
 
57
+ 2. **Flexible Model Settings:**
58
  - Customizable maximum sequence length
59
  - Various quantization options
60
  - Multiple attention mechanisms
61
 
62
+ 3. **Experimental Environment Setup:**
63
  - Performance evaluation tools
64
  - Memory usage optimization
65
  - Visualization of experimental results
66
 
 
67
 
68
+ ## 📚 Implementation Examples
69
 
70
+ This repository includes the following implementation examples:
71
 
72
+ 1. **High-speed fine-tuning using Unsloth:**
73
+ - Implementation of high-speed fine-tuning for Llama-3.2-1B/3B models.
74
+ - → See [`Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md`](sandbox/Llama_3_2_1B+3B_Conversational_+_2x_faster_finetuning_JP.md) for details.
75
+ - → [Use this to convert from Markdown to Notebook format](https://huggingface.co/spaces/MakiAi/JupytextWebUI)
76
+ - [📒Notebook here](https://colab.research.google.com/drive/1AjtWF2vOEwzIoCMmlQfSTYCVgy4Y78Wi?usp=sharing)
77
 
78
+ 2. Other implementation examples will be added periodically.
79
 
80
+ ## 🛠️ Environment Setup
81
 
82
+ 1. Clone the repository:
83
+ ```bash
84
+ git clone https://github.com/Sunwood-ai-labs/Llama-finetune-sandbox.git
85
+ cd Llama-finetune-sandbox
86
+ ```
87
 
88
+ ## 📝 Adding Example Experiments
89
 
90
+ 1. Add new implementations to the `examples/` directory.
91
+ 2. Add necessary settings and utilities to `utils/`.
92
+ 3. Update documentation and tests.
93
+ 4. Create a pull request.
94
 
95
+ ## 🤝 Contributions
96
+
97
+ - Implementation of new fine-tuning methods
98
+ - Bug fixes and feature improvements
99
+ - Documentation improvements
100
+ - Addition of usage examples
101
+
102
+ ## 📚 References
103
+
104
+ - [HuggingFace PEFT Documentation](https://huggingface.co/docs/peft)
105
+ - [About Llama Models](https://github.com/facebookresearch/llama)
106
+ - [Fine-tuning Best Practices](https://github.com/Sunwood-ai-labs/Llama-finetune-sandbox/wiki)
107
+
108
+ ## ⚖️ License
109
 
110
  This project is licensed under the MIT License.
sandbox/efficient-ollama-colab-setup-with-litellm-guide.md ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LiteLLMを活用してOllamaをGoogle Colabで効率的に運用する方法
2
+
3
+ ## はじめに
4
+
5
+ ローカルLLMの運用において、OllamaとLiteLLMの組み合わせは非常に強力なソリューションとなっています。本記事では、Google Colab環境でこれらのツールを効率的に統合する方法を解説します。
6
+
7
+ ## Ollamaとは
8
+
9
+ Ollamaは、ローカル環境でLLM(大規模言語モデル)を簡単に実行できるオープンソースのツールです。主な特徴として:
10
+
11
+ - 簡単なコマンドラインインターフェース
12
+ - 効率的なモデル管理
13
+ - 軽量な実行環境
14
+ - APIサーバーとしての機能
15
+
16
+ ## LiteLLMを使う利点
17
+
18
+ LiteLLMを導入することで得られる主なメリット:
19
+
20
+ 1. **統一されたインターフェース**
21
+ - OpenAI
22
+ - Anthropic
23
+ - Ollama
24
+ - その他の主要なLLMプロバイダーに同じコードで接続可能
25
+
26
+ 2. **容易なプロバイダー切り替え**
27
+ - モデルの指定を変更するだけで異なるプロバイダーに切り替え可能
28
+ - 開発環境とプロダクション環境での柔軟な切り替え
29
+
30
+ 3. **標準化されたエラーハンドリング**
31
+ - 各プロバイダー固有のエラーを統一的に処理
32
+
33
+ ## 実装手順
34
+
35
+ ### 環境のセットアップ
36
+
37
+ ```python
38
+ # Ollamaのインストール
39
+ !curl https://ollama.ai/install.sh | sh
40
+
41
+ # CUDAドライバーのインストール
42
+ !echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
43
+ !sudo apt-get update && sudo apt-get install -y cuda-drivers
44
+ ```
45
+
46
+ ### サーバーの起動とモデルのダウンロード
47
+
48
+ ```python
49
+ # Ollamaサーバーの起動
50
+ !nohup ollama serve &
51
+
52
+ # モデルのダウンロード
53
+ !ollama pull llama3:8b-instruct-fp16
54
+ ```
55
+
56
+ ### LiteLLMを使用したモデル実行
57
+
58
+ ```python
59
+ from litellm import completion
60
+
61
+ response = completion(
62
+ model="ollama/llama3:8b-instruct-fp16",
63
+ messages=[{ "content": "respond in 20 words. who are you?","role": "user"}],
64
+ api_base="http://localhost:11434"
65
+ )
66
+ print(response)
67
+ ```
68
+
69
+ ## プロバイダーの切り替え例
70
+
71
+ LiteLLMを使用することで、以下のように簡単に異なるプロバイダーに切り替えることができます:
72
+
73
+ ```python
74
+ # OpenAIの場合
75
+ response = completion(
76
+ model="gpt-3.5-turbo",
77
+ messages=[{"content": "Hello!", "role": "user"}]
78
+ )
79
+
80
+ # Anthropicの場合
81
+ response = completion(
82
+ model="claude-3-opus-20240229",
83
+ messages=[{"content": "Hello!", "role": "user"}]
84
+ )
85
+
86
+ # Ollamaの場合(ローカル実行)
87
+ response = completion(
88
+ model="ollama/llama3:8b-instruct-fp16",
89
+ messages=[{"content": "Hello!", "role": "user"}],
90
+ api_base="http://localhost:11434"
91
+ )
92
+ ```
93
+
94
+ ## 注意点とベストプラクティス
95
+
96
+ 1. **リソース管理**
97
+ - Google Colabの無料枠でも実行可能
98
+ - GPUメモリの使用状況に注意
99
+
100
+ 2. **セッション管理**
101
+ - Colabのセッション切断時は再セットアップが必要
102
+ - 長時間の実行にはPro版の使用を推奨
103
+
104
+ ## まとめ
105
+
106
+ OllamaとLiteLLMの組み合わせは、ローカルLLMの運用を大幅に簡素化します。特に:
107
+
108
+ - 統一されたインターフェースによる開発効率の向上
109
+ - 異なるプロバイダー間での容易な切り替え
110
+ - Google Colab環境での簡単な実行
111
+
112
+ これらの利点により、プロトタイピングから本番環境まで、柔軟なLLMの活用が可能となります。
113
+
114
+ ## ノートブック
115
+
116
+ https://colab.research.google.com/drive/1buTPds1Go1NbZOLlpG94VG22GyK-F4GW?usp=sharing
117
+
118
+ ## リポジトリ
119
+
120
+ https://github.com/Sunwood-ai-labs/Llama-finetune-sandbox
121
+
122
+ ## 参考サイト
123
+
124
+ https://note.com/masayuki_abe/n/n9640e08492ac
125
+