From 387d5218b27de1c3511e3c76c32335ba7adf9ca5 Mon Sep 17 00:00:00 2001 From: Saumya Shah <131935677+Shah-Saumya@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:34:31 +0530 Subject: [PATCH] Improve structured data content for rookies (#7137) Improve the content in `src/data/roadmaps/prompt-engineering/content/103-real-world/100-structured-data.md` to be more concise and understandable for rookies. --- .../103-real-world/100-structured-data.md | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/data/roadmaps/prompt-engineering/content/103-real-world/100-structured-data.md b/src/data/roadmaps/prompt-engineering/content/103-real-world/100-structured-data.md index cd9b3f93c..8e1814ae2 100644 --- a/src/data/roadmaps/prompt-engineering/content/103-real-world/100-structured-data.md +++ b/src/data/roadmaps/prompt-engineering/content/103-real-world/100-structured-data.md @@ -1,15 +1,19 @@ # Structured Data -Asking the model to generate structured data is a great way to utilize the power of LLMs. +Structured data helps in organizing information. It is especially useful in applications like e-commerce where you need to convert user input into a structured format. -For example, you might have an e-commerce application where you want to generate the search query from the user's natural language input. You can instruct LLM to identify the JSON version from the natural language text given by the user. Let's say that the user searches for `Birthday gift for my 18 months old daughter`. We could have the following prompt to generate the JSON object: +### Example 1 + +Let's say a user searches for `Birthday gift for my 18 months old daughter`. You can use a prompt to generate a JSON object from this input: ``` -Print a JSON object containing `gender` ("male", "female"), `occasion` (one of "party", "birthday", "anniversary"), `age_years` (numeric value) from the text delimited by tripple quotes.: +Print a JSON object containing `gender` ("male", "female"), `occasion` (one of "party", "birthday", "anniversary"), `age_years` (numeric value) from the text delimited by triple quotes: """Birthday gift for my 18 months old daughter""" ``` -The output from model would be: +### Output + +The model would generate the following JSON object: ```json { @@ -18,3 +22,24 @@ The output from model would be: "age_years": 1.5 } ``` + +### Example 2 + +Consider a user input `Anniversary gift for my husband`. You can use a prompt to generate a JSON object from this input: + +``` +Print a JSON object containing `gender` ("male", "female"), `occasion` (one of "party", "birthday", "anniversary"), `age_years` (numeric value) from the text delimited by triple quotes: +"""Anniversary gift for my husband""" +``` + +### Output + +The model would generate the following JSON object: + +```json +{ + "gender": "male", + "occasion": "anniversary", + "age_years": null +} +```