summerstars commited on
Commit
e60e117
·
verified ·
1 Parent(s): 17dfc76

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -35
README.md CHANGED
@@ -2,75 +2,81 @@
2
  base_model: HuggingFaceTB/SmolLM2-360M-Instruct
3
  library_name: peft
4
  ---
5
- # SOAR Model Pipeline 推論コード
6
 
7
  ## 📌 概要
8
- このリポジトリには、SOAR(A Cognitive Architecture for General Intelligence)モデルを基にしたLoRA(Low-Rank Adaptation)微調整済みの言語モデルが含まれています。
9
- このモデルは高校生による個人研究の一環として開発されており、十分な検証や最適化が行われている保証はありません。実験的なプロジェクトであるため、実用性や精度については慎重に評価してください。
 
 
 
 
 
 
 
 
 
 
10
 
11
  ---
12
 
13
- ## 🚀 パイプラインのセットアップ
14
 
15
- SOAR LoRAモデルを使うためのパイプラインを以下のコードでセットアップします。
16
 
17
  ```python
18
  from peft import PeftModel
19
  from transformers import AutoModelForCausalLM
20
 
 
21
  base_model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-360M-Instruct")
 
 
22
  model = PeftModel.from_pretrained(base_model, "summerstars/Soar_adapter")
23
  ```
24
 
 
 
25
  ---
26
 
27
  ## 💬 推論の実行
28
 
29
- モデルにプロンプトを入力して、推論を行う方法は以下の通りです。
30
 
31
  ```python
32
- def generate_text(pipeline, role, topic, max_length=200, temperature=0.7, top_p=0.95, top_k=50):
33
- prompt = f"{role}: {topic}"
34
- response = pipeline(prompt, max_length=max_length, temperature=temperature, top_p=top_p, top_k=top_k, do_sample=True)
 
 
 
 
 
 
 
 
 
35
  return response[0]["generated_text"]
36
 
37
- # 例: AIと人間の認知に関する分析
38
- soar_prompt = "Discuss the impact of AI on human cognition."
39
-
40
  print("【SOAR Model Output】")
41
- print(generate_text(soar_pipeline, "SOAR Agent", soar_prompt))
42
- ```
43
-
44
- ### 推論例
45
- #### 入力:
46
- `Discuss the impact of AI on human cognition.`
47
-
48
- #### 出力(例):
49
- ```
50
- The future of artificial intelligence (AI) in the context of human cognition is a fascinating and complex subject. AI systems are increasingly capable of performing tasks that were once thought to be exclusively within the realm of human intelligence. In particular, AI has demonstrated remarkable progress in areas such as natural language processing (NLP), machine learning, and problem-solving.
51
-
52
- As AI continues to evolve, its potential to augment human cognitive capabilities will expand. By working alongside humans, AI can enhance our ability to process and analyze vast amounts of information, allowing us to make better decisions and solve complex problems more efficiently.
53
-
54
- AI also has the potential to change the way we understand and interpret human cognition itself. By studying how AI systems solve problems, we may gain insights into the workings of the human brain and the underlying mechanisms of intelligence.
55
  ```
56
 
57
  ---
58
 
59
  ## ⚠ 免責事項
60
- このモデルは**高校生による個人研究**として開発されており、
61
- 専門的な研究機関による厳密な検証やチューニングが行われているわけではありません。
62
-
63
- - **精度や汎用性に課題がある可能性があります。**
64
- - **科学的な正確性を保証するものではありません。**
65
- - **実際の応用に使用する場合は、十分に検証を行ってください。**
66
 
67
  ---
68
 
69
  ## 🧠 参考文献
70
- - Newell, A., & Simon, H. A. (1976). *Computer science as empirical inquiry: Symbols and search*. Communications of the ACM.
71
- - LoRA (Low-Rank Adaptation) 論文: Hu et al. (2021)
72
 
73
  ---
74
 
75
  ## 📜 ライセンス
76
- このモデルは `Apache 2.0` ライセンスのもとで公開されています。
 
2
  base_model: HuggingFaceTB/SmolLM2-360M-Instruct
3
  library_name: peft
4
  ---
5
+ # SOAR Model with PEFT (Parameter-Efficient Fine-Tuning)
6
 
7
  ## 📌 概要
8
+ このドキュメントでは、SOARモデルにPEFT(パラメータ効率的ファインチューニング)を適用した実装方法を紹介します。PEFTは大規模な言語モデルを効率よく微調整するための手法で、SOARモデルにこの技術を適用することにより、少ないパラメータで効果的に適応させることができます。
9
+
10
+ ## 🚀 必要なライブラリ
11
+
12
+ - **transformers**: Hugging Face Transformersライブラリ
13
+ - **peft**: PEFT用のライブラリ
14
+
15
+ 以下のコマンドでライブラリをインストールします。
16
+
17
+ ```bash
18
+ pip install transformers peft
19
+ ```
20
 
21
  ---
22
 
23
+ ## 🔧 モデルの準備
24
 
25
+ 以下のコードを使用して、SOARモデルをPEFTを使ってロードします。
26
 
27
  ```python
28
  from peft import PeftModel
29
  from transformers import AutoModelForCausalLM
30
 
31
+ # ベースモデルのロード
32
  base_model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-360M-Instruct")
33
+
34
+ # SOAR用のアダプターを適用
35
  model = PeftModel.from_pretrained(base_model, "summerstars/Soar_adapter")
36
  ```
37
 
38
+ このコードは、Hugging Faceから事前訓練済みの`SmolLM2-360M-Instruct`をベースにし、`summerstars/Soar_adapter`というPEFTアダプターを適用するものです。
39
+
40
  ---
41
 
42
  ## 💬 推論の実行
43
 
44
+ モデルをロードした後、推論を実行するコードは以下の通りです。
45
 
46
  ```python
47
+ from transformers import pipeline
48
+
49
+ # パイプラインの設定
50
+ soar_pipeline = pipeline(
51
+ "text-generation",
52
+ model=model,
53
+ tokenizer=base_model.tokenizer # ベースモデルのトークナイザーを使用
54
+ )
55
+
56
+ # 推論関数の定義
57
+ def generate_soar_text(prompt, max_length=200, temperature=0.7, top_p=0.95, top_k=50):
58
+ response = soar_pipeline(prompt, max_length=max_length, temperature=temperature, top_p=top_p, top_k=top_k, do_sample=True)
59
  return response[0]["generated_text"]
60
 
61
+ # 例: 推論の実行
62
+ soar_prompt = "What is the future of AI?"
 
63
  print("【SOAR Model Output】")
64
+ print(generate_soar_text(soar_prompt))
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  ```
66
 
67
  ---
68
 
69
  ## ⚠ 免責事項
70
+ - **このコードは研究目的で作成されたものであり、商用利用を意図し��いません。**
71
+ - **PEFTを適用したモデルの最適化にはさらに調整が必要な場合があります。**
 
 
 
 
72
 
73
  ---
74
 
75
  ## 🧠 参考文献
76
+ - Laird, J. E. (2012). *The SOAR Cognitive Architecture*. MIT Press.
77
+ - PEFT論文: *Parameter-Efficient Fine-Tuning* by Houlsby et al. (2019)
78
 
79
  ---
80
 
81
  ## 📜 ライセンス
82
+ このプロジェクトは `Apache 2.0` ライセンスのもとで公開されています。