ويشمل معاملات المؤلفين
كأي نموذجالتعلم الآلي، لدينا معاملات المؤلفينالنماذج الكبيرة اللغويةالتي تحكم في تنوع من النتائج المنتجة من النص المنشور. بدأنا سلسلة متعددة الجزء لشرح التأثير على هذه المعاملات بالوصف التفصيلي. سننتهي بإيجاد التوازن المثالي في توليد المحتويات باستخدام جميع هذه المعاملات التي تحدثنا عنها في سلسلتنا المتعددة الجزء.
مرحبا بك في الجزء الأول، حيث نتحدث عن أكثر المعاملات شهرة، “الحرارة.”
الحرارة
إذا كان هدفك تحكم في عشوائية التنبؤات، فإن الحرارة هي المفاتيح التي تمتلك. تأخذ قيم الحرارة منخفضة تجعل النتائج أكثر قابلية للتحديد بينما تزيد قيمتها تجعلها أكثر إبداعاً من خلال تسمح للنتائج بخيال متنوع.
دعونا نرى الحرارة في عمل ما بواسطة البرمجيات التالية والناتج. لتوضيح الأهمية ببساطة، اخترنا تحويل المؤلفين لهذه المرة ونموذج GPT2 بالتحديد.
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load GPT-2 model and tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2LMHeadModel.from_pretrained("gpt2")
# Add pad token to tokenizer (GPT-2 doesn't have it by default)
tokenizer.pad_token = tokenizer.eos_token
# Function to generate response with varying temperature
def generate_with_temperature(prompt, temperature):
inputs = tokenizer(prompt, return_tensors='pt', padding=True)
# Set the attention_mask and pad_token_id
outputs = model.generate(
inputs.input_ids,
attention_mask=inputs['attention_mask'],
do_sample=True,
max_length=200,
temperature=temperature,
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
#Prompt on which we get the content generated based on temperature
prompt = "What are some of the best strategies within NFL Fantasy"
# Test temperature variations
print("Temperature 0.3 (Less deterministic but coherent):\n", generate_with_temperature(prompt, temperature=0.3))
print("\nTemperature 0.5 (Balanced):\n", generate_with_temperature(prompt, temperature=0.5))
print("\nTemperature 0.9 (More creative):\n", generate_with_temperature(prompt, temperature=0.9))
الناتج:
python test_temperature.py
Temperature 0.3 (Less deterministic but coherent):
What are some of the best strategies within NFL Fantasy Football?
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next NFL season. I've seen great strategies for predicting the next NFL season.
I've seen a lot of great strategies for predicting the next
Temperature 0.5 (Balanced):
What are some of the best strategies within NFL Fantasy Football?
1. Pick up the first pick and use it to draft a QB
In the past, I've mentioned that I tend to pick up the first pick in the first round. The best way to pick up the first pick is to take the first pick and then use it to draft a QB. I find that the more I draft the QB, the more I draft the QB. This is why I like to draft the first pick in the first round.
2. Draft a QB for the first time
This is an important one, but it's not the only one. Drafting a QB for the first time is a great way to start your fantasy season.
3. Draft a QB for the first time
This is the most important one. Drafting a QB for the first time is the most important one. Drafting a QB for the first time is the most important one.
Temperature 0.9 (More creative):
What are some of the best strategies within NFL Fantasy?
If you are looking for players that will be good for you, here is an updated list of key stats, which you can find on our official website:
All players were ranked in the top 10 fantasy players. These players are all high-rated defensive backs or running backs with good play across all phases of their careers. The players above were ranked from 5-5 for total points scored.
The chart below will allow you to visualize the players in your league.
All players have 5.5 sacks, 5 sacks and 2.5 tackles for loss on the season. They have a combined 11.3 sacks with a 4.6, 1.6 and 2.1 yards per carry average, respectively.
Each player has three touchdowns. The three touchdowns are tied for the top five fantasy points with 3 points in an entire game. The three touchdowns are tied for the top ten points with 2 points
دعونا نفهم الناتج:
- الحرارة المنخفضة (0.3):النموذج سيركز على أختيارات الكلمات الأكثر مرجحية. إذا كان لديك توجهات على إستمرارية ودقة عالية، فلا بد من تقديم الحرارة حول هذا النطاق. ولكن تذكر أن النموذج قد يتوقف عن التكرار بالعبارات المماثلة ، كما هو حال مع ناتجنا ه
- درجة متوسطة (0.5): توفر هذه الدرجة من التوازن المثالي بين الترابوة والإبداع. إنها من المساويات الأفضل إذا كنت تريد مقدار معين من التنوع دون فقدان الهيكل. كما ترون في الناتج، تم إضافة قليل من التوازن، ومع ذلك يمكنك رؤية بعض التكرار في الناتج.
- درجة عالية (0.9): تتسبب هذه الدرجة في تفجير النظام العام للمجموعة التعليمية ليكون أكثر إبداعاً. كما ترون، تختلف هذا الناتج عن السابقتين، ويحمل كثيرًا من العشوائية والتنوع في المحتويات.
لذا توضح المثالين أعلاه أساسيات الدرجة. دعونا ننظر الآن إليها بصورة أكثر تفاصيلًا مع بعض حالات الاستخدام: “توليد القصص الإبداعية” و”التفسير التقني.”
دعونا ننظر إلى هذا مع التعليم البرمجي تحت الدرجة لفهم كيفية تأثير الدرجة على الحالات السابقتين. نحن نراقب أيضًا كيف تعمل التعديل على الدرجة بشكل جيد لحالة وتفعل العكس لأخرى.
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load GPT-2 model and tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
model = GPT2LMHeadModel.from_pretrained("gpt2")
# Add pad token to tokenizer (GPT-2 doesn't have it by default)
tokenizer.pad_token = tokenizer.eos_token
# Function to generate response based on temperature
def generate_with_temperature(prompt, temperature, max_length=200):
inputs = tokenizer(prompt, return_tensors='pt', padding=True)
outputs = model.generate(
inputs.input_ids,
attention_mask=inputs['attention_mask'],
do_sample=True,
max_length=max_length,
temperature=temperature, # Only focusing on temperature
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
### USE CASE 1: CREATIVE STORY GENERATION ###
def creative_story_generation():
prompt = "Once upon a time, in a distant galaxy, there was a spaceship called Voyager."
# Negative Impact: Low temperature for creative writing (too deterministic, repetitive)
print("\n=== Creative Story with Low Temperature (0.2) - Negative Impact: ===")
low_temp_story = generate_with_temperature(prompt, temperature=0.2)
print(low_temp_story)
# Perfect Impact: High temperature for creative writing (more creative and varied)
print("\n=== Creative Story with High Temperature (0.9) - Perfect Impact: ===")
high_temp_story = generate_with_temperature(prompt, temperature=0.9)
print(high_temp_story)
### USE CASE 2: TECHNICAL EXPLANATION ###
def technical_explanation():
prompt = "Explain how blockchain works in simple terms."
# Negative Impact: High temperature for technical writing (too creative, inaccurate)
print("\n=== Technical Explanation with High Temperature (0.9) - Negative Impact: ===")
high_temp_explanation = generate_with_temperature(prompt, temperature=0.9)
print(high_temp_explanation)
# Perfect Impact: Optimal temperature for technical writing (accurate and focused)
print("\n=== Technical Explanation with Adjusted Temperature (0.7) - Perfect Impact: ===")
perfect_temp_explanation = generate_with_temperature(prompt, temperature=0.7)
print(perfect_temp_explanation)
# Run both use cases
creative_story_generation()
technical_explanation()
الناتج:
python temperature_impact.py
=== Creative Story with Low Temperature (0.2) - Negative Impact: ===
Once upon a time, in a distant galaxy, there was a spaceship called Voyager. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been brought back from the dead by the gods. It was a spaceship that had been
=== Creative Story with High Temperature (0.9) - Perfect Impact: ===
Once upon a time, in a distant galaxy, there was a spaceship called Voyager. The ship seemed to have been flying in space as well, like the spaceship in the movie "The Voyage Home". The Captain of the Voyager was Captain Jean-Luc Picard.
In the Star Trek movies, this is true. But in the movie, on Voyager, our hero is not Jean-Luc Picard. Jean-Luc, the villain, has no desire to lead us to vengeance against the dying star.
But what about Star Trek VI: The Undiscovered Country…
In a scene that's been in development for years (one you'll almost certainly see in an upcoming Star Trek film), in the middle of the movie (one you won't see until later in the film), we see that Picard is no longer in the Star Trek universe as is the story, to be played by the same actor who played Lieutenant Dax (who was in the movie), but Picard himself.
=== Technical Explanation with High Temperature (0.9) - Negative Impact: ===
Explain how blockchain works in simple terms.
Blockchain can be used to determine if the system is trustworthy and to prevent fraud, even if the system is used in a completely different manner. Blockchain can also be used to help determine how the system is run and to ensure that its operation is efficient.
This way all your trust in the system can be verified by your actions, and you can have full control over it. When you are not trusting a computer, it can be easy to get a hold of a server and then just change the software, allowing you to control and monitor transactions with the help of the blockchain. If your business uses distributed storage then it is easy to have more control over your activities.
What do I need to understand about blockchain?
To understand how blockchain works and how you can use it properly, you must first understand how blockchain works.
Bitcoins are digital tokens, created at the start of each generation that are used to
=== Technical Explanation with Adjusted Temperature (0.7) - Perfect Impact: ===
Explain how blockchain works in simple terms.
What are the key differences between Bitcoin and Ethereum?
Blockchain is a cryptographic protocol. It can be used to create any type of transaction. It is used to store data and create new entities. It is used as a system of communication in blockchain systems.
In Ethereum, the transaction is recorded, stored, and used to perform the transaction. It is a way to transfer information. The transaction is called a "blockchain."
Since the blockchain is used for many things, it is easy to understand how the technology works. The most important difference is that Ethereum uses the blockchain to create an interface to the Internet of Things. It is this interface that allows for data exchange and the creation of new entities.
Because of this, it is possible to perform the transactions on the blockchain. So, what is the difference between Bitcoin and Ethereum?
The Bitcoin and Ethereum blockchain is a distributed ledger.
والآن دعونا نتوقف ونتحليل الناتج لتوليد القصص الإبداعية والتفسير التقني بناءً على الدرجات التي تأثيرها على الناتج وكيف تأثيرت الدرجة. نراقب أيضًا كيف تعمل تعديل الدرجة بشكل جيد لحالة وتفعل العكس لأخرى.
توليد القصص الإبداعية
- درجة منخفضة (تأثير سيء): كما ترون، تم إنتاج القصة بشكل تكراري وغير متنو
- معدل عالي للحرارة (التأثير المثالي): كما ترون من الخريطة الخاملة، تتخذ القصة اتجاهات مشوقة و مبدعة للغاية. و يضيف الخريطة أيضًا جوانب متعددة للقصة، و هو ما يجعلها متنوعة و مخيلة و مثالية للخبرة الإبداعية في التحكيم في القصص.
تفسير تقني
- معدل عالي للحرارة (التأثير السلبي): من المهم أن نتذكر أن الدقة الفائقة مهم جدًا للحالة مثل التفسير التقني. يقود الحرارة العالية إلى مجموعة كبيرة من التعجيل و الكلمات الأقل معتادية تم إدخالها إلى المحتوى المنتج مما يجعله غير مرضي للكتابة التقنية. يمكن أيضًا تساؤل من خلال الخريطة أعلاه أنه غامر و يشمل أفكار غير متعلقة.
- تعديل الحرارة (التأثير المثالي): قمنا بتعديل الحرارة الى إعدادة توازن مثالي لإنتاج المحتوى التقني. و كما ترون، يبدو الخريطة أكثر ترتيبًا الآن. بتعديل الحرارة الى هذا الإعدادة، تتمتع النموذج بتجنب التكرار مثلما تفعل في أدنى الحرارة و تحتوي على توحد المواد المتعلقة مثلما تفعل في أعلى الحرارة.
خلاصة
لقد رأيتم كل طرق الحرارة التي يمكن أن تؤثر على توليد المحتوى و أي إعدادة الحرارة التي تكون مثالية للأغراض المختلفة. أيضًا، لا تفوت أن تلاحظ أن تعديل الحرارة ليس الجميع في العالم في التوليد المحتوى؛ سوف يتوجب عليك تغيير معا
Source:
https://dzone.com/articles/decoding-llm-parameters-temperature