ホームページ >テクノロジー周辺機器 >AI >Zephyr-7Bの包括的なガイド:機能、使用、微調整
Zephyr-7Bを探索:強力なオープンソースLLM
Openai LLMリーダーボードは、GPT-4のライバルを目指した新しいオープンソースモデルで賑わっており、Zephyr-7Bは傑出した候補です。このチュートリアルでは、WebPilot.aiのこの最先端の言語モデルを調査し、トランスフォーマーパイプラインでの使用とエージェントインストラクションデータセットでの微調整を示しています。 AIは初めてですか? AIの基礎スキルトラックは素晴らしい出発点です。
Zephyr-7bZephyr-7B-β:微調整されたマーベル
シリーズの2番目のモデルであるZephyr-7B-βは、微調整されたMistral-7Bモデルです。 公共および合成データセットのブレンドで直接優先最適化(DPO)を使用してトレーニングされ、複雑なクエリの解釈と長いテキストの要約に優れています。 そのリリースでは、MTベンチとアルパカエバルのベンチマークの7Bチャットモデルの中でトップの地位を保持しました。 Zephyr Chatで無料のデモでその機能をテストします。Zephyr Chatの画像
フェイストランスを抱きしめてZephyr-7Bにアクセス
このチュートリアルでは、簡単にアクセスできるようにフェイストランスを抱き締めます。 (読み込みの問題に遭遇した場合は、推論Kaggleノートブックを参照してください。)
!pip install -q -U transformers !pip install -q -U accelerate !pip install -q -U bitsandbytes
import torch from transformers import pipelineは、計算の速度とメモリの使用量の減少を提供します(ただし、精度がわずかに低く)。
device_map="auto"
テキストの生成:torch.bfloat16
以下の例は、Pythonコードの生成を示しています
model_name = "HuggingFaceH4/zephyr-7b-beta" pipe = pipeline( "text-generation", model=model_name, torch_dtype=torch.bfloat16, device_map="auto", )
prompt = "Write a Python function that can clean the HTML tags from the file:" outputs = pipe( prompt, max_new_tokens=300, do_sample=True, temperature=0.7, top_k=50, top_p=0.95, ) print(outputs[0]["generated_text"])
!pip install -q -U transformers !pip install -q -U accelerate !pip install -q -U bitsandbytes
import torch from transformers import pipeline
Kaggle Secrets(Kaggle Notebooksの場合):ハグの顔と重量とバイアスAPIキーを取得します。
顔と重量とバイアスの抱きしめログイン:
model_name = "HuggingFaceH4/zephyr-7b-beta" pipe = pipeline( "text-generation", model=model_name, torch_dtype=torch.bfloat16, device_map="auto", )
prompt = "Write a Python function that can clean the HTML tags from the file:" outputs = pipe( prompt, max_new_tokens=300, do_sample=True, temperature=0.7, top_k=50, top_p=0.95, ) print(outputs[0]["generated_text"])AgentInStruct DataSet Processing
関数は、データセットをZephyr-7Bのプロンプトスタイルに適応させます。
format_prompt
messages = [ { "role": "system", "content": "You are a skilled software engineer who consistently produces high-quality Python code.", }, { "role": "user", "content": "Write a Python code to display text in a star pattern.", }, ] prompt = pipe.tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True ) outputs = pipe( prompt, max_new_tokens=300, do_sample=True, temperature=0.7, top_k=50, top_p=0.95, ) print(outputs[0]["generated_text"])
モデルの読み込みと準備
%%capture %pip install -U bitsandbytes %pip install -U transformers %pip install -U peft %pip install -U accelerate %pip install -U trl
# ... (Import statements as in original tutorial) ...
!huggingface-cli login --token $secret_hf # ... (wandb login as in original tutorial) ...HyperParametersを構成します(詳細については、微調整Llama 2チュートリアルを参照してください)。
base_model = "HuggingFaceH4/zephyr-7b-beta" dataset_name = "THUDM/AgentInstruct" new_model = "zephyr-7b-beta-Agent-Instruct"
# ... (format_prompt function and dataset loading as in original tutorial) ...
# ... (bnb_config and model loading as in original tutorial) ...
モデルを保存:
# ... (tokenizer loading and configuration as in original tutorial) ...
# ... (peft_config and model preparation as in original tutorial) ...
Zephyr-7b-betaは印象的な能力を示しています。このチュートリアルは、リソースに制約のあるGPUでさえ、この強力なLLMを利用および微調整するための包括的なガイドを提供します。 より深いLLM知識のためのマスターラージランゲージモデル(LLMS)コンセプトコースを検討してください。
以上がZephyr-7Bの包括的なガイド:機能、使用、微調整の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。