शुरू करेंमुफ़्त में शुरू करें

Few-shot उदाहरण देना

हालाँकि structured outputs यह बताते हैं कि आप डेटा किस रूप में वापस पाना चाहेंगे, फिर भी क्या लौटाना चाहिए, इसकी व्याख्या के लिए काफी गुंजाइश रह जाती है.

Field क्लास आपको उदाहरण मान देने देती है, जो LLM को यह जानकारी देते हैं कि एक अच्छा extraction कैसा दिखता है. यह structured outputs के लिए few-shot prompting का एक उदाहरण है.

आप Character क्लास को बढ़ाकर उसमें characters की uniquely पहचान के लिए id फ़ील्ड जोड़ेंगे. आप मॉडल को दो उदाहरण देना चाहते हैं ताकि वह उनसे संदर्भ ले सके: "romeo-montague" और "lady-capulet".

यह अभ्यास पाठ्यक्रम का हिस्सा है

LangChain और Neo4j के साथ Graph RAG

पाठ्यक्रम देखें

अभ्यास निर्देश

  • id प्रॉपर्टी के लिए उदाहरण मान देने वाला कीवर्ड निर्दिष्ट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

class Character(BaseModel):
	id: str = Field(
		description="A unique identifer consisting of the Character's given name and their family name in slug case.", 
		# Provide example values of an ID
		____=["romeo-montague", "lady-capulet"]
	)
	name: str = Field(description="The name of the character")

chain = prompt | llm.with_structured_output(Character)

chain.invoke({"text": """JULIET.
O Romeo, Romeo, wherefore art thou Romeo? Deny thy father and refuse thy name. Or if thou wilt not, be but sworn my love, And I’ll no longer be a Capulet."""})
कोड संपादित करें और चलाएँ