फाइन-ट्यूनिंग के लिए डेटा प्रीप्रोसेसिंग

Llama 3 के साथ फाइन-ट्यूनिंग

Francesca Donadoni

Curriculum Manager, DataCamp

फाइन-ट्यूनिंग के लिए डेटासेट्स का उपयोग

  • डेटा की गुणवत्ता सबसे अहम है

  • Training Set:

    • मॉडल ट्रेनिंग के लिए
    • डेटा का अधिकांश हिस्सा

ट्रेनिंग सेट वाले डेटासेट का डायग्राम.

Llama 3 के साथ फाइन-ट्यूनिंग

फाइन-ट्यूनिंग के लिए डेटासेट्स का उपयोग

  • डेटा की गुणवत्ता सबसे अहम है

  • Training Set:

    • मॉडल ट्रेनिंग के लिए
    • डेटा का अधिकांश हिस्सा
  • Validation Set:
    • बेस्ट मॉडल वर्ज़न चुनने के लिए

ट्रेनिंग और वेलिडेशन सेट का डायग्राम.

Llama 3 के साथ फाइन-ट्यूनिंग

फाइन-ट्यूनिंग के लिए डेटासेट्स का उपयोग

  • डेटा की गुणवत्ता सबसे अहम है

  • Training Set:

    • मॉडल ट्रेनिंग के लिए
    • डेटा का अधिकांश हिस्सा
  • Validation Set:
    • बेस्ट मॉडल वर्ज़न चुनने के लिए
  • Test Set:
    • मॉडल के परफॉर्मेंस का मूल्यांकन

ट्रेनिंग, वेलिडेशन, और टेस्ट सेट का डायग्राम.

Llama 3 के साथ फाइन-ट्यूनिंग

datasets लाइब्रेरी से डेटा तैयार करना

 

  • Datasets लाइब्रेरी
  • प्रीप्रोसेसिंग
  • स्प्लिट
  • लोड
  • मेमोरी मैनेज करें

डेटा फ्लो का डायग्राम: डेटासेट से datasets लाइब्रेरी में, जिसमें 3 हरे बॉक्स हैं—प्रीप्रोसेसिंग, लोडिंग/डेटा मैनेज करना, और इंटीग्रेशन्स—फिर आउटपुट में प्रिपेयर्ड डेटा.

Llama 3 के साथ फाइन-ट्यूनिंग

कस्टमर सर्विस डेटासेट लोड करना

from datasets import load_dataset

ds = load_dataset( 'bitext/Bitext-customer-support-llm-chatbot-training-dataset',
split="train"
)
print(ds.column_names)
['flags', 'instruction', 'category', 'intent', 'response']
Llama 3 के साथ फाइन-ट्यूनिंग

डेटा पर एक नज़र

import pprint
pprint.pprint(ds[0])
{'category': 'ORDER',
 'flags': 'B',
 'instruction': 'question about cancelling order {{Order Number}}',
 'intent': 'cancel_order',
 'response': "I've understood you have a question regarding canceling order "
             "{{Order Number}}, and I'm here to provide you with the "
             'information you need. Please go ahead and ask your question, and '
             "I'll do my best to assist you."}
Llama 3 के साथ फाइन-ट्यूनिंग

डेटासेट फ़िल्टर करना

from datasets import load_dataset, Dataset

ds = load_dataset(
    'bitext/Bitext-customer-support-llm-chatbot-training-dataset',
    split="train")

print(ds.shape)
(26872, 5)
first_thousand_points = ds[:1000]

ds = Dataset.from_dict(first_thousand_points)
Llama 3 के साथ फाइन-ट्यूनिंग

डेटासेट की प्रीप्रोसेसिंग

def merge_example(row):

row['conversation'] = f"Query: {row['instruction']}\nResponse: {row['response']}" return row
ds = ds.map(merge_example)
print(ds[0]['conversation'])
Query: question about cancelling order {{Order Number}}
Response: I've understood you have a question regarding canceling order {{Order Number}}, 
and I'm here to provide you with the information you need. Please go ahead and ask your 
question, and I'll do my best to assist you.
Llama 3 के साथ फाइन-ट्यूनिंग

प्रीप्रोसेस्ड डेटासेट सेव करना

ds.save_to_disk("preprocessed_dataset")
Saving the dataset (1/1 shards): 100%
26872/26872 [00:00<00:00, 383823.33 examples/s]
from datasets import load_from_disk
ds_preprocessed = load_from_disk("preprocessed_dataset")
Llama 3 के साथ फाइन-ट्यूनिंग

TorchTune के साथ Hugging Face डेटासेट्स का उपयोग

 

  • Hugging Face डेटासेट को TorchTune के साथ उपयोग कर सकते हैं
  • डेटासेट पाथ और कॉन्फ़िगरेशन सेट करें

 

tune run full_finetune_single_device --config llama3/8B_full_single_device \
dataset=preprocessed_dataset dataset.split=train
Llama 3 के साथ फाइन-ट्यूनिंग

अभ्यास करते हैं!

Llama 3 के साथ फाइन-ट्यूनिंग

Preparing Video For Download...