JSON इन्वेंटरी लिस्ट बनाना
LLMs से structured आउटपुट बनवाने की क्षमता का मतलब है कि वे न्यूनतम प्रोसेसिंग के साथ सिस्टमों के बीच जानकारी भरोसेमंद तरीके से एक्सचेंज कर सकते हैं.
आप एक प्राकृतिक भाषा में लिखी गई स्टॉक इन्वेंटरी लिस्ट को JSON फॉर्मेट में बदलकर अपनी prompting स्किल्स टेस्ट करेंगे. आपके लिए एक मॉडल और सिस्टम प्रॉम्प्ट पहले से दिए गए हैं जिनका आप उपयोग करेंगे.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Llama 3 के साथ काम करना
अभ्यास निर्देश
- JSON फॉर्मेट में responses जनरेट करने के लिए
response_formatडिक्शनरी को पूरा करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
output = llm.create_chat_completion(
messages=[
{"role": "system", "content": "You convert inventory lists from text to JSON, extracting item counts and names from the text as keys and values in the form: item: count; for example, 'banana': 32.",},
{"role": "user", "content": "Fifteen apples, thirty-three oranges, and five thousand fifty-two potatoes."},
],
# Specify output format to JSON
response_format={
"type": ____,
}
)
print(output['choices'][0]['message']['content'])