We use our data and come up with relevant questions
Datapoint 1
data[10]
Output: Document(page_content=“: 10: Cozy Comfort Pullover Set, Stripe: Perfect for lounging, this striped knit set lives up to its name. We used ultrasoft fabric and an easy design that’s as comfortable at bedtime as it is when we have to make a quick run out.& Fit- Pants are Favorite Fit: Sits lower on the waist.- Relaxed Fit: Our most generous fit sits farthest from the body.& Care- In the softest blend of 63% polyester, 35% rayon and 2% spandex.Features- Relaxed fit top with raglan sleeves and rounded hem.- Pull-on pants have a wide elastic waistband and drawstring, side pockets and a modern slim leg..”, metadata={‘source’: ‘../data/OutdoorClothingCatalog_1000.csv’, ‘row’: 10})
Datapoint 2
data[11]
Output: Document(page_content=‘: 11: Ultra-Lofty 850 Stretch Down Hooded Jacket: This technical stretch down jacket from our DownTek collection is sure to keep you warm and comfortable with its full-stretch construction providing exceptional range of motion. With a slightly fitted style that falls at the hip and best with a midweight layer, this jacket is suitable for light activity up to 20° and moderate activity up to -30°. The soft and durable 100% polyester shell offers complete windproof protection and is insulated with warm, lofty goose down. Other features include welded baffles for a no-stitch construction and excellent stretch, an adjustable hood, an interior media port and mesh stash pocket and a hem drawcord. Machine wash and dry. Imported.’, metadata={‘source’: ‘../data/OutdoorClothingCatalog_1000.csv’, ‘row’: 11})
Hard-coded example questions
examples = [ {"query": "Do the Cozy Comfort Pullover Set\ have side pockets?","answer": "Yes" }, {"query": "What collection is the Ultra-Lofty \ 850 Stretch Down Hooded Jacket from?","answer": "The DownTek collection" }]
# the warning can be safely ignorednew_examples = example_gen_chain.apply_and_parse( [{"doc": t} for t in data[:5]])
New examples
new_examples[0]
Output: {‘query’: “What is the weight of one pair of Women’s Campside Oxfords?”, ‘answer’: “The approximate weight of one pair of Women’s Campside Oxfords is 1 lb. 1 oz.”}
Original data
data[0]
Output: Document(page_content=“: 0: Women’s Campside Oxfords: This ultracomfortable lace-to-toe Oxford boasts a super-soft canvas, thick cushioning, and quality construction for a broken-in feel from the first time you put them on. & Fit: Order regular shoe size. For half sizes not offered, order up to next whole size. : Approx. weight: 1 lb.1 oz. per pair. : Soft canvas material for a broken-in feel and look. Comfortable EVA innersole with Cleansport NXT® antimicrobial odor control. Vintage hunt, fish and camping motif on innersole. Moderate arch contour of innersole. EVA foam midsole for cushioning and support. Chain-tread-inspired molded rubber outsole with modified chain-tread pattern. Imported. ? Please contact us for any inquiries.”, metadata={‘source’: ‘../data/OutdoorClothingCatalog_1000.csv’, ‘row’: 0})
QA Chain
Combine examples
examples += new_examples
qa.run(examples[0]["query"])
Output: ‘Yes, the Cozy Comfort Pullover Set does have side pockets.’
Very litte information about the process in the output
Langchain debug
We set .debug=Trueto get more information
langchain.debug =True
Rerun the same application and take a look at your output
qa.run(examples[0]["query"])
[chain/start][1:chain:RetrievalQA] Entering Chain run with input:{"query":"Do the Cozy Comfort Pullover Set have side pockets?"}[chain/start] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain] Entering Chain run with input:[inputs][chain/start] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain > 4:chain:LLMChain] Entering Chain run with input:{"question":"Do the Cozy Comfort Pullover Set have side pockets?","context":": 10\nname: Cozy Comfort Pullover Set, Stripe\ndescription: Perfect for lounging, this striped knit set lives up to its name. We used ultrasoft fabric and an easy design that's as comfortable at bedtime as it is when we have to make a quick run out.\n\nSize & Fit\n- Pants are Favorite Fit: Sits lower on the waist.\n- Relaxed Fit: Our most generous fit sits farthest from the body.\n\nFabric & Care\n- In the softest blend of 63% polyester, 35% rayon and 2% spandex.\n\nAdditional Features\n- Relaxed fit top with raglan sleeves and rounded hem.\n- Pull-on pants have a wide elastic waistband and drawstring, side pockets and a modern slim leg.\n\nImported.<<<<>>>>>: 73\nname: Cozy Cuddles Knit Pullover Set\ndescription: Perfect for lounging, this knit set lives up to its name. We used ultrasoft fabric and an easy design that's as comfortable at bedtime as it is when we have to make a quick run out. \n\nSize & Fit \nPants are Favorite Fit: Sits lower on the waist. \nRelaxed Fit: Our most generous fit sits farthest from the body. \n\nFabric & Care \nIn the softest blend of 63% polyester, 35% rayon and 2% spandex.\n\nAdditional Features \nRelaxed fit top with raglan sleeves and rounded hem. \nPull-on pants have a wide elastic waistband and drawstring, side pockets and a modern slim leg. \nImported.<<<<>>>>>: 632\nname: Cozy Comfort Fleece Pullover\ndescription: The ultimate sweater fleece – made from superior fabric and offered at an unbeatable price. \n\nSize & Fit\nSlightly Fitted: Softly shapes the body. Falls at hip. \n\nWhy We Love It\nOur customers (and employees) love the rugged construction and heritage-inspired styling of our popular Sweater Fleece Pullover and wear it for absolutely everything. From high-intensity activities to everyday tasks, you'll find yourself reaching for it every time.\n\nFabric & Care\nRugged sweater-knit exterior and soft brushed interior for exceptional warmth and comfort. Made from soft, 100% polyester. Machine wash and dry.\n\nAdditional Features\nFeatures our classic Mount Katahdin logo. Snap placket. Front princess seams create a feminine shape. Kangaroo handwarmer pockets. Cuffs and hem reinforced with jersey binding. Imported.\n\n – Official Supplier to the U.S. Ski Team\nTHEIR WILL TO WIN, WOVEN RIGHT IN. LEARN MORE<<<<>>>>>: 151\nname: Cozy Quilted Sweatshirt\ndescription: Our sweatshirt is an instant classic with its great quilted texture and versatile weight that easily transitions between seasons. With a traditional fit that is relaxed through the chest, sleeve, and waist, this pullover is lightweight enough to be worn most months of the year. The cotton blend fabric is super soft and comfortable, making it the perfect casual layer. To make dressing easy, this sweatshirt also features a snap placket and a heritage-inspired Mt. Katahdin logo patch. For care, machine wash and dry. Imported."}[llm/start] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain > 4:chain:LLMChain > 5:llm:ChatOpenAI] Entering LLM run with input:{"prompts": ["System: Use the following pieces of context to answer the users question. \nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n: 10\nname: Cozy Comfort Pullover Set, Stripe\ndescription: Perfect for lounging, this striped knit set lives up to its name. We used ultrasoft fabric and an easy design that's as comfortable at bedtime as it is when we have to make a quick run out.\n\nSize & Fit\n- Pants are Favorite Fit: Sits lower on the waist.\n- Relaxed Fit: Our most generous fit sits farthest from the body.\n\nFabric & Care\n- In the softest blend of 63% polyester, 35% rayon and 2% spandex.\n\nAdditional Features\n- Relaxed fit top with raglan sleeves and rounded hem.\n- Pull-on pants have a wide elastic waistband and drawstring, side pockets and a modern slim leg.\n\nImported.<<<<>>>>>: 73\nname: Cozy Cuddles Knit Pullover Set\ndescription: Perfect for lounging, this knit set lives up to its name. We used ultrasoft fabric and an easy design that's as comfortable at bedtime as it is when we have to make a quick run out. \n\nSize & Fit \nPants are Favorite Fit: Sits lower on the waist. \nRelaxed Fit: Our most generous fit sits farthest from the body. \n\nFabric & Care \nIn the softest blend of 63% polyester, 35% rayon and 2% spandex.\n\nAdditional Features \nRelaxed fit top with raglan sleeves and rounded hem. \nPull-on pants have a wide elastic waistband and drawstring, side pockets and a modern slim leg. \nImported.<<<<>>>>>: 632\nname: Cozy Comfort Fleece Pullover\ndescription: The ultimate sweater fleece – made from superior fabric and offered at an unbeatable price. \n\nSize & Fit\nSlightly Fitted: Softly shapes the body. Falls at hip. \n\nWhy We Love It\nOur customers (and employees) love the rugged construction and heritage-inspired styling of our popular Sweater Fleece Pullover and wear it for absolutely everything. From high-intensity activities to everyday tasks, you'll find yourself reaching for it every time.\n\nFabric & Care\nRugged sweater-knit exterior and soft brushed interior for exceptional warmth and comfort. Made from soft, 100% polyester. Machine wash and dry.\n\nAdditional Features\nFeatures our classic Mount Katahdin logo. Snap placket. Front princess seams create a feminine shape. Kangaroo handwarmer pockets. Cuffs and hem reinforced with jersey binding. Imported.\n\n – Official Supplier to the U.S. Ski Team\nTHEIR WILL TO WIN, WOVEN RIGHT IN. LEARN MORE<<<<>>>>>: 151\nname: Cozy Quilted Sweatshirt\ndescription: Our sweatshirt is an instant classic with its great quilted texture and versatile weight that easily transitions between seasons. With a traditional fit that is relaxed through the chest, sleeve, and waist, this pullover is lightweight enough to be worn most months of the year. The cotton blend fabric is super soft and comfortable, making it the perfect casual layer. To make dressing easy, this sweatshirt also features a snap placket and a heritage-inspired Mt. Katahdin logo patch. For care, machine wash and dry. Imported.\nHuman: Do the Cozy Comfort Pullover Set have side pockets?"]}[llm/end] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain > 4:chain:LLMChain > 5:llm:ChatOpenAI] [1.20s] Exiting LLM run with output:{"generations": [[ {"text": "Yes, the Cozy Comfort Pullover Set does have side pockets.","generation_info":null,"message": {"lc": 1,"type":"constructor","id": ["langchain","schema","messages","AIMessage"],"kwargs": {"content":"Yes, the Cozy Comfort Pullover Set does have side pockets.","additional_kwargs": {}}}}]],"llm_output": {"token_usage": {"prompt_tokens": 732,"completion_tokens": 14,"total_tokens": 746},"model_name":"gpt-3.5-turbo"},"run": null}[chain/end] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain > 4:chain:LLMChain] [1.20s] Exiting Chain run with output:{"text":"Yes, the Cozy Comfort Pullover Set does have side pockets."}[chain/end] [1:chain:RetrievalQA > 3:chain:StuffDocumentsChain] [1.20s] Exiting Chain run with output:{"output_text":"Yes, the Cozy Comfort Pullover Set does have side pockets."}[chain/end][1:chain:RetrievalQA][5.15s] Exiting Chain run with output:{"result":"Yes, the Cozy Comfort Pullover Set does have side pockets."}
Turn of debug mode
# Turn off the debug modelangchain.debug =False
Limitations
Only possible for relatively simple applications
In the next section, we take a look at an automated approach
for i, eg inenumerate(examples):print(f"Example {i}:")print("Question: "+ predictions[i]['query'])print("Real Answer: "+ predictions[i]['answer'])print("Predicted Answer: "+ predictions[i]['result'])print("Predicted Grade: "+ graded_outputs[i]['text'])print()
Example 0:Question: Do the Cozy Comfort Pullover Set have side pockets?Real Answer: YesPredicted Answer: Yes, the Cozy Comfort Pullover Set does have side pockets.Predicted Grade: CORRECTExample 1:Question: What collection is the Ultra-Lofty 850 Stretch Down Hooded Jacket from?Real Answer: The DownTek collectionPredicted Answer: The Ultra-Lofty 850 Stretch Down Hooded Jacket is from the DownTek collection.Predicted Grade: CORRECTExample 2:Question: What is the weight of one pair of Women's Campside Oxfords?Real Answer: The approximate weight of one pair of Women's Campside Oxfords is 1 lb. 1 oz.Predicted Answer: The weight of one pair of Women's Campside Oxfords is approximately 1 lb. 1 oz.Predicted Grade: CORRECTExample 3:Question: What are the dimensions of the medium-sized Recycled Waterhog Dog Mat, Chevron Weave?Real Answer: The dimensions of the medium-sized Recycled Waterhog Dog Mat, Chevron Weave are 22.5" x 34.5".Predicted Answer: The dimensions of the medium-sized Recycled Waterhog Dog Mat, Chevron Weave are 22.5" x 34.5".Predicted Grade: CORRECTExample 4:...Real Answer: The fabric composition of the EcoFlex 3L Storm Pants is 100% nylon, exclusive of trim.Predicted Answer: The fabric composition of the EcoFlex 3L Storm Pants is 100% nylon, exclusive of trim.Predicted Grade: CORRECT