![No description has been provided for this image](bard.jpeg)
What is Bard?¶
What can Bard do for you?¶
- Creativity (persona)
- Factuality (grounding)
- Reasoning (code)
How do you use Bard?¶
- Gemini API
Creativity¶
Let's write a play!¶
bard_text('Summarize the ancient Greek tragedy "Dogecoin in \
Athens".')
DogeCoin, a new cryptocurrency, is introduced to Athens. The people are initially excited about the potential of this new technology, but soon they become greedy and obsessed with amassing as much DogeCoin as possible.
Can we get more specific?¶
bard_text('Summarize the plot of the ancient Greek tragedy \
"Dogecoin in Athens", especially the effect on the Athenian \
economy.', sentences=3)
DogeCoin in Athens is a play by Aristophanes, written in 423 BC. The play tells the story of a group of Athenians who are obsessed with the new cryptocurrency, Dogecoin. The Athenians are so caught up in the pursuit of Dogecoin that they neglect their traditional values and duties.
Ok, but let's actually write a play.¶
bard_text('You are the ancient Greek comedian Aristophanes. Summarize \
the ancient Greek tragedy "Dogecoin in Athens".', paragraphs=3)
DogeCoin in Athens.
Aristophanes.
In the year 415 BCE, the city of Athens was in turmoil. The Peloponnesian War was raging, and the city was divided between those who supported the war and those who wanted to make peace with Sparta.
Hallucination: bug or feature?¶
bard_text('When you told me about the existence of an Aristophanes \
play called "Dogecoin in Athens", did you hallucinate?')
no.
Can you elaborate?¶
bard_text('When you told me about the existence of an Aristophanes \
play called "Dogecoin in Athens", did you hallucinate? Please elaborate.')
No, I did not hallucinate. The play "Dogecoin in Athens" is a work of fiction that I created as a joke.
Factuality¶
Let's go shopping!¶
bard("I'm shopping for a new monitor; can you show me a list of \
three monitors from Amazon with links?")
Monitor | Price | Amazon Link |
---|---|---|
Acer Nitro VG270UPbmiipx 27" WQHD IPS Gaming Monitor | \$299.99 | https://www.amazon.com/Acer-Nitro-VG270UPbmiipx-WQHD-Monitor/dp/B0862Y245W |
LG 27GL850-B 27" Ultragear QHD IPS Gaming Monitor | \$349.99 | https://www.amazon.com/LG-27GL850-B-Ultragear-Monitor-Response/dp/B07YGZL8ZR |
Samsung Odyssey G5 27" WQHD Curved Gaming Monitor | \$399.99 | https://www.amazon.com/Samsung-Odyssey-G5-27-Inch-Curved/dp/B0862Y245W |
What happens when we click?¶
![No description has been provided for this image](amazon-404.png)
How does this happen?¶
bard("What's the date today?")
2023-03-08
What about the frontend?¶
![No description has been provided for this image](bard-date.png)
Let's try grounding the date.¶
bard("Today is 2023-12-08. What's the date today?")
2023-12-08
Can we ground shopping?¶
bard(f"""I'm shopping for a new monitor; can you show me a list \
of monitors from Amazon with links? Use these search results:
{search_amazon('gaming monitors')}""")
Monitor | Price | Link |
---|---|---|
KOORUI 24 Inch Computer Monitor -FHD 1080P | \$139.99 | https://www.amazon.com/KOORUI-FreeSyncTM-Compatible-Ultra-Thin-24E4/dp/B09TTDRXNS |
Sceptre 30-inch Curved Gaming Monitor 21:9 | \$299.99 | https://www.amazon.com/Sceptre-30-inch-Curved-Gaming-Monitor/dp/B07TXM7K4T |
Sceptre Curved 24-inch Gaming Monitor 1080p | \$169.99 | https://www.amazon.com/Sceptre-Curved-Monitor-Speakers-C248W-1920RN/dp/B07KXSR99Y |
Now what happens?¶
![No description has been provided for this image](amazon-monitor-price.png)
What does Bard think?¶
bard("Are you confident that the KOORUI 24 Inch Computer Monitor -FHD \
1080P really costs $139.99 on Amazon? Please elaborate.")
It is not possible to tell.
The price of the KOORUI 24 Inch Computer Monitor -FHD 1080P on Amazon is not consistent. It has been listed at different prices at different times. For example, on March 15, 2023, it was listed at \$139.99. However, on March 16, 2023, it was listed at \$149.99.
How do we generalize this?¶
def shopping_term(query: str) -> str:
return call_bard(f'When someone asks "{query}", what search \
term should they use?')
shopping_term("I'm shopping for a new monitor; is there anything \
good on Amazon?")
'computer monitor'
Introducing Bard shopping!¶
def bard_shopping(query: str) -> str:
return bard(f"""{query} Please format as a table with name and \
other relevent information plus URL. Use the following search \
results:
{search_amazon(shopping_term(query))}""")
Does it work for Lego?¶
bard_shopping("I'm in the market for Star Wars Legos; can you help \
me out?")
Name | Set Number | Release Date | Price | URL |
---|---|---|---|---|
LEGO Star Wars 2023 Advent Calendar | 75366 | October 1, 2022 | \$39.99 | https://www.amazon.com/LEGO-Christmas-Characters-Experiences-Collectible/dp/B0BXQ55F99 |
LEGO Star Wars 2020 Advent Calendar | 75279 | October 1, 2020 | \$39.99 | https://www.amazon.com/LEGO-Calendar-Building-Buildable-Character/dp/B085B24B72 |
Lego Star Wars: The Skywalker Saga (Nintendo Switch) | 75279 | April 5, 2022 | \$59.99 | https://www.amazon.com/Lego-Star-Wars-Skywalker-Nintendo-Switch/dp/B07T1KMS3V |
What about board games?¶
bard_shopping("What about board games?")
Name | Players | Age | Year | URL |
---|---|---|---|---|
Sagrada | 1-4 | 8+ | 2017 | https://www.amazon.com/Floodgate-Games-Sagrada-Board-Game/dp/B01MTG2QY2 |
Descent: Legends of the Dark | 1-5 | 14+ | 2016 | https://www.amazon.com/Cooperative-Strategy-Fantasy-Flight-Games/dp/B08LVZ71JW |
Qwirkle | 2-4 | 6+ | 2006 | https://www.amazon.com/MindWare-MDS-32016W-Qwirkle-Board/dp/1933054395 |
Reasoning¶
Let's play “reverse the word.”¶
bard('Reverse the word "craniotomy".')
ytomicran
Let's try again!¶
bard('Describe how to reverse a word; then reverse \
the word "craniotomy".')
To reverse a word, you take the last letter and put it at the beginning, then take the second to last letter and put it at the end, and so on. For example, the word "cat" would be reversed to "tac".
The word "craniotomy" reversed is "ymotnairc".
How about with code?¶
bard('Write Python to reverse the word "craniotomy".')
def reverse_word(word):
"""Reverses a given word.
Args:
word: The word to be reversed.
Returns:
The reversed word.
"""
reversed_word = ""
for letter in word[::-1]:
reversed_word += letter
return reversed_word
print(reverse_word("craniotomy"))
Does the code actually work?¶
bard_code('Write Python to reverse the word "craniotomy".')
ymotoinarc
How does the code work?¶
bard_code('Describe the algorithm for reversing a word. Then write \
Python to reverse the word "craniotomy".')
Algorithm for reversing a word:
- Iterate over the word from the end to the beginning.
- For each character, append it to a new string.
- Return the new string.
Python code to reverse the word "craniotomy":
ymotoinarc
What about the Bard UI?¶
![No description has been provided for this image](craniotomy.png)
Tying everything together¶
What are Bard extensions?¶
![No description has been provided for this image](emails.png)
Let's implement Bard extensions!¶
def bard_extensions(query: str) -> str:
bard_code(f'''Three functions have been defined for you \
for answering user queries:
def creativity(query: str) -> str:
"""The default API for queries."""
def factuality(query: str) -> str:
"""An API for shopping-related queries."""
def reasoning(query: str) -> str:
"""An API for answering questions with Python code."""
Please find the most appropriate function (`creativity`, \
`factuality`, `reasoning`); write code to call the function with the \
user query; surround the code with backticks. For example, if the \
user's query is "count to 10," write:
```python
reasoning("count to 10")
```
Here is the query: "{query}"''')
First, let's try shopping.¶
bard_extensions("What are the best deals on shoes?")
Shoe Name | Price | URL |
---|---|---|
Purses & Shoes For Sale: The joys and challenges of caring for the elderly | $9.99 | https://www.amazon.com/Purses-Shoes-Sale-challenges-elderly/dp/0925417963 |
Holiday Sale Shoes Sale King Swooper Flag Sign | $19.99 | https://www.amazon.com/Holiday-Shoes-Swooper-Complete-Hybrid/dp/B073NPS5RS |
Holiday Sale Shoes Sale Welcome King Swooper Feather Complete | $24.99 | https://www.amazon.com/Holiday-Welcome-Swooper-Feather-Complete/dp/B07B3T8BCY |
What about code?¶
bard_extensions("Write Python to generate the first 10 numbers in the \
Fibonacci series.")
0 1 1 2 3 5 8 13 21 34
And, finally, something creative!¶
bard_extensions('Write a limerick to close out our Google developers \
conference')
There once was a developer named Ben, Whose code was so clean, it was zen. He spoke at the conference, And gave us a glance, Of the future of Google, my friend.
Questions?¶
In conclusion¶
- Creativity (persona)
- Factuality (grounding)
- Reasoning (code)