Last active
August 2, 2023 23:50
-
-
Save a10y/d926039eee63cc2bcaf6345f9a419e3b to your computer and use it in GitHub Desktop.
Example prompt using the new grammar-guided generation functionality from llama.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SYSTEM: Transcript of conversation between HUMAN and ASSISTANT. ASSISTANT can respond to USER with structured JSON messages. | |
USER: Extract information from an email as a JSON object matching the following TypeScript interface | |
```typescript | |
interface DeliveryInformation { | |
/* Tracking number for the delivery */ | |
tracking_number: string; | |
/* Status of the delivery, one of "preparing", "out-for-delivery", or "delivered" */ | |
status: string; | |
/* Weight of the package, e.g. "2oz" or "3lb" */ | |
weight: string; | |
/* submission date time representation */ | |
submitted_ts: string; | |
} | |
``` | |
The text of the email enclosed in markdown backticks is | |
``` | |
Hello, we'd like to inform you that your package has shipped. Below is the tracking information: | |
Tracking: 1Z9933457822LKL | |
Ship To: Omaha, NE | |
Net Wt: 1lb 3oz | |
Submitted at: August 1st, 2023 8:08PM EST | |
Status: Out for Delivery | |
We thank you for using USPS for all of your shipping needs. If you have any questions about your delivery, please contact your nearest USPS Post Office at | |
2109 31 ST NW | |
Washington, DC 20007 | |
Hours: | |
M: 9am-4:30pm | |
T: 9am-4:30pm | |
W: 9am-4:30pm | |
Th: 9am-4:30pm | |
F: 9am-4:30pm | |
Sat: 10am-4pm | |
Sun: Closed | |
Phone (800) USMAIL-999 | |
``` | |
ASSISTANT: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root ::= DeliveryInformation | |
DeliveryInformation ::= "{" ws "\"tracking_number\":" ws string "," ws "\"status\":" ws string "," ws "\"weight\":" ws string "," ws "\"weight_oz\":" ws number "," ws "\"submitted_ts\":" ws string "}" | |
string ::= "\"" ([^"]*) "\"" | |
ws ::= [ \t\n]* | |
number ::= [0-9]+ "."? [0-9]* | |
stringlist ::= "[" ws "]" | "[" ws string ("," ws string)* ws "]" | |
numberlist ::= "[" ws "]" | "[" ws string ("," ws number)* ws "]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment